Skip to content

Commit 174efa7

Browse files
seehearfeelAlexei Starovoitov
authored andcommitted
bpf: Print some info if disable bpf_jit_enable failed
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> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/1652153703-22729-3-git-send-email-yangtiezhu@loongson.cn
1 parent f922c89 commit 174efa7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/core/sysctl_net_core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ static int proc_dointvec_minmax_bpf_enable(struct ctl_table *table, int write,
266266
loff_t *ppos)
267267
{
268268
int ret, jit_enable = *(int *)table->data;
269+
int min = *(int *)table->extra1;
270+
int max = *(int *)table->extra2;
269271
struct ctl_table tmp = *table;
270272

271273
if (write && !capable(CAP_SYS_ADMIN))
@@ -283,6 +285,10 @@ static int proc_dointvec_minmax_bpf_enable(struct ctl_table *table, int write,
283285
ret = -EPERM;
284286
}
285287
}
288+
289+
if (write && ret && min == max)
290+
pr_info_once("CONFIG_BPF_JIT_ALWAYS_ON is enabled, bpf_jit_enable is permanently set to 1.\n");
291+
286292
return ret;
287293
}
288294

0 commit comments

Comments
 (0)