Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3148238imu; Sun, 13 Jan 2019 20:00:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN5ffUeYnhSDNs0T6qNhdE3aRb3A6q83ui/q7pv7Vmvgx/jEwHt+Cdp+q6ysevzqezqPPiV5 X-Received: by 2002:a62:2b8b:: with SMTP id r133mr23731588pfr.246.1547438436477; Sun, 13 Jan 2019 20:00:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547438436; cv=none; d=google.com; s=arc-20160816; b=JnUdq9VKiUKU5ePd+w9JoCyduriuii+hnx+kNe/9W0/TlIPRIP+K30Oh7DspqrWIp7 +vsx9E/OxLHGr40cHyCXiS8Y9zM7bSkOuIfV7+IN5V8VdIkAd/ITa3poLAoG1F1DH8ar Q2dFJ49xNfPu9JW1DEQzszhYDAI/+s3H0kjEMQkMT3qb3+mK9ETWS5efegp/zdf2cYzu QSJ6n/RfpFpo0d75jYiF5O/QeqvBBJQEL3TN6ssPZRFdTf3NiFqYux/t9E07mQVz67iD NQ0xdGtCWHfGeLqSXccfqnxY+kiXhb1SpbOCcoi2eUEPhd45F1q49Mj5a4waavCMAWOv Xlxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:reply-to:cc :from:to:dkim-signature:date; bh=b+qt26x7rYf58bwLSFESIhyi4ktw5t21LfR8snoG+6g=; b=mvzSClivUBz05nFWsrw7JfqRhKC0PbceCreqlcJhg26zZjZJ5H1CHCZ7Gb0jAcUCr0 YzTxFswKNoodDpUMOFh75srid37ofFRpO9FtcYpfeFdE3WO939UdONGae7TuTFdolcHl f49M64MTsxOM8JG/XV1Nig8VwqPEn9MKViZ8nuC0fiMn0mMgVVbrGM6iCevAWxZ1x74a xNq0mmaOCPm1ZLOsOhV2Vmmot/No2H9KLTV2f0gUhlXj75L+ThgpF8ZG3yIpodFSHpbD NWC6yresmzmWoFPk7zVlpB4KfljoZtzynS0XdtZcyz6psThItpVwAShXAwMEZWSltbPO MkRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.ch header.s=default header.b=jP5b6vuV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.ch Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72si13966736pla.218.2019.01.13.20.00.20; Sun, 13 Jan 2019 20:00:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@protonmail.ch header.s=default header.b=jP5b6vuV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726737AbfAND7O (ORCPT + 99 others); Sun, 13 Jan 2019 22:59:14 -0500 Received: from mail-40135.protonmail.ch ([185.70.40.135]:38085 "EHLO mail-40135.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbfAND7N (ORCPT ); Sun, 13 Jan 2019 22:59:13 -0500 Date: Mon, 14 Jan 2019 03:59:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.ch; s=default; t=1547438350; bh=b+qt26x7rYf58bwLSFESIhyi4ktw5t21LfR8snoG+6g=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References: Feedback-ID:From; b=jP5b6vuVFneZ0g/ibDX+BxkZF4Zp65KMmyffXyKPf+bqHo7Gq8W2l2F16sdV+ni+k ZDHwsxlqvxcZ5n3zym6pig78axAFXM+kS95q6zmLUUbPx2GA3rgFEL6lUrstBJiNmw tLhgnypt47UiShMmge07Jcimk42LF4K5lIpM4a0M= To: "dgilbert@interlog.com" From: Esme Cc: Qian Cai , David Lechner , Michel Lespinasse , Andrew Morton , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , "joeypabalinas@gmail.com" , linux-mm , LKML Reply-To: Esme Subject: Re: [PATCH v2] rbtree: fix the red root Message-ID: In-Reply-To: References: <20190111181600.GJ6310@bombadil.infradead.org> <20190111205843.25761-1-cai@lca.pw> <864d6b85-3336-4040-7c95-7d9615873777@lechnology.com> <8v11ZOLyufY7NLAHDFApGwXOO_wGjVHtsbw1eiZ__YvI9EZCDe_4FNmlp0E-39lnzGQHhHAczQ6Q6lQPzVU2V6krtkblM8IFwIXPHZCuqGE=@protonmail.ch> Feedback-ID: pQGzDYT_k6dzic_kf3kwsxmTXzjnqMJxtC9J3KGyZBepPHdXRBM0BHuwPfpm1pFdJLAMwtJT5KKNaGlRVnFRQw==:Ext:ProtonMail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FREEMAIL_REPLYTO autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me= ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 On Sunday, January 13, 2019 10:52 PM, Douglas Gilbert wrote: > On 2019-01-13 10:07 p.m., Esme wrote: > > > =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Origina= l Message =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80= =90 > > On Sunday, January 13, 2019 9:33 PM, Qian Cai cai@lca.pw wrote: > > > > > On 1/13/19 9:20 PM, David Lechner wrote: > > > > > > > On 1/11/19 8:58 PM, Michel Lespinasse wrote: > > > > > > > > > On Fri, Jan 11, 2019 at 3:47 PM David Lechner david@lechnology.co= m wrote: > > > > > > > > > > > On 1/11/19 2:58 PM, Qian Cai wrote: > > > > > > > > > > > > > A GPF was reported, > > > > > > > kasan: CONFIG_KASAN_INLINE enabled > > > > > > > kasan: GPF could be caused by NULL-ptr deref or user memory a= ccess > > > > > > > general protection fault: 0000 [#1] SMP KASAN > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 kasan_= die_handler.cold.22+0x11/0x31 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 notifi= er_call_chain+0x17b/0x390 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 atomic= _notifier_call_chain+0xa7/0x1b0 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 notify= _die+0x1be/0x2e0 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 do_gen= eral_protection+0x13e/0x330 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 genera= l_protection+0x1e/0x30 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rb_ins= ert_color+0x189/0x1480 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 create= _object+0x785/0xca0 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 kmemle= ak_alloc+0x2f/0x50 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 kmem_c= ache_alloc+0x1b9/0x3c0 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 getnam= e_flags+0xdb/0x5d0 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 getnam= e+0x1e/0x20 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 do_sys= _open+0x3a1/0x7d0 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __x64_= sys_open+0x7e/0xc0 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 do_sys= call_64+0x1b3/0x820 > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 entry_= SYSCALL_64_after_hwframe+0x49/0xbe > > > > > > > It turned out, > > > > > > > gparent =3D rb_red_parent(parent); > > > > > > > tmp =3D gparent->rb_right; <-- GPF was triggered here. > > > > > > > Apparently, "gparent" is NULL which indicates "parent" is rbt= ree's root > > > > > > > which is red. Otherwise, it will be treated properly a few li= nes above. > > > > > > > /* > > > > > > > =C2=A0=C2=A0 * If there is a black parent, we are done. > > > > > > > =C2=A0=C2=A0 * Otherwise, take some corrective action as, > > > > > > > =C2=A0=C2=A0 * per 4), we don't want a red root or two > > > > > > > =C2=A0=C2=A0 * consecutive red nodes. > > > > > > > =C2=A0=C2=A0 */ > > > > > > > if(rb_is_black(parent)) > > > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > > > > > Hence, it violates the rule #1 (the root can't be red) and ne= ed a fix > > > > > > > up, and also add a regression test for it. This looks like wa= s > > > > > > > introduced by 6d58452dc06 where it no longer always paint the= root as > > > > > > > black. > > > > > > > Fixes: 6d58452dc06 (rbtree: adjust root color in rb_insert_co= lor() only > > > > > > > when necessary) > > > > > > > Reported-by: Esme esploit@protonmail.ch > > > > > > > Tested-by: Joey Pabalinas joeypabalinas@gmail.com > > > > > > > Signed-off-by: Qian Cai cai@lca.pw > > > > > > > > > > > > Tested-by: David Lechner david@lechnology.com > > > > > > FWIW, this fixed the following crash for me: > > > > > > Unable to handle kernel NULL pointer dereference at virtual add= ress 00000004 > > > > > > > > > > Just to clarify, do you have a way to reproduce this crash withou= t the fix ? > > > > > > > > I am starting to suspect that my crash was caused by some new code > > > > in the drm-misc-next tree that might be causing a memory corruption= . > > > > It threw me off that the stack trace didn't contain anything relate= d > > > > to drm. > > > > See: https://patchwork.freedesktop.org/patch/276719/ > > > > > > It may be useful for those who could reproduce this issue to turn on = those > > > memory corruption debug options to narrow down a bit. > > > CONFIG_DEBUG_PAGEALLOC=3Dy > > > CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT=3Dy > > > CONFIG_KASAN=3Dy > > > CONFIG_KASAN_GENERIC=3Dy > > > CONFIG_SLUB_DEBUG_ON=3Dy > > > > I have been on SLAB, I configured SLAB DEBUG with a fresh pull from git= hub. Linux syzkaller 5.0.0-rc2 #9 SMP Sun Jan 13 21:57:40 EST 2019 x86_64 > > ... > > In an effort to get a different stack into the kernel, I felt that noth= ing works better than fork bomb? :) > > Let me know if that helps. > > root@syzkaller:~# gcc -o test3 test3.c > > root@syzkaller:~# while : ; do ./test3 & done > > And is test3 the same multi-threaded program that enters the kernel via > /dev/sg0 and then calls SCSI_IOCTL_SEND_COMMAND which goes to the SCSI > mid-level and thence to the block layer? > > And please remind me, does it also fail on lk 4.20.2 ? > > Doug Gilbert Yes, the same C repro from the earlier thread. It was a 4.20.0 kernel wher= e it was first detected. I can move to 4.20.2 and see if that changes anyt= hing. Esme