diff options
| author | Eric Biggers <ebiggers@google.com> | 2016-08-19 12:15:22 -0700 | 
|---|---|---|
| committer | Sami Tolvanen <samitolvanen@google.com> | 2016-09-06 15:54:48 +0000 | 
| commit | 43243ce74a56007bf71e4fb3310f475fd4441ce4 (patch) | |
| tree | 6f9560c3993a80e38f10ecbdef1445e668a90b1a /include/linux/blkdev.h | |
| parent | 3a9c8260c66ce387754641134089ba6ea5793bd5 (diff) | |
UPSTREAM: usercopy: avoid potentially undefined behavior in pointer math
check_bogus_address() checked for pointer overflow using this expression,
where 'ptr' has type 'const void *':
	ptr + n < ptr
Since pointer wraparound is undefined behavior, gcc at -O2 by default
treats it like the following, which would not behave as intended:
	(long)n < 0
Fortunately, this doesn't currently happen for kernel code because kernel
code is compiled with -fno-strict-overflow.  But the expression should be
fixed anyway to use well-defined integer arithmetic, since it could be
treated differently by different compilers in the future or could be
reported by tools checking for undefined behavior.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Change-Id: I73b13be651cf35c03482f2014bf2c3dd291518ab
(cherry picked from commit 7329a655875a2f4bd6984fe8a7e00a6981e802f3)
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Diffstat (limited to 'include/linux/blkdev.h')
0 files changed, 0 insertions, 0 deletions
