-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Fix invalid pointer arithmetic in Hash #1222
Merged
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
It is UB to exceed the bounds of the buffer when doing pointer arithemetic. That means the following is not a valid bounds check: if (start + 4 <= limit) Because if we were at the end of the buffer, we wouldn't be allowed to add 4 anyway. Instead, this must be written as: if (limit - start >= 4) Basic forms of this issue are flagged by UBSan. If building with -fsanitize=undefined, the following test trips an error: [ RUN ] HASH.SignedUnsignedIssue .../leveldb/util/hash.cc:30:15: runtime error: applying non-zero offset 4 to null pointer SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/local/google/home/davidben/leveldb/util/hash.cc:30:15 in [ OK ] HASH.SignedUnsignedIssue (1 ms)
CC @a-sully just because I noticed this repo isn't getting that much activity and you last merged something here. 😄 |
aarongable
pushed a commit
to chromium/chromium
that referenced
this pull request
Dec 24, 2024
This is a reland of commit 103f0ee The fix for leveldb is google/leveldb#1222, but add a suppression for now. Original change's description: > Add -fsanitize=pointer-overflow to the UBSan config > > This required adding a couple suppressions for issues. Also fixing > undefined behavior in BufferIteratorTest.ObjectSizeOverflow, which seems > to have not been testing SIZE_MAX at all, and just when the buffer > didn't have enough room. > > Bug: 40942951, 384391188, 385062729, 385155394 > Change-Id: If6defef3fbc4977632fccc63049901836d4a5347 > Cq-Include-Trybots: luci.chromium.try:linux_chromium_ubsan_rel_ng > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6108769 > Reviewed-by: Nico Weber <thakis@chromium.org> > Reviewed-by: Daniel Cheng <dcheng@chromium.org> > Auto-Submit: David Benjamin <davidben@chromium.org> > Commit-Queue: David Benjamin <davidben@chromium.org> > Cr-Commit-Position: refs/heads/main@{#1399851} Bug: 40942951, 384391188, 385062729, 385155394 Change-Id: I535d865661be49f11a291c62671557f7541b2bb9 Cq-Include-Trybots: luci.chromium.try:linux_chromium_ubsan_rel_ng Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6120908 Auto-Submit: David Benjamin <davidben@chromium.org> Commit-Queue: David Benjamin <davidben@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Cr-Commit-Position: refs/heads/main@{#1399949}
github-actions bot
pushed a commit
to kaidokert/chrome_base_mirror
that referenced
this pull request
Dec 24, 2024
This is a reland of commit 103f0ee63afb8a42af04c9a152dc938e3571c128 The fix for leveldb is google/leveldb#1222, but add a suppression for now. Original change's description: > Add -fsanitize=pointer-overflow to the UBSan config > > This required adding a couple suppressions for issues. Also fixing > undefined behavior in BufferIteratorTest.ObjectSizeOverflow, which seems > to have not been testing SIZE_MAX at all, and just when the buffer > didn't have enough room. > > Bug: 40942951, 384391188, 385062729, 385155394 > Change-Id: If6defef3fbc4977632fccc63049901836d4a5347 > Cq-Include-Trybots: luci.chromium.try:linux_chromium_ubsan_rel_ng > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6108769 > Reviewed-by: Nico Weber <thakis@chromium.org> > Reviewed-by: Daniel Cheng <dcheng@chromium.org> > Auto-Submit: David Benjamin <davidben@chromium.org> > Commit-Queue: David Benjamin <davidben@chromium.org> > Cr-Commit-Position: refs/heads/main@{#1399851} Bug: 40942951, 384391188, 385062729, 385155394 Change-Id: I535d865661be49f11a291c62671557f7541b2bb9 Cq-Include-Trybots: luci.chromium.try:linux_chromium_ubsan_rel_ng Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6120908 Auto-Submit: David Benjamin <davidben@chromium.org> Commit-Queue: David Benjamin <davidben@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Cr-Commit-Position: refs/heads/main@{#1399949} NOKEYCHECK=True GitOrigin-RevId: fd7de0b84913bda60edcf21ab6c7c0cd017b1d70
jrguzman-ms
pushed a commit
to msft-mirror-aosp/platform.external.libchrome
that referenced
this pull request
Jan 1, 2025
This is a reland of commit 103f0ee63afb8a42af04c9a152dc938e3571c128 The fix for leveldb is google/leveldb#1222, but add a suppression for now. Original change's description: > Add -fsanitize=pointer-overflow to the UBSan config > > This required adding a couple suppressions for issues. Also fixing > undefined behavior in BufferIteratorTest.ObjectSizeOverflow, which seems > to have not been testing SIZE_MAX at all, and just when the buffer > didn't have enough room. > > Bug: 40942951, 384391188, 385062729, 385155394 > Change-Id: If6defef3fbc4977632fccc63049901836d4a5347 > Cq-Include-Trybots: luci.chromium.try:linux_chromium_ubsan_rel_ng > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6108769 > Reviewed-by: Nico Weber <thakis@chromium.org> > Reviewed-by: Daniel Cheng <dcheng@chromium.org> > Auto-Submit: David Benjamin <davidben@chromium.org> > Commit-Queue: David Benjamin <davidben@chromium.org> > Cr-Commit-Position: refs/heads/main@{#1399851} Bug: 40942951, 384391188, 385062729, 385155394 Change-Id: I535d865661be49f11a291c62671557f7541b2bb9 Cq-Include-Trybots: luci.chromium.try:linux_chromium_ubsan_rel_ng Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6120908 Auto-Submit: David Benjamin <davidben@chromium.org> Commit-Queue: David Benjamin <davidben@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Cr-Commit-Position: refs/heads/main@{#1399949} CrOS-Libchrome-Original-Commit: fd7de0b84913bda60edcf21ab6c7c0cd017b1d70
ogsts
pushed a commit
to ubiquiti/ubnt_libjingle_component_src_build
that referenced
this pull request
Jan 12, 2025
This is a reland of commit 103f0ee63afb8a42af04c9a152dc938e3571c128 The fix for leveldb is google/leveldb#1222, but add a suppression for now. Original change's description: > Add -fsanitize=pointer-overflow to the UBSan config > > This required adding a couple suppressions for issues. Also fixing > undefined behavior in BufferIteratorTest.ObjectSizeOverflow, which seems > to have not been testing SIZE_MAX at all, and just when the buffer > didn't have enough room. > > Bug: 40942951, 384391188, 385062729, 385155394 > Change-Id: If6defef3fbc4977632fccc63049901836d4a5347 > Cq-Include-Trybots: luci.chromium.try:linux_chromium_ubsan_rel_ng > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6108769 > Reviewed-by: Nico Weber <thakis@chromium.org> > Reviewed-by: Daniel Cheng <dcheng@chromium.org> > Auto-Submit: David Benjamin <davidben@chromium.org> > Commit-Queue: David Benjamin <davidben@chromium.org> > Cr-Commit-Position: refs/heads/main@{#1399851} Bug: 40942951, 384391188, 385062729, 385155394 Change-Id: I535d865661be49f11a291c62671557f7541b2bb9 Cq-Include-Trybots: luci.chromium.try:linux_chromium_ubsan_rel_ng Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6120908 Auto-Submit: David Benjamin <davidben@chromium.org> Commit-Queue: David Benjamin <davidben@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Cr-Commit-Position: refs/heads/main@{#1399949} NOKEYCHECK=True GitOrigin-RevId: fd7de0b84913bda60edcf21ab6c7c0cd017b1d70
maflcko
pushed a commit
to maflcko/leveldb-subtree
that referenced
this pull request
Jan 14, 2025
It is UB to exceed the bounds of the buffer when doing pointer arithemetic. That means the following is not a valid bounds check: if (start + 4 <= limit) Because if we were at the end of the buffer, we wouldn't be allowed to add 4 anyway. Instead, this must be written as: if (limit - start >= 4) Basic forms of this issue are flagged by UBSan. If building with -fsanitize=undefined, the following test trips an error: [ RUN ] HASH.SignedUnsignedIssue .../leveldb/util/hash.cc:30:15: runtime error: applying non-zero offset 4 to null pointer SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/local/google/home/davidben/leveldb/util/hash.cc:30:15 in [ OK ] HASH.SignedUnsignedIssue (1 ms) (cherry picked from commit 578eeb7)
fanquake
added a commit
to bitcoin-core/leveldb-subtree
that referenced
this pull request
Jan 16, 2025
a8844b2 Fix invalid pointer arithmetic in Hash (google#1222) (David Benjamin) Pull request description: It is UB to exceed the bounds of the buffer when doing pointer arithemetic. That means the following is not a valid bounds check: if (start + 4 <= limit) Because if we were at the end of the buffer, we wouldn't be allowed to add 4 anyway. Instead, this must be written as: if (limit - start >= 4) Basic forms of this issue are flagged by UBSan. If building with -fsanitize=undefined, the following test trips an error: [ RUN ] HASH.SignedUnsignedIssue .../leveldb/util/hash.cc:30:15: runtime error: applying non-zero offset 4 to null pointer SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/local/google/home/davidben/leveldb/util/hash.cc:30:15 in [ OK ] HASH.SignedUnsignedIssue (1 ms) (cherry picked from commit 578eeb7) ACKs for top commit: l0rinc: ACK a8844b2 fanquake: ACK a8844b2 Tree-SHA512: 4e3e7aa680ec0a7ed759dd47318876e78cc04bd65456b7b0e41f7c29f1f70cf0f9568b7f32056bedae8492ee7fe5510f25d74a48a27518185248c5c34e54fa2f
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
It is UB to exceed the bounds of the buffer when doing pointer arithemetic. That means the following is not a valid bounds check:
Because if we were at the end of the buffer, we wouldn't be allowed to add 4 anyway. Instead, this must be written as:
Basic forms of this issue are flagged by UBSan. If building with -fsanitize=undefined, the following test trips an error: