From patchwork Wed Jun 19 22:48:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13704695 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 C8D0BC27C53 for ; Wed, 19 Jun 2024 22:49:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7CFA66B00BC; Wed, 19 Jun 2024 18:49:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 667D48D0091; Wed, 19 Jun 2024 18:49:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 498798D008F; Wed, 19 Jun 2024 18:49:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0E8328D0090 for ; Wed, 19 Jun 2024 18:49:48 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B7451415AF for ; Wed, 19 Jun 2024 22:49:47 +0000 (UTC) X-FDA: 82249132014.14.9224373 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf02.hostedemail.com (Postfix) with ESMTP id 7673980007 for ; Wed, 19 Jun 2024 22:49:45 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=LNWxnnz1; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=roVh2sJJ; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=LNWxnnz1; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=roVh2sJJ; spf=pass (imf02.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718837377; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=X7+XAotVIvWS2vTh75oVQOPFwsOci6tWQZhDoSRQGx4=; b=nX/MAO+iVkX8QJUDZbS4fjhqSP2IsyBZyestRvj1YRmQ0QA67ZxMZjXPHUMuSIAQVBTYkJ HYjaTSBv3tQYj+7pnkNMjR93bMhxACFvUwESeFhSh0OlUcXcDWCNIWI3Fr2ZWRqKzK5DZ2 L2+UVJqWM8IsnDIWXy698yqkFX/0rfo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718837377; a=rsa-sha256; cv=none; b=2HBXTYKL4MZkTAK6NVvF+lK84gj8Nnn3R2nUERJAvzUmz595xd1Vnf9KbU/YLegP4vgwm+ Cxperhox4APUNrrOsY5S827OSvPKUyrGS+KA36TQzLzV9F5EGtxF8svu8/It8Go8XupQa9 /G+SgErA2fWOJHxSH4gHUgIAnaLg5JU= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=LNWxnnz1; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=roVh2sJJ; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=LNWxnnz1; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=roVh2sJJ; spf=pass (imf02.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 994E01F7F7; Wed, 19 Jun 2024 22:49:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1718837383; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X7+XAotVIvWS2vTh75oVQOPFwsOci6tWQZhDoSRQGx4=; b=LNWxnnz1OKuGoWGrMXrwTd2enyzJN73ypy1Cuy1qZtBotKAAqp2aq65A1gK7qZ8U54E2Lz FILu5L+orwbhDShXDMWDHPD659eTlwmmC78MWsxkCr/n6HetuhQ8GeFlOmDbT43Vpg8zeO i6yA9AvNuoYhNrFm1SRXWVMJ9lI5Fo0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1718837383; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X7+XAotVIvWS2vTh75oVQOPFwsOci6tWQZhDoSRQGx4=; b=roVh2sJJLOmM0oiL35sPyLjBSwOuoRsf/nGyJvEjjBe2kt/FPev0yfzWJK/1XF1/iK2GOP 56CsF5e9QNpjsaBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1718837383; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X7+XAotVIvWS2vTh75oVQOPFwsOci6tWQZhDoSRQGx4=; b=LNWxnnz1OKuGoWGrMXrwTd2enyzJN73ypy1Cuy1qZtBotKAAqp2aq65A1gK7qZ8U54E2Lz FILu5L+orwbhDShXDMWDHPD659eTlwmmC78MWsxkCr/n6HetuhQ8GeFlOmDbT43Vpg8zeO i6yA9AvNuoYhNrFm1SRXWVMJ9lI5Fo0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1718837383; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X7+XAotVIvWS2vTh75oVQOPFwsOci6tWQZhDoSRQGx4=; b=roVh2sJJLOmM0oiL35sPyLjBSwOuoRsf/nGyJvEjjBe2kt/FPev0yfzWJK/1XF1/iK2GOP 56CsF5e9QNpjsaBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 76B2913AC3; Wed, 19 Jun 2024 22:49:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id gBasHIdgc2aFIAAAD6G6ig (envelope-from ); Wed, 19 Jun 2024 22:49:43 +0000 From: Vlastimil Babka Date: Thu, 20 Jun 2024 00:48:59 +0200 Subject: [PATCH v2 5/7] bpf: do not create bpf_non_sleepable_error_inject list when unnecessary MIME-Version: 1.0 Message-Id: <20240620-fault-injection-statickeys-v2-5-e23947d3d84b@suse.cz> References: <20240620-fault-injection-statickeys-v2-0-e23947d3d84b@suse.cz> In-Reply-To: <20240620-fault-injection-statickeys-v2-0-e23947d3d84b@suse.cz> To: Akinobu Mita , Christoph Lameter , David Rientjes , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Masami Hiramatsu , Steven Rostedt , Mark Rutland Cc: Jiri Olsa , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Vlastimil Babka X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1591; i=vbabka@suse.cz; h=from:subject:message-id; bh=+HcqYdgaWT9BrUacvRJSWp4CDbAKfRkRibADsrgT2bU=; b=owEBbQGS/pANAwAIAbvgsHXSRYiaAcsmYgBmc2B9IzDEAVKG5FXS38RcYZUyeL9j5X2CdCydU Xm/auj9IMKJATMEAAEIAB0WIQR7u8hBFZkjSJZITfG74LB10kWImgUCZnNgfQAKCRC74LB10kWI mieMB/0Z2oYYCWNAmVEuHX7NW7yYno6Akg2QEWBe10L/+QsV4Wfjt61ibXRZyOYv5dL16q+TyVM Gofehb9TgIuIG9fzbiv/IkDt0D9UULaagQwhJUpdnLAOYxw7FRr1nYbjmJt/cNOUtR8cMo6x1PG 33Gevml4l4phxiCJEnvCSO9Xum+ZBP/F3GOvVXDBDIF/vXVBhmF0iRyvefoi9o66f+guBziQc0j DDNd0wet/qYXslsYfyo9XtYY9+dP/5/d9pwYbcsvP8BN9uQkE3IeYQHe/Thldx8B/855/bItiKc AkAI9cbY8cY4/mKYag0vVzO6xNXmffLfuOg01lsVKyX58qWE X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Stat-Signature: 5wrn7fgre5cco8de5rjw715aqkmr4bfm X-Rspamd-Queue-Id: 7673980007 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1718837385-488125 X-HE-Meta: U2FsdGVkX1/I7/BKHF2rsvLiaCtAJyO97yoIoYckAjjlzDhK4iTM6c99s6vckyj0G2ihs5DiYOG+CG8tzRdzEub9I0Z6UgJuMrMHp+wc0gtjG/cEAPkCQlKBxTaWu9RTDGN14PmUPK1+FzMw26LOU6rbZPvaSLO+CEtfj9iiLnyQo51nD8aVjelhGO+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g/AfO1gJ6TXUu+Brfw6gPh+VoFOBsX+q3gl61ElvYCawFGiqyXRIA== 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: List-Subscribe: List-Unsubscribe: When CONFIG_FUNCTION_ERROR_INJECTION is disabled, within_error_injection_list() will return false for any address and the result of check_non_sleepable_error_inject() denylist is thus redundant. The bpf_non_sleepable_error_inject list thus does not need to be constructed at all, so #ifdef it out. This will allow to inline functions on the list when CONFIG_FUNCTION_ERROR_INJECTION is disabled as there will be no BTF_ID() reference for them. Signed-off-by: Vlastimil Babka --- kernel/bpf/verifier.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 77da1f438bec..5cd93de37d68 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -21044,6 +21044,8 @@ static int check_attach_modify_return(unsigned long addr, const char *func_name) return -EINVAL; } +#ifdef CONFIG_FUNCTION_ERROR_INJECTION + /* list of non-sleepable functions that are otherwise on * ALLOW_ERROR_INJECTION list */ @@ -21061,6 +21063,19 @@ static int check_non_sleepable_error_inject(u32 btf_id) return btf_id_set_contains(&btf_non_sleepable_error_inject, btf_id); } +#else /* CONFIG_FUNCTION_ERROR_INJECTION */ + +/* + * Pretend the denylist is empty, within_error_injection_list() will return + * false anyway. + */ +static int check_non_sleepable_error_inject(u32 btf_id) +{ + return 0; +} + +#endif + int bpf_check_attach_target(struct bpf_verifier_log *log, const struct bpf_prog *prog, const struct bpf_prog *tgt_prog,