Commit 7263e22b authored by Tengda Wu's avatar Tengda Wu Committed by Pu Lehui
Browse files

Fix kabi breakage in struct bpf_link and bpf_link_ops

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


CVE: CVE-2024-35860

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

After backport LTS commit 777a1adfea1c ("[Backport] bpf: support deferring
bpf_link dealloc to after RCU grace period"), `bpf_link` and `bpf_link_ops`
structures have changed, causing kabi breakage.

Use KABI_REPLACE and KABI_USE to fix kabi breakage in struct `bpf_link` and
struct `bpf_link_ops`.

Fixes: 1a1260f3db15 ("bpf: support deferring bpf_link dealloc to after RCU grace period")
Signed-off-by: default avatarTengda Wu <wutengda2@huawei.com>
Signed-off-by: default avatarPu Lehui <pulehui@huawei.com>
parent 12775e76
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -1585,10 +1585,10 @@ struct bpf_link {
	/* rcu is used before freeing, work can be used to schedule that
	 * RCU-based freeing before that, so they never overlap
	 */
	union {
	KABI_REPLACE(struct work_struct work, union {
		struct rcu_head rcu;
		struct work_struct work;
	};
	})

	KABI_RESERVE(1)
	KABI_RESERVE(2)
@@ -1602,11 +1602,6 @@ struct bpf_link_ops {
	 * waiting
	 */
	void (*dealloc)(struct bpf_link *link);
	/* deallocate link resources callback, called after RCU grace period;
	 * if underlying BPF program is sleepable we go through tasks trace
	 * RCU GP and then "classic" RCU GP
	 */
	void (*dealloc_deferred)(struct bpf_link *link);
	int (*detach)(struct bpf_link *link);
	int (*update_prog)(struct bpf_link *link, struct bpf_prog *new_prog,
			   struct bpf_prog *old_prog);
@@ -1616,7 +1611,11 @@ struct bpf_link_ops {
	int (*update_map)(struct bpf_link *link, struct bpf_map *new_map,
			  struct bpf_map *old_map);

	KABI_RESERVE(1)
	/* deallocate link resources callback, called after RCU grace period;
	 * if underlying BPF program is sleepable we go through tasks trace
	 * RCU GP and then "classic" RCU GP
	 */
	KABI_USE(1, void (*dealloc_deferred)(struct bpf_link *link))
	KABI_RESERVE(2)
	KABI_RESERVE(3)
	KABI_RESERVE(4)