Blob Blame History Raw
From: Tiezhu Yang <yangtiezhu@loongson.cn>
Date: Tue, 10 May 2022 11:35:03 +0800
Subject: bpf: Print some info if disable bpf_jit_enable failed
Patch-mainline: v5.19-rc1
Git-commit: 174efa7811659b3e3dec05b3649dc6d66c8c4628
References: jsc#PED-1377

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
Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
---
 net/core/sysctl_net_core.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -267,6 +267,8 @@ static int proc_dointvec_minmax_bpf_enab
 					   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))
@@ -284,6 +286,10 @@ static int proc_dointvec_minmax_bpf_enab
 			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;
 }