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 410DCC001DE for ; Sun, 9 Jul 2023 15:15:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233205AbjGIPPH (ORCPT ); Sun, 9 Jul 2023 11:15:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233268AbjGIPOl (ORCPT ); Sun, 9 Jul 2023 11:14:41 -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 66B3E19B7; Sun, 9 Jul 2023 08:14:09 -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 B997260C23; Sun, 9 Jul 2023 15:14:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3045BC433C8; Sun, 9 Jul 2023 15:14:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688915641; bh=Aesp4GTSsA1CjPjXVz0rW/ftouvK6fmZazcFgRA9MIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NwXc1q2NipC1KXnWvioHiZE9xHVx7sM1tUf1Xo8Rumis221N4WeGVfoEX92A+i9sg MRwrgMxfsjFjetufmrEAJE+WOrq3HNBAi6n2UsBmSl0iiD+YvJoaekoUpwYkJJunjd fbewSIh9seeke/Sw9IfpoQd6LMuHY+4+ZzvnmTGgV/Pwa5BuHkjULyFwXex3P3HtwV LMR/xbpi2PBB/Izs2KGBpeMvz+gMfn6g3FQOBSSt03b3wXsy/fOQKt72CIFyHAVt8W Tdi2NhKJsXE9kaeTcQWtsd2H9Q+ZiuP7RxCgyTdUmFOFGnB7mnUOzRVKQ/TSffbRWa ZeTXfFn/GDmCQ== 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.3 02/22] bpf: Print a warning only if writing to unprivileged_bpf_disabled. Date: Sun, 9 Jul 2023 11:13:36 -0400 Message-Id: <20230709151356.513279-2-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230709151356.513279-1-sashal@kernel.org> References: <20230709151356.513279-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.3.12 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 adc83cb82f379..4ae74b8ded867 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -5314,7 +5314,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