Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8211163ybi; Thu, 6 Jun 2019 08:26:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmUBrtY7I08OiIUUaB09lH0zhuj/868ZNWm2YOlxDBLwOj12pQtNZ4lC7awnIgxB9wbltY X-Received: by 2002:a17:902:2aab:: with SMTP id j40mr11667704plb.76.1559834771961; Thu, 06 Jun 2019 08:26:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559834771; cv=none; d=google.com; s=arc-20160816; b=rL1p52csQ8FGKUouCoGcXJIPQiDo0EpHK97e+b4ZWrikDzaPKq1bkM/NPiSHF42GIN IterHdwPwm7Cr4dj/zlEmneXcrSrvU8PcWvj57+FIu4vXRxx63iJ+DIYFjrhflrRbNFM owq9X+XA7KBfIjN5YEN0gNhvNMk496HjLOoUG85qJbEkGfi3/fhrmLrYet4hUzqslkWB cQDb1o0Kvxr0nSVxcYIfaPhDTdklOXR1bu4DwyyHseHuxVmU1b4vGeotil4RODNAH/83 y5y6L35ODUj84KZf7MUUq72wNEfEugBnjWt1WXcEl21THhZsfpJRMpdUsmHT8bj5ibDl XA4A== 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; bh=5+dOmXeURBRc7VvGwZp4Iip2YXKOWTHfhZLgEEKCtU0=; b=gv6bbY9dPVWdhNoq1b9O4oU0x6XdsAnfoRcboZdrl0k7O+AQon6zlqNXPyAHRb6oQp 4q5n13fkMdRlTuKApBhvjYJ89ex8e1BRa2RXDolGbfoySkY3kn6mz99WgeJIZD9IvB8t SFXgkmvGo0tGOcj0QuB70Jte86FH3vexsHw2ElbuymVbxMGPddrVPlwJPDIAd7HC2U2o HdDs9u938ANkCBGKFsMmD1Bf5m/WFUnPdMUZNB8a09szfZD1ohJxzXONQiY0rx7XZlOS 92X1X7adj0Up9IfTaTqM/b/4AVtTjzvUmUUITFLQ657fwgcArDY8TLjjqoAu6n4uksFb 3sqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10si2288921pfj.93.2019.06.06.08.25.54; Thu, 06 Jun 2019 08:26:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-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-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729086AbfFFPZa (ORCPT + 99 others); Thu, 6 Jun 2019 11:25:30 -0400 Received: from relay.sw.ru ([185.231.240.75]:37420 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729015AbfFFPZ3 (ORCPT ); Thu, 6 Jun 2019 11:25:29 -0400 Received: from [172.16.25.169] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hYuGS-0000sH-Cr; Thu, 06 Jun 2019 18:25:16 +0300 Subject: Re: KASAN: use-after-free Read in unregister_shrinker To: Dmitry Vyukov Cc: "J. Bruce Fields" , syzbot , Andrew Morton , bfields@redhat.com, Chris Down , Daniel Jordan , guro@fb.com, Johannes Weiner , Jeff Layton , laoar.shao@gmail.com, LKML , Linux-MM , linux-nfs@vger.kernel.org, Mel Gorman , Michal Hocko , Stephen Rothwell , syzkaller-bugs , yang.shi@linux.alibaba.com References: <0000000000005a4b99058a97f42e@google.com> <20190606131334.GA24822@fieldses.org> <275f77ad-1962-6a60-e60b-6b8845f12c34@virtuozzo.com> <00ec828a-0dcb-ca70-e938-ca26a6a8b675@virtuozzo.com> From: Kirill Tkhai Message-ID: Date: Thu, 6 Jun 2019 18:25:16 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On 06.06.2019 18:18, Dmitry Vyukov wrote: > On Thu, Jun 6, 2019 at 4:54 PM Kirill Tkhai wrote: >> >> On 06.06.2019 17:40, Dmitry Vyukov wrote: >>> On Thu, Jun 6, 2019 at 3:43 PM Kirill Tkhai wrote: >>>> >>>> On 06.06.2019 16:13, J. Bruce Fields wrote: >>>>> On Thu, Jun 06, 2019 at 10:47:43AM +0300, Kirill Tkhai wrote: >>>>>> This may be connected with that shrinker unregistering is forgotten on error path. >>>>> >>>>> I was wondering about that too. Seems like it would be hard to hit >>>>> reproduceably though: one of the later allocations would have to fail, >>>>> then later you'd have to create another namespace and this time have a >>>>> later module's init fail. >>>> >>>> Yes, it's had to bump into this in real life. >>>> >>>> AFAIU, syzbot triggers such the problem by using fault-injections >>>> on allocation places should_failslab()->should_fail(). It's possible >>>> to configure a specific slab, so the allocations will fail with >>>> requested probability. >>> >>> No fault injection was involved in triggering of this bug. >>> Fault injection is clearly visible in console log as "INJECTING >>> FAILURE at this stack track" splats and also for bugs with repros it >>> would be noted in the syzkaller repro as "fault_call": N. So somehow >>> this bug was triggered as is. >>> >>> But overall syzkaller can do better then the old probabilistic >>> injection. The probabilistic injection tend to both under-test what we >>> want to test and also crash some system services. syzkaller uses the >>> new "systematic fault injection" that allows to test specifically each >>> failure site separately in each syscall separately. >> >> Oho! Interesting. > > If you are interested. You write N into /proc/thread-self/fail-nth > (say, 5) then it will cause failure of the N-th (5-th) failure site in > the next syscall in this task only. And by reading it back after the > syscall you can figure out if the failure was indeed injected or not > (or the syscall had less than 5 failure sites). > Then, for each syscall in a test (or only for one syscall of > interest), we start by writing "1" into /proc/thread-self/fail-nth; if > the failure was injected, write "2" and restart the test; if the > failure was injected, write "3" and restart the test; and so on, until > the failure wasn't injected (tested all failure sites). > This guarantees systematic testing of each error path with minimal > number of runs. This has obvious extensions to "each pair of failure > sites" (to test failures on error paths), but it's not supported atm. And what you do in case of a tested syscall has pre-requisites? Say, you test close(), which requires open() and some IO before. Are such the dependencies statically declared in some configuration file? Or you test any repeatable sequence of syscalls? Kirill