Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1176361rwb; Fri, 18 Nov 2022 14:04:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf47bdLwwBSx8B0jI1/w46OLGuoTTwZRA149qem1GUTlTTVjiHwbzThKSbpFjQJJfA2LESmi X-Received: by 2002:a05:6a00:1993:b0:56c:3fbb:7eb1 with SMTP id d19-20020a056a00199300b0056c3fbb7eb1mr9906799pfl.7.1668809078595; Fri, 18 Nov 2022 14:04:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668809078; cv=none; d=google.com; s=arc-20160816; b=R0/YW1yfv/uVQ8qHlmPCa9A7e5r4HBkXLj1bgi3GWE/WkPAJRzVLal213GvL7rKgst f6GVmQ5abG4IdpMVgljQB2e1k9A7wKqxOVYMyn3KoMxYPjzz4i23pdOgLZn5MXMSCqnV ZB1gA8Dc7TsiKeomEm4eyXz6HewVOduhlCxeTftgVGxrPFAONK6ff2eU3+z65Dwo2Luv sgDd3fLtG0fPsCvy1XG234F3jddwJspSTI15+rzC8dJyAeeoA9FXjnn8+jfdtOE/sThL b7F3TIIVQA0n5ET3xnvV9l0lonBQjI2VE3RsGg8p8bEQApLW7B75kB6izwUGQfB42btn IgZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ZadjNkxfHbMe9MSbtAQ/30dJInlLEIFNN3fnutGX4wU=; b=lNcUOWOGk+8RtXb7luuFw/aPr6rUyWQnNrGm0XbH44643ob6pNO462t+ui9ZgEm93W r7UzrpUuPk774b/JMDuhsiZKVY3bFS/KHpef6A2V5qtytHjvkJdNxhfYOtDyeHBmnsyO tVre4snXE0qN3nvoZo4Va9QBOizQ7l0yZ6+3dm7AeuNfapDnj7mfa85n5T5fAtSDiR3T MlEHN0/OhCKBlPkYIij/6svnPzYKEUFdP0zUXDWwQpMNfS3q3rF7e1Pb0fMQwnYHri4x FxeskVYgWxl4sK8gZD5s5QkpPGd6+k7oaqfrAwmlQ/LWDDgAGpxPJZZi7HMYqUdIMdBL hs+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=fG5ssDEh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t23-20020a170902b21700b00179f9521d08si4331433plr.149.2022.11.18.14.04.22; Fri, 18 Nov 2022 14:04:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=fG5ssDEh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230299AbiKRVmn (ORCPT + 90 others); Fri, 18 Nov 2022 16:42:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbiKRVml (ORCPT ); Fri, 18 Nov 2022 16:42:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E300A5715; Fri, 18 Nov 2022 13:42:40 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E777DB8255A; Fri, 18 Nov 2022 21:42:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48EA1C433D6; Fri, 18 Nov 2022 21:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1668807757; bh=WCPSd68RHGDTmUGJSNAlMJajTd8lyzv3UTFrUTuu6Pk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fG5ssDEhHsnZ7cCi8hoDKZ3Yq44Q4NZanE7eKUfA0v6WD0+fd7vKP1VUJF7Cnby2k hYyck5qs0LoBNYqW0o2VfQEx2vhdzmTKhJ5TERW3t339NYh46eAX+KR2eGN6QNv6/g SUCnfJ4eIMwT+2yuiHyMtCNfetPUPcHFJp76co+4= Date: Fri, 18 Nov 2022 13:42:36 -0800 From: Andrew Morton To: Qi Zheng Cc: akinobu.mita@gmail.com, dvyukov@google.com, jgg@nvidia.com, willy@infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v3] mm: fix unexpected changes to {failslab|fail_page_alloc}.attr Message-Id: <20221118134236.17a67804b3b6e6c157d8ea02@linux-foundation.org> In-Reply-To: <20221118100011.2634-1-zhengqi.arch@bytedance.com> References: <20221118100011.2634-1-zhengqi.arch@bytedance.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Fri, 18 Nov 2022 18:00:11 +0800 Qi Zheng wrote: > When we specify __GFP_NOWARN, we only expect that no warnings > will be issued for current caller. But in the __should_failslab() > and __should_fail_alloc_page(), the local GFP flags alter the > global {failslab|fail_page_alloc}.attr, which is persistent and > shared by all tasks. This is not what we expected, let's fix it. > > Cc: stable@vger.kernel.org > Fixes: 3f913fc5f974 ("mm: fix missing handler for __GFP_NOWARN") > Reported-by: Dmitry Vyukov > Signed-off-by: Qi Zheng > Reviewed-by: Akinobu Mita > > ... > > -bool should_fail(struct fault_attr *attr, ssize_t size) > +bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags) > { > bool stack_checked = false; > > @@ -152,13 +149,20 @@ bool should_fail(struct fault_attr *attr, ssize_t size) > return false; > > fail: > - fail_dump(attr); > + if (!(flags & FAULT_NOWARN)) > + fail_dump(attr); > > if (atomic_read(&attr->times) != -1) > atomic_dec_not_zero(&attr->times); > > return true; > } > +EXPORT_SYMBOL_GPL(should_fail_ex); I don't see a need to export this?