From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751591AbdJYHJ6 (ORCPT ); Wed, 25 Oct 2017 03:09:58 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9488 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751407AbdJYHJz (ORCPT ); Wed, 25 Oct 2017 03:09:55 -0400 Subject: Re: [PATCH RFC] random: fix syzkaller fuzzer test int overflow To: Greg KH References: <1508831057-64195-1-git-send-email-puck.chen@hisilicon.com> <20171024090927.GA20625@kroah.com> <20171024102528.7oywdwjriesoh3mk@thunk.org> <59F02FA0.7090605@hisilicon.com> <20171025065646.GA13386@kroah.com> CC: "Theodore Ts'o" , , , , , From: Chen Feng Message-ID: <59F03887.7020700@hisilicon.com> Date: Wed, 25 Oct 2017 15:08:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20171025065646.GA13386@kroah.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.142.193.64] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A010204.59F038B0.0004,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 268a9a7b23ca769d66995e2317b5ca82 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/10/25 14:56, Greg KH wrote: > On Wed, Oct 25, 2017 at 02:30:56PM +0800, Chen Feng wrote: >> Hi Ted, >> >> On 2017/10/24 18:25, Theodore Ts'o wrote: >>> On Tue, Oct 24, 2017 at 11:09:27AM +0200, Greg KH wrote: >>>> On Tue, Oct 24, 2017 at 03:44:17PM +0800, Chen Feng wrote: >>>>> [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 >>>> >>>> Does this also happen on 4.14-rc6? >>> >>> No. It was fixed in 4.8, by commit 86a574de4590: "random: strengthen >>> input validation for RNDADDTOENTCNT". >> >> >> I see my kernel has already merged this patch. So I don't think this patch >> can resolve the issue above. > > Do you have a reproducer for this issue that we can use to test? > It's hard to reproduce, we found this on stress test with syzkaller test. r3 = syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) r3 = syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) syz_open_dev$random(&(0x7f0000005000-0xc)="2f6465762f72616e646f6d00", 0x0, 0x10100) r3 = syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) r3 = syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) r3 = syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) r3 = syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) r3 = syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) r3 = syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) r3 = syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) r3 = syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) r3 = syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) r3 = syz_open_dev$urandom(&(0x7f000000a000)="2f6465762f7572616e646f6d00", 0x0, 0x0) UBSAN: Undefined behaviour in kernel/linux-4.4/drivers/char/random.c:676:19 [] random_ioctl+0x338/0x384 git log --oneline drivers/char/random.c 3991576 random: properly align get_random_int_hash 5f87c47 Merge branch 'linux-linaro-lsk-v4.4' into linux-linaro-lsk-v4.4-android f48dd2d random: add interrupt callback to VMBus IRQ handler 529025b random: print a warning for the first ten uninitialized random users f41fc0b random: initialize the non-blocking pool via add_hwgenerator_randomness() fdd8543 Merge branch 'linux-linaro-lsk-v4.4' into linux-linaro-lsk-v4.4-android 93f84c8 random: strengthen input validation for RNDADDTOENTCNT 06bfe14 FROMLIST: drivers: char: random: add get_random_long() c271950 random: Remove kernel blocking API 205a525 random: Add callback API for random pool readiness 16b369a random: Blocking API for accessing nonblocking_pool 1d9de44 random: Wake up all getrandom(2) callers when pool is ready 19acc77 random: Fix fast_mix() function > thanks, > > greg k-h > > . >