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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58EA3C433FE for ; Fri, 18 Nov 2022 21:42:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229510AbiKRVmo (ORCPT ); Fri, 18 Nov 2022 16:42:44 -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 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?