Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3144881imu; Sun, 13 Jan 2019 19:54:29 -0800 (PST) X-Google-Smtp-Source: ALg8bN5Y+/H4nQ1V0DWs4PaQawkMwgpO/SZkJ9AGpalKCzJ2UJ19ssUohC1oLbJou5qT5O2HHC4H X-Received: by 2002:a17:902:b18b:: with SMTP id s11mr23650487plr.56.1547438069283; Sun, 13 Jan 2019 19:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547438069; cv=none; d=google.com; s=arc-20160816; b=WSHHD5UlIN3iPW/uJK8BzbvCW9xPPkKhDhC32MRMz/2d02NbA7ExZolKc6mBk7pO++ mlgosQCXzdDqiy1GppgwPjA69zNSVKW3PDVCy5ZCXeDSE+EcGtaKy9t2oJg7EbI9Jg3d KeMo/kuqUu5yXp6EuCTiPwE42/ONpGAZRT0vhSIImczjiRV6nuLv5r1Yct40OxCDcSck UTIb67WnEH8zgMc+STvkIE44mxgizepdvP1bh8Zw/A8XdKuD52TNbYO3iSi1NOI+w7Ry U83BW0Nr6JxjmcZjrAGQ8aXBSE2jdG+CU4i1vj+s78yKGFITawcyelwxl8WhYqdaeALp WNGQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:reply-to; bh=GMutIi43YTpM5MMUxpbDED2mIHolN0hUR92tD6+e/8I=; b=1Gge5VuzGdKUeCXR47a9lhRjemrVzmJY09J7Xm5git+Pa6PYpvqsbybgDMB+A9pNBf FRRAD6u16eE6euQYLMULIjlFglgklWoq3C6ffzso5TweunUkGySpHmIuU05Qm0JgidGe 5MIQYoiiep1Fjsuy89a1OClJ1yc+PKjqiPUt5eVcliOvP4iXLdYQRLAAFdjyfjNk4vBG B6o12iJkrTEV1Xn0Ak7MvZGbVzTGSREoToml3GfvtIRMNWckHEraM2aVCEaIAbie/fja EQuQvIcMnjpG+L4o88QKP6kGykuenkhDtaPKcwC5lgYx8P0gikTGRb2FQaj8l/SYkOcH P5Ng== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j66si37350428pfb.182.2019.01.13.19.54.12; Sun, 13 Jan 2019 19:54:29 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726731AbfANDxI (ORCPT + 99 others); Sun, 13 Jan 2019 22:53:08 -0500 Received: from smtp.infotech.no ([82.134.31.41]:54660 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbfANDxH (ORCPT ); Sun, 13 Jan 2019 22:53:07 -0500 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id DF8C620424C; Mon, 14 Jan 2019 04:53:04 +0100 (CET) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hlcOg8sG+Gmu; Mon, 14 Jan 2019 04:52:57 +0100 (CET) Received: from [192.168.48.23] (host-184-164-16-103.dyn.295.ca [184.164.16.103]) by smtp.infotech.no (Postfix) with ESMTPA id DB393204187; Mon, 14 Jan 2019 04:52:55 +0100 (CET) Reply-To: dgilbert@interlog.com Subject: Re: [PATCH v2] rbtree: fix the red root To: Esme , Qian Cai Cc: David Lechner , Michel Lespinasse , Andrew Morton , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , "joeypabalinas@gmail.com" , linux-mm , LKML 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> From: Douglas Gilbert Message-ID: Date: Sun, 13 Jan 2019 22:52:16 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <8v11ZOLyufY7NLAHDFApGwXOO_wGjVHtsbw1eiZ__YvI9EZCDe_4FNmlp0E-39lnzGQHhHAczQ6Q6lQPzVU2V6krtkblM8IFwIXPHZCuqGE=@protonmail.ch> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-CA Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-01-13 10:07 p.m., Esme wrote: > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ > On Sunday, January 13, 2019 9:33 PM, Qian Cai 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.com 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 access >>>>>> general protection fault: 0000 [#1] SMP KASAN >>>>>>           kasan_die_handler.cold.22+0x11/0x31 >>>>>>           notifier_call_chain+0x17b/0x390 >>>>>>           atomic_notifier_call_chain+0xa7/0x1b0 >>>>>>           notify_die+0x1be/0x2e0 >>>>>>           do_general_protection+0x13e/0x330 >>>>>>           general_protection+0x1e/0x30 >>>>>>           rb_insert_color+0x189/0x1480 >>>>>>           create_object+0x785/0xca0 >>>>>>           kmemleak_alloc+0x2f/0x50 >>>>>>           kmem_cache_alloc+0x1b9/0x3c0 >>>>>>           getname_flags+0xdb/0x5d0 >>>>>>           getname+0x1e/0x20 >>>>>>           do_sys_open+0x3a1/0x7d0 >>>>>>           __x64_sys_open+0x7e/0xc0 >>>>>>           do_syscall_64+0x1b3/0x820 >>>>>>           entry_SYSCALL_64_after_hwframe+0x49/0xbe >>>>>> It turned out, >>>>>> gparent = rb_red_parent(parent); >>>>>> tmp = gparent->rb_right; <-- GPF was triggered here. >>>>>> Apparently, "gparent" is NULL which indicates "parent" is rbtree's root >>>>>> which is red. Otherwise, it will be treated properly a few lines above. >>>>>> /* >>>>>>    * If there is a black parent, we are done. >>>>>>    * Otherwise, take some corrective action as, >>>>>>    * per 4), we don't want a red root or two >>>>>>    * consecutive red nodes. >>>>>>    */ >>>>>> if(rb_is_black(parent)) >>>>>>        break; >>>>>> Hence, it violates the rule #1 (the root can't be red) and need a fix >>>>>> up, and also add a regression test for it. This looks like was >>>>>> introduced by 6d58452dc06 where it no longer always paint the root as >>>>>> black. >>>>>> >>>>>> Fixes: 6d58452dc06 (rbtree: adjust root color in rb_insert_color() 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 address 00000004 >>>> >>>> Just to clarify, do you have a way to reproduce this crash without 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 related >>> 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=y >> CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT=y >> CONFIG_KASAN=y >> CONFIG_KASAN_GENERIC=y >> CONFIG_SLUB_DEBUG_ON=y > > I have been on SLAB, I configured SLAB DEBUG with a fresh pull from github. 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 nothing 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