Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp376641pxx; Wed, 28 Oct 2020 07:02:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhTDyxpmbQ3BniP28THdVeL/pkftdGXaxjCJh8iLMz9nym37y9W7gnVzRXaARhW7voa8ch X-Received: by 2002:a17:906:e15:: with SMTP id l21mr8051188eji.509.1603893767742; Wed, 28 Oct 2020 07:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603893767; cv=none; d=google.com; s=arc-20160816; b=pINYHhu2TpKXN20VbGY6n51H49/HkCAFANS+ZTKSP59UQNpYcSdf4wkjI89YEs9M/M zRjLpnNKnpuKLBaS+l1K1ZoT3vfpKho/XSuXMJ6z46hI9m+8knJ6DtmXYksJzoTgbCMy PN9QswPbhQNAJuzqAQr7j1Ft1mQbxMZaGhk8i3MkYy62GeBH2gkMRBsZWNKPDQTLFyXo f/vJfAAASPlpaTR7yeOyfHn/clzr4zhEtucbDQDOZ27IKMobzL+TQrGduhgl/eI9XPjk EGPByXK5QZIwaFoHrSR/DNnvO4i9ra2tcuaQu8JiRx0Nb85Y7F401Hq/TTHdYXVMPShV YxaA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=luIdkSFOOmoY/W/eUuABaMEsIiB89ANAVGVeiXUjr6o=; b=D9T8Z43X0xKyhplG4onuvVY8jFokiUnning9oLt8Bu9dnQ6nRjFw3+ggJA7YvmBDGR ia/jyVxea3tHB6J5fIemqBNUP4Vol0Dp7GurutgQGV4CnEiiFLtTnkBFRhpjH8MvoiXZ 0avPbQ/V0VJiEOATIcGkWvDdW37vzlyVdytLpZSwnx3EUhOSZVNy2Jqz8JFI4vvPxl2O PjouxLR7YV1QCJVxz2JfLs+Jo0eXMDSDOJrbMnqFcNx4fQNeXXKutWbpzD5gu3DoIJ7l wxCC3RnhoIJiwjjS/sp1lMXkbwHCQzp1Ni+QbkRqbtIKBhmDgZrkKjv2YVNyMCCQlmuA k8HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0LjoFyaG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs17si3022913ejb.543.2020.10.28.07.02.24; Wed, 28 Oct 2020 07:02:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0LjoFyaG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1803772AbgJ0PxZ (ORCPT + 99 others); Tue, 27 Oct 2020 11:53:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:43568 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S368776AbgJ0P1m (ORCPT ); Tue, 27 Oct 2020 11:27:42 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C61D0206E9; Tue, 27 Oct 2020 15:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812460; bh=fDvuzdHMi2m/Y1H9LP/iTIncn0If+v+pdo13ALMHRUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0LjoFyaGDI8RKtIdsnQraQFpbvDcTlShumow8i+vMytz8pED9FYUl82SxnabgZn9E 1sfH/jCoQzoji3xp9vYBVy9voEht0qSKwJwkPa37Ht8Q7pFOm14NACHg/wLLjq+2VC ZPAd/I/UYe3GAlDo4ic3S55mr+SCzxHTc3Riv5do= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Josef Bacik , Sasha Levin Subject: [PATCH 5.9 218/757] mm/error_inject: Fix allow_error_inject function signatures. Date: Tue, 27 Oct 2020 14:47:48 +0100 Message-Id: <20201027135500.838159404@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexei Starovoitov [ Upstream commit 76cd61739fd107a7f7ec4c24a045e98d8ee150f0 ] 'static' and 'static noinline' function attributes make no guarantees that gcc/clang won't optimize them. The compiler may decide to inline 'static' function and in such case ALLOW_ERROR_INJECT becomes meaningless. The compiler could have inlined __add_to_page_cache_locked() in one callsite and didn't inline in another. In such case injecting errors into it would cause unpredictable behavior. It's worse with 'static noinline' which won't be inlined, but it still can be optimized. Like the compiler may decide to remove one argument or constant propagate the value depending on the callsite. To avoid such issues make sure that these functions are global noinline. Fixes: af3b854492f3 ("mm/page_alloc.c: allow error injection") Fixes: cfcbfb1382db ("mm/filemap.c: enable error injection at add_to_page_cache()") Signed-off-by: Alexei Starovoitov Signed-off-by: Daniel Borkmann Reviewed-by: Josef Bacik Link: https://lore.kernel.org/bpf/20200827220114.69225-2-alexei.starovoitov@gmail.com Signed-off-by: Sasha Levin --- mm/filemap.c | 8 ++++---- mm/page_alloc.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 99c49eeae71b8..f6d36ccc23515 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -827,10 +827,10 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) } EXPORT_SYMBOL_GPL(replace_page_cache_page); -static int __add_to_page_cache_locked(struct page *page, - struct address_space *mapping, - pgoff_t offset, gfp_t gfp_mask, - void **shadowp) +noinline int __add_to_page_cache_locked(struct page *page, + struct address_space *mapping, + pgoff_t offset, gfp_t gfp_mask, + void **shadowp) { XA_STATE(xas, &mapping->i_pages, offset); int huge = PageHuge(page); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 780c8f023b282..c449d74f55842 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3496,7 +3496,7 @@ static inline bool __should_fail_alloc_page(gfp_t gfp_mask, unsigned int order) #endif /* CONFIG_FAIL_PAGE_ALLOC */ -static noinline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order) +noinline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order) { return __should_fail_alloc_page(gfp_mask, order); } -- 2.25.1