Commit 7e40445f authored by Pu Lehui's avatar Pu Lehui
Browse files

bpf: Fix kabi breakage in struct bpf_map

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYRIC


CVE: CVE-2024-50063

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

Fix kabi breakage in struct bpf_map by using KABI_USE.

Fixes: e0b1224b89c4 ("bpf: Prevent tail call between progs attached to different hooks")
Signed-off-by: default avatarPu Lehui <pulehui@huawei.com>
parent a4271b19
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -294,7 +294,6 @@ struct bpf_map {
	 * same prog type, JITed flag and xdp_has_frags flag.
	 */
	struct {
		const struct btf_type *attach_func_proto;
		spinlock_t lock;
		enum bpf_prog_type type;
		bool jited;
@@ -307,7 +306,7 @@ struct bpf_map {
	s64 __percpu *elem_count;

	KABI_USE(1, atomic64_t sleepable_refcnt)
	KABI_RESERVE(2)
	KABI_USE(2, const struct btf_type *attach_func_proto)
	KABI_RESERVE(3)
	KABI_RESERVE(4)
};
+2 −2
Original line number Diff line number Diff line
@@ -2280,14 +2280,14 @@ bool bpf_prog_map_compatible(struct bpf_map *map,
		map->owner.type  = prog_type;
		map->owner.jited = fp->jited;
		map->owner.xdp_has_frags = aux->xdp_has_frags;
		map->owner.attach_func_proto = aux->attach_func_proto;
		map->attach_func_proto = aux->attach_func_proto;
		ret = true;
	} else {
		ret = map->owner.type  == prog_type &&
		      map->owner.jited == fp->jited &&
		      map->owner.xdp_has_frags == aux->xdp_has_frags;
		if (ret &&
		    map->owner.attach_func_proto != aux->attach_func_proto) {
		    map->attach_func_proto != aux->attach_func_proto) {
			switch (prog_type) {
			case BPF_PROG_TYPE_TRACING:
			case BPF_PROG_TYPE_LSM: