From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2E6FC43334 for ; Wed, 8 Jun 2022 08:20:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 501188D000C; Wed, 8 Jun 2022 04:20:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B0FC8D0009; Wed, 8 Jun 2022 04:20:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39FF88D000C; Wed, 8 Jun 2022 04:20:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2ABF08D0009 for ; Wed, 8 Jun 2022 04:20:19 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 04F5980D9A for ; Wed, 8 Jun 2022 08:20:18 +0000 (UTC) X-FDA: 79554371358.11.1AF1FB6 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by imf14.hostedemail.com (Postfix) with ESMTP id A8D5210004F for ; Wed, 8 Jun 2022 08:20:18 +0000 (UTC) Received: by mail-lj1-f178.google.com with SMTP id y29so21878435ljd.7 for ; Wed, 08 Jun 2022 01:20:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1JjOcRGJSB2fSgbLiiW6ZWGHzYh7EMGNOWme17+fMEk=; b=hkSTJRJFPhK39Y853A/W3/yTLjh4qALYD0cYwErihhB09XSKkdRcupA/W7zjIIItiI JFG+HqHAqCLpcFkinLvs7pGNHVs8mdlZId8G4E38VWqFR5ZiieJIpVrHrBH+HQ8AqkjB fdpU/cG9omO9T+sQJR/3PbiLseabtmITaUpZhd0XSmQ0dswt8fH6vTmATL62bRizvxpm WlEjD8YGiE8bCRWWmGpbwbmgJ9N+QdZgklReUF2fcCzUrqWtT+3bdobnpEZ4NHUtAs4B viv68KKKktnOGPtsgPcY8iA1mzousNrvyxVG+zyc0GWe087eSvr+ReRSk2R56R/uQCB9 qVlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1JjOcRGJSB2fSgbLiiW6ZWGHzYh7EMGNOWme17+fMEk=; b=Y5M/JzpDlmjbDiTJUGtxGKQNHXW6BuFF4c5ygClA/kvgH7YJSEW0rO+nnoM2TOZY1y TZS9FzIYBK1h23dMNa0EXQUi1wJ/seJI8q5iFa42VtBx4IwJV7xHYmpsbDbMXAyjQpaN 8l8WUEFmDLQT7V/wNfi2YoKCABBSymQ4ATWzp42xtmfGCRsqt3BsjPrelS9htOsyj3jl Krz1i294P1YEtUuf/h2pTXM54/vdN+1CAjAJgI/9nVqfMBNTT+UYxlHRgJ7xuZooP2SH j1hp0qZAZW9VvFQnZ7joDwWKoa2f7Enp3co7dey9PRh/aIjNcaPGwIP+4j8lWjuamiJ7 kehQ== X-Gm-Message-State: AOAM530+nkWT8Sx7CR8udzp97/VScEe70uSel4duqTmiG/xDdgdkgE3+ J7/nz6xqXLBgXT5xOJotM1xYhZICxzpz/QI1Nn7v/A== X-Google-Smtp-Source: ABdhPJz2/z1uPZQh1zE8SQsjqlcxNLnLSwaKoG+0A//xjS09k6hF+JzANV6JR9AY+rVkDmcx9EX96Aq0URjVtZPSG4A= X-Received: by 2002:a2e:8882:0:b0:255:6858:d4c0 with SMTP id k2-20020a2e8882000000b002556858d4c0mr21336730lji.268.1654676416727; Wed, 08 Jun 2022 01:20:16 -0700 (PDT) MIME-Version: 1.0 References: <000000000000bb7f1c05da29b601@google.com> <00000000000010b7d305e08837c8@google.com> <20220606123839.GW2146@kadam> In-Reply-To: From: Dmitry Vyukov Date: Wed, 8 Jun 2022 10:20:04 +0200 Message-ID: Subject: Re: [syzbot] general protection fault in __device_attach To: Matthew Wilcox Cc: Dan Carpenter , Greg KH , Alan Stern , Andy Shevchenko , syzbot , hdanton@sina.com, lenb@kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, rafael.j.wysocki@intel.com, rafael@kernel.org, rjw@rjwysocki.net, syzkaller-bugs@googlegroups.com, linux-usb@vger.kernel.org, Linux-MM Content-Type: text/plain; charset="UTF-8" X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=hkSTJRJF; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of dvyukov@google.com designates 209.85.208.178 as permitted sender) smtp.mailfrom=dvyukov@google.com X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: A8D5210004F X-Stat-Signature: woyq1yxasuph7tt9kifh7wa8h8rukhfj X-HE-Tag: 1654676418-888035 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 8 Jun 2022 at 05:25, Matthew Wilcox wrote: > > On Tue, Jun 07, 2022 at 09:15:09AM +0200, Dmitry Vyukov wrote: > > On Mon, 6 Jun 2022 at 14:39, Dan Carpenter wrote: > > > > > > On Sat, Jun 04, 2022 at 10:32:46AM +0200, 'Dmitry Vyukov' via syzkaller-bugs wrote: > > > > On Fri, 3 Jun 2022 at 18:12, Greg KH wrote: > > > > > > > > > > But again, is this a "real and able to be triggered from userspace" > > > > > problem, or just fault-injection-induced? > > > > > > > > Then this is something to fix in the fault injection subsystem. > > > > Testing systems shouldn't be reporting false positives. > > > > What allocations cannot fail in real life? Is it <=page_size? > > > > > > > > > > Apparently in 2014, anything less than *EIGHT?!!* pages succeeded! > > > > > > https://lwn.net/Articles/627419/ > > > > > > I have been on the look out since that article and never seen anyone > > > mention it changing. I think we should ignore that and say that > > > anything over PAGE_SIZE can fail. Possibly we could go smaller than > > > PAGE_SIZE... > > > > +linux-mm for GFP expertise re what allocations cannot possibly fail > > and should be excluded from fault injection. > > > > Interesting, thanks for the link. > > > > PAGE_SIZE looks like a good start. Once we have the predicate in > > place, we can refine it later when/if we have more inputs. > > > > But I wonder about GFP flags. They definitely have some impact on allocations. > > If GFP_ACCOUNT is set, all allocations can fail, right? > > If GFP_DMA/DMA32 is set, allocations can fail, right? What about other zones? > > If GFP_NORETRY is set, allocations can fail? > > What about GFP_NOMEMALLOC and GFP_ATOMIC? > > What about GFP_IO/GFP_FS/GFP_DIRECT_RECLAIM/GFP_KSWAPD_RECLAIM? At > > least some of these need to be set for allocations to not fail? Which > > ones? > > Any other flags are required to be set/unset for allocations to not fail? > > I'm not the expert on page allocation, but ... > > I don't think GFP_ACCOUNT makes allocations fail. It might make reclaim > happen from within that cgroup, and it might cause an OOM kill for > something in that cgroup. But I don't think it makes a (low order) > allocation more likely to fail. Interesting. I was thinking of some malicious specifically crafted configurations with very low limit and particular pattern of allocations. Also what if there is just 1 process (current)? Is it possible to kill and reclaim the current process when a thread is stuck in the middle of the kernel on a kmalloc? Also I see e.g.: Tasks with the OOM protection (oom_score_adj set to -1000) are treated as an exception and are never killed. I am not an expert on this either, but I think it may be hard to fight with a specifically crafted attack. > There's usually less memory avilable in DMA/DMA32 zones, but we have > so few allocations from those zones, I question the utility of focusing > testing on those allocations. > > GFP_ATOMIC allows access to emergency pools, so I would say _less_ likely > to fail. KSWAPD_RECLAIM has no effect on whether _this_ allocation > succeeds or fails; it kicks kswapd to do reclaim, rather than doing > reclaim directly. DIRECT_RECLAIM definitely makes allocations more likely > to succeed. GFP_FS allows (direct) reclaim to happen from filesystems. > GFP_IO allows IO to start (ie writeback can start) in order to clean > dirty memory. > > Anyway, I hope somebody who knows the page allocator better than I do > can say smarter things than this. Even better if they can put it into > Documentation/ somewhere ;-) Even better to put this into code as a predicate function that fault injection will use. It will also serve as precise up-to-date documentation. > https://www.kernel.org/doc/html/latest/core-api/memory-allocation.html > exists but isn't quite enough to answer this question.