diff options
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 9378f3ba2cbf..021a05d9d800 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -1093,12 +1093,12 @@ static int bpf_obj_get(const union bpf_attr *attr) | |||
1093 | 1093 | ||
1094 | #ifdef CONFIG_CGROUP_BPF | 1094 | #ifdef CONFIG_CGROUP_BPF |
1095 | 1095 | ||
1096 | #define BPF_PROG_ATTACH_LAST_FIELD attach_bpf_fd2 | 1096 | #define BPF_PROG_ATTACH_LAST_FIELD attach_flags |
1097 | 1097 | ||
1098 | static int sockmap_get_from_fd(const union bpf_attr *attr, int ptype) | 1098 | static int sockmap_get_from_fd(const union bpf_attr *attr) |
1099 | { | 1099 | { |
1100 | struct bpf_prog *prog1, *prog2; | ||
1101 | int ufd = attr->target_fd; | 1100 | int ufd = attr->target_fd; |
1101 | struct bpf_prog *prog; | ||
1102 | struct bpf_map *map; | 1102 | struct bpf_map *map; |
1103 | struct fd f; | 1103 | struct fd f; |
1104 | int err; | 1104 | int err; |
@@ -1108,29 +1108,16 @@ static int sockmap_get_from_fd(const union bpf_attr *attr, int ptype) | |||
1108 | if (IS_ERR(map)) | 1108 | if (IS_ERR(map)) |
1109 | return PTR_ERR(map); | 1109 | return PTR_ERR(map); |
1110 | 1110 | ||
1111 | if (!map->ops->map_attach) { | 1111 | prog = bpf_prog_get_type(attr->attach_bpf_fd, BPF_PROG_TYPE_SK_SKB); |
1112 | fdput(f); | 1112 | if (IS_ERR(prog)) { |
1113 | return -EOPNOTSUPP; | ||
1114 | } | ||
1115 | |||
1116 | prog1 = bpf_prog_get_type(attr->attach_bpf_fd, ptype); | ||
1117 | if (IS_ERR(prog1)) { | ||
1118 | fdput(f); | 1113 | fdput(f); |
1119 | return PTR_ERR(prog1); | 1114 | return PTR_ERR(prog); |
1120 | } | ||
1121 | |||
1122 | prog2 = bpf_prog_get_type(attr->attach_bpf_fd2, ptype); | ||
1123 | if (IS_ERR(prog2)) { | ||
1124 | fdput(f); | ||
1125 | bpf_prog_put(prog1); | ||
1126 | return PTR_ERR(prog2); | ||
1127 | } | 1115 | } |
1128 | 1116 | ||
1129 | err = map->ops->map_attach(map, prog1, prog2); | 1117 | err = sock_map_attach_prog(map, prog, attr->attach_type); |
1130 | if (err) { | 1118 | if (err) { |
1131 | fdput(f); | 1119 | fdput(f); |
1132 | bpf_prog_put(prog1); | 1120 | bpf_prog_put(prog); |
1133 | bpf_prog_put(prog2); | ||
1134 | return err; | 1121 | return err; |
1135 | } | 1122 | } |
1136 | 1123 | ||
@@ -1165,16 +1152,13 @@ static int bpf_prog_attach(const union bpf_attr *attr) | |||
1165 | case BPF_CGROUP_SOCK_OPS: | 1152 | case BPF_CGROUP_SOCK_OPS: |
1166 | ptype = BPF_PROG_TYPE_SOCK_OPS; | 1153 | ptype = BPF_PROG_TYPE_SOCK_OPS; |
1167 | break; | 1154 | break; |
1168 | case BPF_CGROUP_SMAP_INGRESS: | 1155 | case BPF_SK_SKB_STREAM_PARSER: |
1169 | ptype = BPF_PROG_TYPE_SK_SKB; | 1156 | case BPF_SK_SKB_STREAM_VERDICT: |
1170 | break; | 1157 | return sockmap_get_from_fd(attr); |
1171 | default: | 1158 | default: |
1172 | return -EINVAL; | 1159 | return -EINVAL; |
1173 | } | 1160 | } |
1174 | 1161 | ||
1175 | if (attr->attach_type == BPF_CGROUP_SMAP_INGRESS) | ||
1176 | return sockmap_get_from_fd(attr, ptype); | ||
1177 | |||
1178 | prog = bpf_prog_get_type(attr->attach_bpf_fd, ptype); | 1162 | prog = bpf_prog_get_type(attr->attach_bpf_fd, ptype); |
1179 | if (IS_ERR(prog)) | 1163 | if (IS_ERR(prog)) |
1180 | return PTR_ERR(prog); | 1164 | return PTR_ERR(prog); |