linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next v2 0/2] Modify some code in sysctl_net_core.c
@ 2022-05-10  3:35 Tiezhu Yang
  2022-05-10  3:35 ` [PATCH bpf-next v2 1/2] net: sysctl: Use SYSCTL_TWO instead of &two Tiezhu Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tiezhu Yang @ 2022-05-10  3:35 UTC (permalink / raw)
  To: davem, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko
  Cc: Xuefeng Li, netdev, bpf, linux-kernel

Tiezhu Yang (2):
  net: sysctl: Use SYSCTL_TWO instead of &two
  bpf: Print some info if disable bpf_jit_enable failed

 net/core/sysctl_net_core.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

-- 
2.1.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH bpf-next v2 1/2] net: sysctl: Use SYSCTL_TWO instead of &two
  2022-05-10  3:35 [PATCH bpf-next v2 0/2] Modify some code in sysctl_net_core.c Tiezhu Yang
@ 2022-05-10  3:35 ` Tiezhu Yang
  2022-05-10  3:35 ` [PATCH bpf-next v2 2/2] bpf: Print some info if disable bpf_jit_enable failed Tiezhu Yang
  2022-05-10 17:30 ` [PATCH bpf-next v2 0/2] Modify some code in sysctl_net_core.c patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Tiezhu Yang @ 2022-05-10  3:35 UTC (permalink / raw)
  To: davem, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko
  Cc: Xuefeng Li, netdev, bpf, linux-kernel

It is better to use SYSCTL_TWO instead of &two, and then we can
remove the variable "two" in net/core/sysctl_net_core.c.

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

diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 8295e58..cf00dd7 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -25,7 +25,6 @@
 
 #include "dev.h"
 
-static int two = 2;
 static int three = 3;
 static int int_3600 = 3600;
 static int min_sndbuf = SOCK_MIN_SNDBUF;
@@ -390,7 +389,7 @@ static struct ctl_table net_core_table[] = {
 		.extra2		= SYSCTL_ONE,
 # else
 		.extra1		= SYSCTL_ZERO,
-		.extra2		= &two,
+		.extra2		= SYSCTL_TWO,
 # endif
 	},
 # ifdef CONFIG_HAVE_EBPF_JIT
@@ -401,7 +400,7 @@ static struct ctl_table net_core_table[] = {
 		.mode		= 0600,
 		.proc_handler	= proc_dointvec_minmax_bpf_restricted,
 		.extra1		= SYSCTL_ZERO,
-		.extra2		= &two,
+		.extra2		= SYSCTL_TWO,
 	},
 	{
 		.procname	= "bpf_jit_kallsyms",
@@ -546,7 +545,7 @@ static struct ctl_table net_core_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO,
-		.extra2		= &two,
+		.extra2		= SYSCTL_TWO,
 	},
 	{
 		.procname	= "devconf_inherit_init_net",
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH bpf-next v2 2/2] bpf: Print some info if disable bpf_jit_enable failed
  2022-05-10  3:35 [PATCH bpf-next v2 0/2] Modify some code in sysctl_net_core.c Tiezhu Yang
  2022-05-10  3:35 ` [PATCH bpf-next v2 1/2] net: sysctl: Use SYSCTL_TWO instead of &two Tiezhu Yang
@ 2022-05-10  3:35 ` Tiezhu Yang
  2022-05-10 17:30 ` [PATCH bpf-next v2 0/2] Modify some code in sysctl_net_core.c patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Tiezhu Yang @ 2022-05-10  3:35 UTC (permalink / raw)
  To: davem, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko
  Cc: Xuefeng Li, netdev, bpf, linux-kernel

A user told me that bpf_jit_enable can be disabled on one system, but he
failed to disable bpf_jit_enable on the other system:

  # echo 0 > /proc/sys/net/core/bpf_jit_enable
  bash: echo: write error: Invalid argument

No useful info is available through the dmesg log, a quick analysis shows
that the issue is related with CONFIG_BPF_JIT_ALWAYS_ON.

When CONFIG_BPF_JIT_ALWAYS_ON is enabled, bpf_jit_enable is permanently set
to 1 and setting any other value than that will return failure.

It is better to print some info to tell the user if disable bpf_jit_enable
failed.

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

diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index cf00dd7..ca4527f 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -266,6 +266,8 @@ static int proc_dointvec_minmax_bpf_enable(struct ctl_table *table, int write,
 					   loff_t *ppos)
 {
 	int ret, jit_enable = *(int *)table->data;
+	int min = *(int *)table->extra1;
+	int max = *(int *)table->extra2;
 	struct ctl_table tmp = *table;
 
 	if (write && !capable(CAP_SYS_ADMIN))
@@ -283,6 +285,10 @@ static int proc_dointvec_minmax_bpf_enable(struct ctl_table *table, int write,
 			ret = -EPERM;
 		}
 	}
+
+	if (write && ret && min == max)
+		pr_info_once("CONFIG_BPF_JIT_ALWAYS_ON is enabled, bpf_jit_enable is permanently set to 1.\n");
+
 	return ret;
 }
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next v2 0/2] Modify some code in sysctl_net_core.c
  2022-05-10  3:35 [PATCH bpf-next v2 0/2] Modify some code in sysctl_net_core.c Tiezhu Yang
  2022-05-10  3:35 ` [PATCH bpf-next v2 1/2] net: sysctl: Use SYSCTL_TWO instead of &two Tiezhu Yang
  2022-05-10  3:35 ` [PATCH bpf-next v2 2/2] bpf: Print some info if disable bpf_jit_enable failed Tiezhu Yang
@ 2022-05-10 17:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-10 17:30 UTC (permalink / raw)
  To: Tiezhu Yang
  Cc: davem, kuba, pabeni, ast, daniel, andrii, lixuefeng, netdev, bpf,
	linux-kernel

Hello:

This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Tue, 10 May 2022 11:35:01 +0800 you wrote:
> Tiezhu Yang (2):
>   net: sysctl: Use SYSCTL_TWO instead of &two
>   bpf: Print some info if disable bpf_jit_enable failed
> 
>  net/core/sysctl_net_core.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)

Here is the summary with links:
  - [bpf-next,v2,1/2] net: sysctl: Use SYSCTL_TWO instead of &two
    https://git.kernel.org/bpf/bpf-next/c/f922c8972fb5
  - [bpf-next,v2,2/2] bpf: Print some info if disable bpf_jit_enable failed
    https://git.kernel.org/bpf/bpf-next/c/174efa781165

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-10 17:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10  3:35 [PATCH bpf-next v2 0/2] Modify some code in sysctl_net_core.c Tiezhu Yang
2022-05-10  3:35 ` [PATCH bpf-next v2 1/2] net: sysctl: Use SYSCTL_TWO instead of &two Tiezhu Yang
2022-05-10  3:35 ` [PATCH bpf-next v2 2/2] bpf: Print some info if disable bpf_jit_enable failed Tiezhu Yang
2022-05-10 17:30 ` [PATCH bpf-next v2 0/2] Modify some code in sysctl_net_core.c patchwork-bot+netdevbpf

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).