Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[linux-block.git] / mm / fadvise.c
index afa41491d324819271b7d2f7629b56da7f4006fa..2d8376e3c6408bf1ea058570dad64079cae7632d 100644 (file)
@@ -72,8 +72,12 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
                goto out;
        }
 
-       /* Careful about overflows. Len == 0 means "as much as possible" */
-       endbyte = offset + len;
+       /*
+        * Careful about overflows. Len == 0 means "as much as possible".  Use
+        * unsigned math because signed overflows are undefined and UBSan
+        * complains.
+        */
+       endbyte = (u64)offset + (u64)len;
        if (!len || endbyte < len)
                endbyte = -1;
        else