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: <1508831057-64195-1-git-send-email-puck.chen@hisilicon.com>
Date:   Tue, 24 Oct 2017 15:44:17 +0800
From:   Chen Feng <puck.chen@...ilicon.com>
To:     <puck.chen@...ilicon.com>, <zhaoyukun@...wei.com>, <tytso@....edu>,
        <arnd@...db.de>, <linux-kernel@...r.kernel.org>
CC:     <gregkh@...uxfoundation.org>, <suzhuangluan@...ilicon.com>,
        <dan.zhao@...ilicon.com>
Subject: [PATCH RFC] random: fix syzkaller fuzzer test int overflow

[pid:11940,cpu6,syz-executor][flp_ioctl]cmd[0x1]
Restart is not permit
=================================================================
UBSAN: Undefined behaviour in
kernel/linux-4.4/drivers/char/random.c:676:19
signed integer overflow:
2147483645 + 268435455 cannot be represented in type 'int'
CPU: 4 PID: 11941 Comm: syz-executor Not tainted 4.4.76+ #2
TGID: 11928 Comm: syz-executor
Hardware name: hi3660 (DT)
Call trace:
[<ffffffa661090378>] dump_backtrace+0x0/0x314
[<ffffffa66109077c>] show_stack+0x1c/0x24
[<ffffffa66180cc54>] dump_stack+0xdc/0x130
[<ffffffa6618833d0>] ubsan_epilogue+0x18/0x6c
[<ffffffa661883c5c>] handle_overflow+0x180/0x1d4
[<ffffffa661883cdc>] __ubsan_handle_add_overflow+0x2c/0x34
[<ffffffa661ab75a0>] credit_entropy_bits+0x358/0x9a8
[<ffffffa661ab85bc>] random_ioctl+0x338/0x384
[<ffffffa661399c74>] do_vfs_ioctl+0x60c/0xa4c
[<ffffffa66139a150>] SyS_ioctl+0x9c/0xc0
[<ffffffa6610838b0>] el0_svc_naked+0x24/0x28
=================================================================

Signed-off-by: Chen Feng <puck.chen@...ilicon.com>
Signed-off-by: Yukun Zhao <zhaoyukun@...wei.com>
---
 drivers/char/random.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 1ef2640..6f2bd6a 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -699,6 +699,11 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits)
 	if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
 		goto retry;
 
+	if (INT_MAX - nbits < r->entropy_total) {
+		WARN_ON(1);
+		return;
+	}
+
 	r->entropy_total += nbits;
 	if (!r->initialized && r->entropy_total > 128) {
 		r->initialized = 1;
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ