]> Git Repo - linux.git/commit
mm/fadvise.c: fix signed overflow UBSAN complaint
authorAndrey Ryabinin <[email protected]>
Fri, 17 Aug 2018 22:46:57 +0000 (15:46 -0700)
committerLinus Torvalds <[email protected]>
Fri, 17 Aug 2018 23:20:30 +0000 (16:20 -0700)
commita718e28f538441a3b6612da9ff226973376cdf0f
treeb5830c2c461c94774130af6d18428e578731c82d
parent31f21da18132fc971297175077fafa3bd4184dc1
mm/fadvise.c: fix signed overflow UBSAN complaint

Signed integer overflow is undefined according to the C standard.  The
overflow in ksys_fadvise64_64() is deliberate, but since it is signed
overflow, UBSAN complains:

UBSAN: Undefined behaviour in mm/fadvise.c:76:10
signed integer overflow:
4 + 9223372036854775805 cannot be represented in type 'long long int'

Use unsigned types to do math.  Unsigned overflow is defined so UBSAN
will not complain about it.  This patch doesn't change generated code.

[[email protected]: add comment explaining the casts]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Andrey Ryabinin <[email protected]>
Reported-by: <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/fadvise.c
This page took 0.066939 seconds and 4 git commands to generate.