From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexei Starovoitov Subject: [PATCH bpf-next 2/6] fs: wire in BPF_CGROUP_FILE_OPEN hook Date: Wed, 3 Oct 2018 19:57:46 -0700 Message-ID: <20181004025750.498303-3-ast@kernel.org> References: <20181004025750.498303-1-ast@kernel.org> Mime-Version: 1.0 Content-Type: text/plain Cc: , , , , , To: "David S . Miller" Return-path: Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:42760 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727209AbeJDJtF (ORCPT ); Thu, 4 Oct 2018 05:49:05 -0400 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w942oJCm011991 for ; Wed, 3 Oct 2018 19:57:58 -0700 Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2mw83r0bkm-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 03 Oct 2018 19:57:58 -0700 In-Reply-To: <20181004025750.498303-1-ast@kernel.org> Sender: netdev-owner@vger.kernel.org List-ID: 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 --- 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