diff options
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index e24aa3241387..3aeb4ea2a93a 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -1315,7 +1315,8 @@ static int bpf_obj_get(const union bpf_attr *attr) | |||
1315 | 1315 | ||
1316 | #define BPF_PROG_ATTACH_LAST_FIELD attach_flags | 1316 | #define BPF_PROG_ATTACH_LAST_FIELD attach_flags |
1317 | 1317 | ||
1318 | static int sockmap_get_from_fd(const union bpf_attr *attr, bool attach) | 1318 | static int sockmap_get_from_fd(const union bpf_attr *attr, |
1319 | int type, bool attach) | ||
1319 | { | 1320 | { |
1320 | struct bpf_prog *prog = NULL; | 1321 | struct bpf_prog *prog = NULL; |
1321 | int ufd = attr->target_fd; | 1322 | int ufd = attr->target_fd; |
@@ -1329,8 +1330,7 @@ static int sockmap_get_from_fd(const union bpf_attr *attr, bool attach) | |||
1329 | return PTR_ERR(map); | 1330 | return PTR_ERR(map); |
1330 | 1331 | ||
1331 | if (attach) { | 1332 | if (attach) { |
1332 | prog = bpf_prog_get_type(attr->attach_bpf_fd, | 1333 | prog = bpf_prog_get_type(attr->attach_bpf_fd, type); |
1333 | BPF_PROG_TYPE_SK_SKB); | ||
1334 | if (IS_ERR(prog)) { | 1334 | if (IS_ERR(prog)) { |
1335 | fdput(f); | 1335 | fdput(f); |
1336 | return PTR_ERR(prog); | 1336 | return PTR_ERR(prog); |
@@ -1382,9 +1382,11 @@ static int bpf_prog_attach(const union bpf_attr *attr) | |||
1382 | case BPF_CGROUP_DEVICE: | 1382 | case BPF_CGROUP_DEVICE: |
1383 | ptype = BPF_PROG_TYPE_CGROUP_DEVICE; | 1383 | ptype = BPF_PROG_TYPE_CGROUP_DEVICE; |
1384 | break; | 1384 | break; |
1385 | case BPF_SK_MSG_VERDICT: | ||
1386 | return sockmap_get_from_fd(attr, BPF_PROG_TYPE_SK_MSG, true); | ||
1385 | case BPF_SK_SKB_STREAM_PARSER: | 1387 | case BPF_SK_SKB_STREAM_PARSER: |
1386 | case BPF_SK_SKB_STREAM_VERDICT: | 1388 | case BPF_SK_SKB_STREAM_VERDICT: |
1387 | return sockmap_get_from_fd(attr, true); | 1389 | return sockmap_get_from_fd(attr, BPF_PROG_TYPE_SK_SKB, true); |
1388 | default: | 1390 | default: |
1389 | return -EINVAL; | 1391 | return -EINVAL; |
1390 | } | 1392 | } |
@@ -1437,9 +1439,11 @@ static int bpf_prog_detach(const union bpf_attr *attr) | |||
1437 | case BPF_CGROUP_DEVICE: | 1439 | case BPF_CGROUP_DEVICE: |
1438 | ptype = BPF_PROG_TYPE_CGROUP_DEVICE; | 1440 | ptype = BPF_PROG_TYPE_CGROUP_DEVICE; |
1439 | break; | 1441 | break; |
1442 | case BPF_SK_MSG_VERDICT: | ||
1443 | return sockmap_get_from_fd(attr, BPF_PROG_TYPE_SK_MSG, false); | ||
1440 | case BPF_SK_SKB_STREAM_PARSER: | 1444 | case BPF_SK_SKB_STREAM_PARSER: |
1441 | case BPF_SK_SKB_STREAM_VERDICT: | 1445 | case BPF_SK_SKB_STREAM_VERDICT: |
1442 | return sockmap_get_from_fd(attr, false); | 1446 | return sockmap_get_from_fd(attr, BPF_PROG_TYPE_SK_SKB, false); |
1443 | default: | 1447 | default: |
1444 | return -EINVAL; | 1448 | return -EINVAL; |
1445 | } | 1449 | } |