netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: davem@davemloft.net, Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH bpf-next 2/3] net: sysctl: No need to check CAP_SYS_ADMIN for bpf_jit_*
Date: Mon,  9 May 2022 14:57:54 +0800	[thread overview]
Message-ID: <1652079475-16684-3-git-send-email-yangtiezhu@loongson.cn> (raw)
In-Reply-To: <1652079475-16684-1-git-send-email-yangtiezhu@loongson.cn>

The mode of the following procnames are defined as 0644, 0600, 0600
and 0600 respectively in net_core_table[], normal user can not write
them, so no need to check CAP_SYS_ADMIN in the related proc_handler
function, just remove the checks.

/proc/sys/net/core/bpf_jit_enable
/proc/sys/net/core/bpf_jit_harden
/proc/sys/net/core/bpf_jit_kallsyms
/proc/sys/net/core/bpf_jit_limit

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 net/core/sysctl_net_core.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index cf00dd7..059352b 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -268,9 +268,6 @@ static int proc_dointvec_minmax_bpf_enable(struct ctl_table *table, int write,
 	int ret, jit_enable = *(int *)table->data;
 	struct ctl_table tmp = *table;
 
-	if (write && !capable(CAP_SYS_ADMIN))
-		return -EPERM;
-
 	tmp.data = &jit_enable;
 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
 	if (write && !ret) {
@@ -291,9 +288,6 @@ static int
 proc_dointvec_minmax_bpf_restricted(struct ctl_table *table, int write,
 				    void *buffer, size_t *lenp, loff_t *ppos)
 {
-	if (!capable(CAP_SYS_ADMIN))
-		return -EPERM;
-
 	return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
 }
 # endif /* CONFIG_HAVE_EBPF_JIT */
@@ -302,9 +296,6 @@ static int
 proc_dolongvec_minmax_bpf_restricted(struct ctl_table *table, int write,
 				     void *buffer, size_t *lenp, loff_t *ppos)
 {
-	if (!capable(CAP_SYS_ADMIN))
-		return -EPERM;
-
 	return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
 }
 #endif
-- 
2.1.0


  parent reply	other threads:[~2022-05-09  7:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09  6:57 [PATCH bpf-next 0/3] Modify some code in sysctl_net_core.c Tiezhu Yang
2022-05-09  6:57 ` [PATCH bpf-next 1/3] net: sysctl: Use SYSCTL_TWO instead of &two Tiezhu Yang
2022-05-09  6:57 ` Tiezhu Yang [this message]
2022-05-09 15:02   ` [PATCH bpf-next 2/3] net: sysctl: No need to check CAP_SYS_ADMIN for bpf_jit_* Daniel Borkmann
2022-05-10  2:42     ` Tiezhu Yang
2022-05-09  6:57 ` [PATCH bpf-next 3/3] bpf: Print some info if disable bpf_jit_enable failed Tiezhu Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1652079475-16684-3-git-send-email-yangtiezhu@loongson.cn \
    --to=yangtiezhu@loongson.cn \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).