Commit 8d84ad68 authored by Stanislav Fomichev's avatar Stanislav Fomichev Committed by Pu Lehui
Browse files

bpf: expose bpf_strtol and bpf_strtoul to all program types

mainline inclusion
from mainline-v6.1-rc1
commit 8a67f2de
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I932VT
CVE: CVE-2023-52452

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8a67f2de9b1d



--------------------------------

bpf_strncmp is already exposed everywhere. The motivation is to keep
those helpers in kernel/bpf/helpers.c. Otherwise it's tempting to move
them under kernel/bpf/cgroup.c because they are currently only used
by sysctl prog types.

Suggested-by: default avatarMartin KaFai Lau <kafai@fb.com>
Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/r/20220823222555.523590-4-sdf@google.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarPu Lehui <pulehui@huawei.com>
parent ab02811b
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -1766,10 +1766,6 @@ static const struct bpf_func_proto *
sysctl_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
{
	switch (func_id) {
	case BPF_FUNC_strtol:
		return &bpf_strtol_proto;
	case BPF_FUNC_strtoul:
		return &bpf_strtoul_proto;
	case BPF_FUNC_sysctl_get_name:
		return &bpf_sysctl_get_name_proto;
	case BPF_FUNC_sysctl_get_current_value:
+6 −1
Original line number Diff line number Diff line
@@ -405,6 +405,8 @@ const struct bpf_func_proto bpf_get_local_storage_proto = {
};
#endif

#endif /* CONFIG_CGROUPS */

#define BPF_STRTOX_BASE_MASK 0x1F

static int __bpf_strtoull(const char *buf, size_t buf_len, u64 flags,
@@ -532,7 +534,6 @@ const struct bpf_func_proto bpf_strtoul_proto = {
	.arg3_type	= ARG_ANYTHING,
	.arg4_type	= ARG_PTR_TO_LONG,
};
#endif

BPF_CALL_4(bpf_get_ns_current_pid_tgid, u64, dev, u64, ino,
	   struct bpf_pidns_info *, nsdata, u32, size)
@@ -701,6 +702,10 @@ bpf_base_func_proto(enum bpf_func_id func_id)
		return &bpf_ringbuf_discard_proto;
	case BPF_FUNC_ringbuf_query:
		return &bpf_ringbuf_query_proto;
	case BPF_FUNC_strtol:
		return &bpf_strtol_proto;
	case BPF_FUNC_strtoul:
		return &bpf_strtoul_proto;
	case BPF_FUNC_sched_tg_tag_of:
		return &bpf_sched_tg_tag_of_proto;
	case BPF_FUNC_sched_task_tag_of: