summaryrefslogtreecommitdiff
path: root/mm/fadvise.c
diff options
context:
space:
mode:
authorAndrey Ryabinin <aryabinin@virtuozzo.com>2018-08-10 13:25:58 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2018-08-13 04:11:46 +1000
commitaeeeaa7078d5c4989550406380f9a8c66d0f692f (patch)
tree4ea649285c84a01868b27be715faa6b723dd7d00 /mm/fadvise.c
parentf5d47494f404f012c357105a00ef4a03abfb61d3 (diff)
downloadlinux-next-aeeeaa7078d5c4989550406380f9a8c66d0f692f.tar.gz
mm/fadvise: 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. Link: http://lkml.kernel.org/r/20180629184453.7614-1-aryabinin@virtuozzo.com Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Reported-by: <icytxw@gmail.com> Cc: Alexander Potapenko <glider@google.com> Cc: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Diffstat (limited to 'mm/fadvise.c')
-rw-r--r--mm/fadvise.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/fadvise.c b/mm/fadvise.c
index afa41491d324..1eaf2002d79a 100644
--- a/mm/fadvise.c
+++ b/mm/fadvise.c
@@ -73,7 +73,7 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
}
/* Careful about overflows. Len == 0 means "as much as possible" */
- endbyte = offset + len;
+ endbyte = (u64)offset + (u64)len;
if (!len || endbyte < len)
endbyte = -1;
else