-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Use dummy allocator to make accesses defined as per standard #25688
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
the
please-review
PR is ready for (re-)review by a maintainer
label
Dec 9, 2022
This looks like a spurious gcc warning, I'll take a closer look and see how to fix up. |
poettering
requested changes
Dec 12, 2022
poettering
added
reviewed/needs-rework 🔨
PR has been reviewed and needs another round of reworks
and removed
please-review
PR is ready for (re-)review by a maintainer
labels
Dec 12, 2022
github-actions
bot
added
please-review
PR is ready for (re-)review by a maintainer
and removed
reviewed/needs-rework 🔨
PR has been reviewed and needs another round of reworks
labels
Dec 12, 2022
Changes from v1:
Tested with clang, gcc and the sanitizer fuzzer test that had failed, so hopefully this one should run fully clean. |
yuwata
requested changes
Dec 13, 2022
yuwata
added
util-lib
reviewed/needs-rework 🔨
PR has been reviewed and needs another round of reworks
and removed
please-review
PR is ready for (re-)review by a maintainer
labels
Dec 13, 2022
github-actions
bot
added
please-review
PR is ready for (re-)review by a maintainer
and removed
reviewed/needs-rework 🔨
PR has been reviewed and needs another round of reworks
labels
Dec 13, 2022
siddhesh
requested review from
yuwata and
poettering
and removed request for
yuwata
December 13, 2022 12:36
siddhesh
commented
Dec 13, 2022
poettering
requested changes
Dec 13, 2022
systemd uses malloc_usable_size() everywhere to use memory blocks obtained through malloc, but that is abuse since the malloc_usable_size() interface isn't meant for this kind of use, it is for diagnostics only. This is also why systemd behaviour is flaky when built with _FORTIFY_SOURCE. One way to make this more standard (and hence safer) is to, at every malloc_usable_size() call, also 'reallocate' the block so that the compiler can see the larger size. This is done through a dummy reallocator whose only purpose is to tell the compiler about the larger usable size, it doesn't do any actual reallocation. Florian Weimer pointed out that this doesn't solve the problem of an allocator potentially growing usable size at will, which will break the implicit assumption in systemd use that the value returned remains constant as long as the object is valid. The safest way to fix that is for systemd to step away from using malloc_usable_size() like this. Resolves #22801.
poettering
added
good-to-merge/waiting-for-ci 👍
PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed
and removed
please-review
PR is ready for (re-)review by a maintainer
labels
Dec 14, 2022
lgtm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
good-to-merge/waiting-for-ci 👍
PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed
util-lib
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
systemd uses malloc_usable_size() everywhere to use memory blocks obtained through malloc, but that is abuse since the malloc_usable_size() interface isn't meant for this kind of use, it is for diagnostics only. This is also why systemd behaviour is flaky when built with _FORTIFY_SOURCE.
One way to make this more standard (and hence safer) is to, at every malloc_usable_size() call, also 'reallocate' the block so that the compiler can see the larger size. This is done through a dummy reallocator whose only purpose is to tell the compiler about the larger usable size, it doesn't do any actual reallocation.
Florian Weimer pointed out that this doesn't solve the problem of an allocator potentially growing usable size at will, which will break the implicit assumption in systemd use that the value returned remains constant as long as the object is valid. The safest way to fix that is for systemd to step away from using malloc_usable_size() like this.
Resolves #22801.