Re: [PATCH] fs: Avoid signed overflow UBSAN warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Feb 23, 2019 at 05:02:10PM +0800, Hongbo Yao wrote:
> I ran into this:
> 	UBSAN: Undefined behaviour in fs/read_write.c:251:11
> 	signed integer overflow:
> 	9223372036854775805 + 9223372036854775805 cannot be represented in
> 	type 'long long int'
> 
> Use unsigned types to do math, it doesn't throw a UBSAN warning
> when it does overflow.This patch doesn't change generated code.

You don't need to be this verbose to fix it.

> -			offset += file->f_pos;
> +			offset = (u64)file->f_pos + (u64)offset;

			offset += (u64)file->f_pos;




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux