Unverified Commit 26e63d23 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!9457 bpf: Add BPF_PROG_TYPE_CGROUP_SKB attach type enforcement in BPF_LINK_CREATE

parents c296899e 70231c28
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3812,6 +3812,11 @@ static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
			 * check permissions at attach time.
			 */
			return -EPERM;

		ptype = attach_type_to_prog_type(attach_type);
		if (prog->type != ptype)
			return -EINVAL;

		return prog->enforce_expected_attach_type &&
			prog->expected_attach_type != attach_type ?
			-EINVAL : 0;