Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1508854
| From | Mickaël Salaün <mic@digikod.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC v4 12/18] bpf: Cosmetic change for bpf_prog_attach() |
| Date | 2016-10-26 09:10 +0200 |
| Message-ID | <swqvw-i6-41@gated-at.bofh.it> (permalink) |
| References | <swqlP-8qD-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Move code outside a switch/case to ease code factoring (cf. next
commit).
This apply on Daniel Mack's "Add eBPF hooks for cgroups" v7:
https://lkml.kernel.org/r/1477390454-12553-1-git-send-email-daniel@zonque.org
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Daniel Mack <daniel@zonque.org>
---
kernel/bpf/syscall.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 0f7faa9d2262..ac4cbb98596d 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -843,23 +843,24 @@ static int bpf_prog_attach(const union bpf_attr *attr)
case BPF_CGROUP_INET_EGRESS:
prog = bpf_prog_get_type(attr->attach_bpf_fd,
BPF_PROG_TYPE_CGROUP_SKB);
- if (IS_ERR(prog))
- return PTR_ERR(prog);
-
- cgrp = cgroup_get_from_fd(attr->target_fd);
- if (IS_ERR(cgrp)) {
- bpf_prog_put(prog);
- return PTR_ERR(cgrp);
- }
-
- cgroup_bpf_update(cgrp, prog, attr->attach_type);
- cgroup_put(cgrp);
break;
default:
return -EINVAL;
}
+ if (IS_ERR(prog))
+ return PTR_ERR(prog);
+
+ cgrp = cgroup_get_from_fd(attr->target_fd);
+ if (IS_ERR(cgrp)) {
+ bpf_prog_put(prog);
+ return PTR_ERR(cgrp);
+ }
+
+ cgroup_bpf_update(cgrp, prog, attr->attach_type);
+ cgroup_put(cgrp);
+
return 0;
}
--
2.9.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC v4 00/18] Landlock LSM: Unprivileged sandboxing Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:00 +0200
[RFC v4 16/18] bpf/cgroup,landlock: Handle Landlock hooks per cgroup Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:00 +0200
[RFC v4 11/18] seccomp,landlock: Handle Landlock hooks per process hierarchy Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:00 +0200
[RFC v4 05/18] bpf,landlock: Define an eBPF program type for Landlock Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
[RFC v4 06/18] fs: Constify path_is_under()'s arguments Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
[RFC v4 10/18] seccomp: Split put_seccomp_filter() with put_seccomp() Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
[RFC v4 14/18] bpf/cgroup: Make cgroup_bpf_update() return an error code Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
[RFC v4 13/18] bpf/cgroup: Replace struct bpf_prog with struct bpf_object Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
[RFC v4 12/18] bpf: Cosmetic change for bpf_prog_attach() Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
[RFC v4 01/18] landlock: Add Kconfig Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
[RFC v4 09/18] landlock: Add manager functions Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
[RFC v4 03/18] bpf,landlock: Add a new arraymap type to deal with (Landlock) handles Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
Re: [kernel-hardening] [RFC v4 03/18] bpf,landlock: Add a new arraymap type to deal with (Landlock) handles Jann Horn <jann@thejh.net> - 2016-10-26 21:10 +0200
Re: [kernel-hardening] [RFC v4 03/18] bpf,landlock: Add a new arraymap type to deal with (Landlock) handles Mickaël Salaün <mic@digikod.net> - 2016-10-26 22:10 +0200
Re: [kernel-hardening] [RFC v4 03/18] bpf,landlock: Add a new arraymap type to deal with (Landlock) handles Jann Horn <jann@thejh.net> - 2016-10-26 22:20 +0200
[RFC v4 02/18] bpf: Move u64_to_ptr() to BPF headers and inline it Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
Re: [RFC v4 02/18] bpf: Move u64_to_ptr() to BPF headers and inline it Arnd Bergmann <arnd@arndb.de> - 2016-10-26 09:30 +0200
Re: [kernel-hardening] Re: [RFC v4 02/18] bpf: Move u64_to_ptr() to BPF headers and inline it David Sterba <dave@jikos.cz> - 2016-10-26 16:00 +0200
[RFC v4 08/18] landlock: Handle file comparisons Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
[RFC v4 04/18] bpf,landlock: Add eBPF program subtype and is_valid_subtype() verifier Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
[RFC v4 17/18] landlock: Add update and debug access flags Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
[RFC v4 07/18] landlock: Add LSM hooks Mickaël Salaün <mic@digikod.net> - 2016-10-26 09:10 +0200
Re: [RFC v4 00/18] Landlock LSM: Unprivileged sandboxing Jann Horn <jann@thejh.net> - 2016-10-26 17:00 +0200
Re: [RFC v4 00/18] Landlock LSM: Unprivileged sandboxing Mickaël Salaün <mic@digikod.net> - 2016-10-26 19:00 +0200
Re: [RFC v4 00/18] Landlock LSM: Unprivileged sandboxing Mickaël Salaün <mic@digikod.net> - 2016-10-26 19:30 +0200
csiph-web