Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 3rd party libs, part1 #3616

Merged
merged 8 commits into from
Oct 3, 2024
Merged

Update 3rd party libs, part1 #3616

merged 8 commits into from
Oct 3, 2024

Conversation

georgeliao
Copy link
Contributor

@georgeliao georgeliao commented Aug 1, 2024

link to all multipass related forked repos https://github.com/orgs/canonical/teams/multipass/repositories
This is only part1, part2 is #3707

Private part, https://github.com/canonical/multipass-private/pull/666

FetchContent:

  1. googletest, main branch as GIT_TAG, nothing to update

git submodule:

  • Original repo
    1. fmt, 10.1.1 -> 11.0.2, includes small code adjustment.
    2. xz-decode, linux-2.6.38-26-g090e6a0 -> v20240322.
    3. scope_guard, nothing to update
    4. flutter, current version 3.16.9. Its update is out of the scope of this PR.
    5. protobuf.dart, current version protobuf-v1.1.4-251-gc559fe. Its update is out of the scope of this PR.
  • Forked repo, aka with our patches as top commits.
    1. libssh currently is on 0.10.5 it is updated to 0.11.1, forked repo
    2. semver, current version is the latest version 1.1.0
    3. yaml-cpp, updated from 0.6.3 to 0.8.0, forked repo

vcpkg:

1. Poco, 1.12.4 -> 1.13.3

@georgeliao georgeliao marked this pull request as draft August 1, 2024 12:50
@georgeliao georgeliao changed the title 1[3rd part fmt] update fmt submodule from 10.1.1 to 11.0.2 and applie… [3rd part fmt] update fmt submodule from 10.1.1 to 11.0.2 and applie… Aug 1, 2024
@georgeliao georgeliao force-pushed the update_3rd_lib_version branch from 01ffa4e to 576cdf2 Compare August 1, 2024 12:50
@georgeliao georgeliao changed the title [3rd part fmt] update fmt submodule from 10.1.1 to 11.0.2 and applie… update 3rd party libs Aug 1, 2024
@georgeliao georgeliao changed the title update 3rd party libs Update 3rd party libs Aug 1, 2024
@georgeliao georgeliao force-pushed the update_3rd_lib_version branch from 576cdf2 to a39d6e0 Compare August 1, 2024 12:58
Copy link

codecov bot commented Aug 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.92%. Comparing base (76172f4) to head (d79d2c9).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3616      +/-   ##
==========================================
+ Coverage   88.88%   88.92%   +0.03%     
==========================================
  Files         254      254              
  Lines       14293    14294       +1     
==========================================
+ Hits        12705    12711       +6     
+ Misses       1588     1583       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@georgeliao georgeliao force-pushed the update_3rd_lib_version branch 4 times, most recently from 357fde4 to 3a88457 Compare August 6, 2024 13:35
@georgeliao georgeliao force-pushed the update_3rd_lib_version branch 2 times, most recently from b35fbab to 7df76fe Compare August 12, 2024 10:05
@ricab ricab added this to the 1.15.0 milestone Sep 23, 2024
Copy link
Contributor

@Sploder12 Sploder12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM so far, just a couple links that should be updated. Notify me when gRPC is ready! :)

3rd-party/submodule_info.md Outdated Show resolved Hide resolved
3rd-party/submodule_info.md Outdated Show resolved Hide resolved
@georgeliao georgeliao force-pushed the update_3rd_lib_version branch 2 times, most recently from 6fee681 to a458656 Compare September 30, 2024 16:21
@georgeliao georgeliao changed the title Update 3rd party libs Update 3rd party libs, part1 Sep 30, 2024
string(REGEX MATCH "^project\\(libssh VERSION ([0-9]+)\\.([0-9]+)\\.([0-9]+) LANGUAGES C\\)$"
libssh_VERSION "${libssh_VERSION}")
string(REGEX MATCH "^project\\(libssh VERSION ([0-9]+)\\.([0-9]+)\\.([0-9]+) LANGUAGES C CXX\\)$"
libssh_VERSION "${libssh_VERSION}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is due to the regex match failure stems from the change in the internal CMakeLists.txt change of libssh, the line
project(libssh VERSION 0.11.1 LANGUAGES C CXX) is appended with CXX.

@@ -12,12 +12,12 @@ Version: 1.52.1 (+[our patches](https://github.com/CanonicalLtd/grpc/compare/v1.
<https://github.com/grpc/grpc/releases>

### libssh
Version: 0.10.5 (+[our patches](https://github.com/canonical/libssh/compare/libssh-0.10.5..843b97db)) |
Version: 0.11.1 (+[our patches](https://github.com/canonical/libssh/compare/libssh-0.11.1...multipass)) |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using multipass branch name as opposed to commit hash to prevent adaptive change in the future.

@georgeliao georgeliao marked this pull request as ready for review October 1, 2024 13:51
@georgeliao
Copy link
Contributor Author

Hi @Sploder12
The part1 of 3rd party library update is ready for review.

I did a final scan on the latest version of the packages, it turned out that libssh can be upgraded further to 0.11.1 instead of 0.10.6. So the corresponding cherry-pick and push were done. Please perform a careful check on the new patches, meaning compare the patches with the ones on the 0.10.5 and see if it makes sense. You can find it either via submodule_info.md patch link or jump to the libssh repo by yourself. Please do the very same thing to yaml-cpp as well, if you have done that already, just simply let me know it looks good to you.

@georgeliao georgeliao marked this pull request as draft October 1, 2024 14:01
@georgeliao georgeliao marked this pull request as ready for review October 1, 2024 14:02
@georgeliao georgeliao force-pushed the update_3rd_lib_version branch from b277676 to ca31a3a Compare October 1, 2024 14:06
Copy link
Contributor

@Sploder12 Sploder12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly good. Tests pass and didn't notice any issues when running! Just some issues with edge cases in libssh changes.

3rd-party/libssh/libssh Outdated Show resolved Hide resolved
@georgeliao georgeliao force-pushed the update_3rd_lib_version branch from ca31a3a to 25a88f3 Compare October 2, 2024 10:49
@georgeliao
Copy link
Contributor Author

line 708: potential off by one error, the check should probably be >=

Not sure I get this one, did you mean val is 0-index based so val == sftp->total_allocated_handles is already an invalid condition?

    memcpy(&val, ssh_string_data(handle), sizeof(uint32_t));

    if (val > sftp->total_allocated_handles) {
      return NULL;
    }

@georgeliao
Copy link
Contributor Author

georgeliao commented Oct 2, 2024

in file src/sftpserver.c

lines 674-676: if realloc fails then sftp->total_allocated_handles is still as if the realloc succeeded, this could lead to out-of-bounds issues later on in the program.

  if (i == sftp->total_allocated_handles) {
    uint32_t old_size = sftp->total_allocated_handles;
    sftp->total_allocated_handles += SFTP_HANDLES_CHUNK_SZ;

    void **tmp = realloc(sftp->handles, sftp->total_allocated_handles * sizeof(void *));
    if (tmp == NULL)
        return NULL; /* no handle available */

    sftp->handles = tmp;
    memset(sftp->handles + old_size, '\0', SFTP_HANDLES_CHUNK_SZ * sizeof(void *));
  }

Indeed, sftp->total_allocated_handles should be incremented only if realloc succeeds, what do you think of the proposed code snippet below?

  if (i == sftp->total_allocated_handles) {
    uint32_t temp_new_size = sftp->total_allocated_handles + SFTP_HANDLES_CHUNK_SZ;

    void **tmp = realloc(sftp->handles, temp_new_size * sizeof(void *));
    if (tmp == NULL)
        return NULL; /* no handle available */

    sftp->handles = tmp;
    uint32_t old_size = sftp->total_allocated_handles;
    sftp->total_allocated_handles = temp_new_size;
    memset(sftp->handles + old_size, '\0', SFTP_HANDLES_CHUNK_SZ * sizeof(void *));
  }

@Sploder12
Copy link
Contributor

line 708: potential off by one error, the check should probably be >=

Not sure I get this one, did you mean val is 0-index based so val == sftp->total_allocated_handles is already an invalid condition?

    memcpy(&val, ssh_string_data(handle), sizeof(uint32_t));

    if (val > sftp->total_allocated_handles) {
      return NULL;
    }

Yeah, if val == sftp->total_allocated_handles then there is an out of bounds read afterwards.

@Sploder12
Copy link
Contributor

  if (i == sftp->total_allocated_handles) {
    uint32_t old_size = sftp->total_allocated_handles;
    sftp->total_allocated_handles += SFTP_HANDLES_CHUNK_SZ;

    void **tmp = realloc(sftp->handles, sftp->total_allocated_handles * sizeof(void *));
    if (tmp == NULL)
        return NULL; /* no handle available */

    sftp->handles = tmp;
    memset(sftp->handles + old_size, '\0', SFTP_HANDLES_CHUNK_SZ * sizeof(void *));
  }

Indeed, sftp->total_allocated_handles should be incremented only if realloc succeeds, what do you think of the proposed code snippet below?

  if (i == sftp->total_allocated_handles) {
    uint32_t temp_new_size = sftp->total_allocated_handles + SFTP_HANDLES_CHUNK_SZ;

    void **tmp = realloc(sftp->handles, temp_new_size * sizeof(void *));
    if (tmp == NULL)
        return NULL; /* no handle available */

    sftp->handles = tmp;
    uint32_t old_size = sftp->total_allocated_handles;
    sftp->total_allocated_handles = temp_new_size;
    memset(sftp->handles + old_size, '\0', SFTP_HANDLES_CHUNK_SZ * sizeof(void *));
  }

The proposed code looks good!

@georgeliao
Copy link
Contributor Author

georgeliao commented Oct 2, 2024

@Sploder12
Another thing is that the windows build has been failing on ssh lib compilation since we upgraded to 0.10.6 from 0.10.5, the private part has a small change to fix that. See the intro comment for the link to the private side.

@georgeliao
Copy link
Contributor Author

Yeah, if val == sftp->total_allocated_handles then there is an out of bounds read afterwards.

Then we are also fixing the libssh original code as opposed to fixing out patches. Not sure if we should do that.

The proposed code looks good!

This one is fixing the legacy patches as opposed to this particular rebase. So maybe this can be done.

@georgeliao
Copy link
Contributor Author

@Sploder12

The proposed code looks good!

This is added to libssh repo. Please have another check. The other change will deviate from the original code of libssh and it adds complexity to the patches even though it might be a corner case bug. So I am inclined to leave it. What do you think?

@Sploder12
Copy link
Contributor

This is added to libssh repo. Please have another check. The other change will deviate from the original code of libssh and it adds complexity to the patches even though it might be a corner case bug. So I am inclined to leave it. What do you think?

Looks good! It's not a big bug, and I doubt it's possible under normal execution, so I think leaving it is fine. Sorry, GitHub doesn't really make submodule changes clear.

Sploder12
Sploder12 previously approved these changes Oct 2, 2024
@georgeliao
Copy link
Contributor Author

@Sploder12
The latest commit cherry-pick was redone, so now it only grafts the commit. Feel free to make another PR to adapt the format and add the if block code we have proposed in a different PR.

Once the build is finished, feel free to merge.

Copy link
Contributor

@Sploder12 Sploder12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@georgeliao georgeliao added this pull request to the merge queue Oct 3, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 3, 2024
@georgeliao georgeliao force-pushed the update_3rd_lib_version branch from 2a93369 to d79d2c9 Compare October 3, 2024 09:36
@ricab
Copy link
Collaborator

ricab commented Oct 3, 2024

This won't pass on the merge queue without the private side, need to merge manually.

@ricab ricab merged commit 183583d into main Oct 3, 2024
14 checks passed
@ricab ricab deleted the update_3rd_lib_version branch October 3, 2024 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants