[PATCH bpf-next 2/6] fs: wire in BPF_CGROUP_FILE_OPEN hook

Alexei Starovoitov
2018-10-04T02:58:29Z

enable cgroup-bpf BPF_CGROUP_FILE_OPEN hook after security_file_open() LSM hook.
Similarly to other cgroup-bpf hooks it's gated by static key 'cgroup_bpf_enabled'
and has zero overhead until bpf prog is attached to that hook.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
fs/open.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/fs/open.c b/fs/open.c
index 0285ce7dbd51..7e1170863f40 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -759,6 +759,10 @@ static int do_dentry_open(struct file *f,
if (error)
goto cleanup_all;

+ error = BPF_CGROUP_RUN_PROG_FILE_FILTER(f);
+ if (error)
+ goto cleanup_all;
+
error = break_lease(locks_inode(f), f->f_flags);
if (error)
goto cleanup_all;
--
2.17.1