From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E23FC33D9 for ; Sun, 9 Jul 2023 15:13:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5901EC433CB; Sun, 9 Jul 2023 15:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688915580; bh=oyJMKpX+tRVslhuKNrHjM4kIgy+eIZlE7fR7+clRX28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mChc1bevbOxg2tfP00ebnrapHQmR+7bRCGQgJvV5RGfrLrA9klyBuECQHswZ+5Wl0 GGgc8prXRW8O00MaXoOOHt82yJhyyML+KZakSYylV7Y/BqjqRnCk/kc8sf7kZuN0lq eetZiXGL97TiYc41695yyJsBI6czRjlv6b9lyc5Wam5Or+WdDsuCsZulTuGQgziZFA jes0qMutM4CC8ca8ZPE2D2iaPPR+0z2tCMzkzRIuxftciId5BEEDRAy8sq898gHeZL FKuJ9R7s2ohnUYUGqKEtgzxWcvhHSIVDTHI4mryIRtd2I3oXsmOzr8E+KtvJog/ZWI gCUUE2rzkghHw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kui-Feng Lee , Kui-Feng Lee , Andrii Nakryiko , Yonghong Song , Sasha Levin , ast@kernel.org, daniel@iogearbox.net, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 6.4 02/26] bpf: Print a warning only if writing to unprivileged_bpf_disabled. Date: Sun, 9 Jul 2023 11:12:31 -0400 Message-Id: <20230709151255.512931-2-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230709151255.512931-1-sashal@kernel.org> References: <20230709151255.512931-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.4.2 Content-Transfer-Encoding: 8bit From: Kui-Feng Lee [ Upstream commit fedf99200ab086c42a572fca1d7266b06cdc3e3f ] Only print the warning message if you are writing to "/proc/sys/kernel/unprivileged_bpf_disabled". The kernel may print an annoying warning when you read "/proc/sys/kernel/unprivileged_bpf_disabled" saying WARNING: Unprivileged eBPF is enabled with eIBRS on, data leaks possible via Spectre v2 BHB attacks! However, this message is only meaningful when the feature is disabled or enabled. Signed-off-by: Kui-Feng Lee Signed-off-by: Andrii Nakryiko Acked-by: Yonghong Song Link: https://lore.kernel.org/bpf/20230502181418.308479-1-kuifeng@meta.com Signed-off-by: Sasha Levin --- kernel/bpf/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index f1c8733f76b83..5524fcf6fb2a4 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -5394,7 +5394,8 @@ static int bpf_unpriv_handler(struct ctl_table *table, int write, *(int *)table->data = unpriv_enable; } - unpriv_ebpf_notify(unpriv_enable); + if (write) + unpriv_ebpf_notify(unpriv_enable); return ret; } -- 2.39.2