lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190223090210.116847-1-yaohongbo@huawei.com>
Date:   Sat, 23 Feb 2019 17:02:10 +0800
From:   Hongbo Yao <yaohongbo@...wei.com>
To:     <viro@...iv.linux.org.uk>, <linux-fsdevel@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <linuxarm@...wei.com>
Subject: [PATCH] fs: Avoid signed overflow UBSAN warning

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.

Signed-off-by: Hongbo Yao <yaohongbo@...wei.com>
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 8f08d4a2aa9a..0509e81afc8e 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -248,7 +248,7 @@ loff_t default_llseek(struct file *file, loff_t offset, int whence)
 				retval = file->f_pos;
 				goto out;
 			}
-			offset += file->f_pos;
+			offset = (u64)file->f_pos + (u64)offset;
 			break;
 		case SEEK_DATA:
 			/*
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ