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 B9F0FC001E0 for ; Sun, 9 Jul 2023 15:16:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233613AbjGIPQq (ORCPT ); Sun, 9 Jul 2023 11:16:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233118AbjGIPPk (ORCPT ); Sun, 9 Jul 2023 11:15:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD60410D2; Sun, 9 Jul 2023 08:14:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B7E1960C34; Sun, 9 Jul 2023 15:14:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22710C433C7; Sun, 9 Jul 2023 15:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688915691; bh=PAIGQlpd5mDeDYXcTp4+cGTvT0EXLfKX+X11SAwBp8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q1gb17Qj11wDmXy95lZFPElsVOMP0Fmwl3x+jzuQ8yh25xDuGj4CnOWQL7lFBEScV 1xceDtJ9N9tSmrofBWXUYofNeYaUeqN6f8chV71t0yFlw+NHyPvAk4kWuLusxwCuPf NnDUAL6xfCPtp7fT7xIc6p6qDCdTcnPgLRDeqEmQCDmtfrc26qONKJ3Bn3iNJOQrNv XQC6XrRGc2g8gIpFvRYBPlT3jrAUmN9fQt0KcsXdKLV8A/aEY/31gm/V0yI7uaUMUI k/ZhU9u2jOh82GbnszWviaqopJLjgzCf4wCtC2aiWbf1NTStHXZpyNuolKTgFnQnlR oRnI04A79yEUQ== 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.1 02/18] bpf: Print a warning only if writing to unprivileged_bpf_disabled. Date: Sun, 9 Jul 2023 11:14:30 -0400 Message-Id: <20230709151446.513549-2-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230709151446.513549-1-sashal@kernel.org> References: <20230709151446.513549-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.38 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 6c61dba26f4d9..f04e1f1fc4b6b 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -5284,7 +5284,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