Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2324437iof; Wed, 8 Jun 2022 02:29:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwn0nvXGvK9Ae3jsD67NVDSp9rkf4Z5R25cZNFmZDPwCAjDgTsS8/8aHLQ/oV+Ba0cJWXoe X-Received: by 2002:a05:6a00:882:b0:510:a043:d4bc with SMTP id q2-20020a056a00088200b00510a043d4bcmr34042883pfj.64.1654680577747; Wed, 08 Jun 2022 02:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654680577; cv=none; d=google.com; s=arc-20160816; b=p0u5VFvoqGbNfTzJOa+WqOWLj5Zy8nSIsRJOpX/95vP63kTlODzRCdpTqzwRsOIwud jz/hdnRPaPucgULKqtSghrn30Fkb5emXbVaq/jpHDsW2IUChh2butR9Rm4Fy9AcnuDar XYOfJ/BUVNMVAbU/jIc2XBGBYP4thZYJyyL6CazO2amXP7tH58sttW3pJuQL5OGgTma2 Qf45Wlf7fjcrLi4rJ4ThdxbLlrP6BvlwDH7laRAktEqPWu6dCjREmpHy+oN8z33NlRbo bPjZ4/YNb6+DjS8Banb5tVQrZMJVWufyjthzeE3p2h7NOBXvMeanWTWrgTZKyyBVIcth xccw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1JjOcRGJSB2fSgbLiiW6ZWGHzYh7EMGNOWme17+fMEk=; b=LhVrsrON6GczWZdk16PhJpa3EnQMwRRl6AjdtlE9U+GREMrTde3cUmNq2p8ABWA+B1 l3MrmS8LRIcdDYNhdu710H+BNcgBVWCqfLgLjIXjjNvNxR2LaHpT9lTFuRecTOt4z+ur kwstCVWwAiToWvJqtMCiUAasYo4UaGal7JNiihFVu8/iUZiKKHEVBfQfFk26kslwGBq/ 2zKzfJm2sFv1a6rYriTR+GrTqXDmWWgmKAUvAKPezS3qUwM4eCQmXqLZTtUj7KzgeALS L5u0eM2FBCITwYnwpHon24qcbzmoQTZIB7WCQgEsFDwC8O8WjLeSmC1a8hIa/ZggeA3h ogTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hkSTJRJF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h18-20020a170902f55200b00158f88c5316si29643205plf.373.2022.06.08.02.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 02:29:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hkSTJRJF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 92111151FFE; Wed, 8 Jun 2022 02:02:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232901AbiFHJBk (ORCPT + 99 others); Wed, 8 Jun 2022 05:01:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230290AbiFHJBM (ORCPT ); Wed, 8 Jun 2022 05:01:12 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A1CD40526C for ; Wed, 8 Jun 2022 01:20:19 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id m25so18564916lji.11 for ; Wed, 08 Jun 2022 01:20:19 -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=zpVq7CT0AvDXyI552iV4lYhKtDDHRThzY+iwi7WeBeGeaER5UZDadieq4tERC8lF3c 2DyM3GTvOp5o3eN297UKt2nk55bdTRBadwEGndAQJ5oAVYmn8WTJol7A5P5svl9tpMfL pjUprvXC0Ei2h9h9/0sDpYFv/DG+9HI7UP95kON1w6xEL/klIgH2eRZGjKUIP5pT5ipn ee4YQat2AYEARU/kUllTF1ReeGokGKmn6uRaAlDO2wBVVBzYDVZgyboKeL38erbbi03W 2htoCxtSLLgK0IQ6RngZjSycYD0zD85xmYiGOgNbuz1frv2NVOTMrWqZeLfyZ+AMtFps Su9w== X-Gm-Message-State: AOAM5326ge1VKtDz5bs0l5aK/DvWbjCmmYnszi9q6pThKyZEMDVlfDma mtYYVHp5jP5xmMEJdTkUds5k0II13uDNPfdPqorGXQ== 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-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.