From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiri Olsa Subject: Re: [PATCHv2] bpf: Emit audit messages upon successful prog load and unload Date: Fri, 6 Dec 2019 22:27:46 +0100 Message-ID: <20191206212746.GA30691@krava> References: <20191205102552.19407-1-jolsa@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: Content-Disposition: inline Sender: netdev-owner@vger.kernel.org To: Paul Moore Cc: Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-audit@redhat.com, Andrii Nakryiko , Yonghong Song , Martin KaFai Lau , Jakub Kicinski , Steve Grubb , David Miller , Eric Paris , Jiri Benc List-Id: linux-audit@redhat.com On Fri, Dec 06, 2019 at 04:11:13PM -0500, Paul Moore wrote: SNIP > > > > #define IS_FD_ARRAY(map) ((map)->map_type =3D=3D BPF_MAP_TYPE_PERF_EVE= NT_ARRAY || \ > > @@ -1306,6 +1307,36 @@ static int find_prog_type(enum bpf_prog_type typ= e, struct bpf_prog *prog) > > return 0; > > } > > > > +enum bpf_audit { > > + BPF_AUDIT_LOAD, > > + BPF_AUDIT_UNLOAD, > > + BPF_AUDIT_MAX, > > +}; > > + > > +static const char * const bpf_audit_str[BPF_AUDIT_MAX] =3D { > > + [BPF_AUDIT_LOAD] =3D "LOAD", > > + [BPF_AUDIT_UNLOAD] =3D "UNLOAD", > > +}; > > + > > +static void bpf_audit_prog(const struct bpf_prog *prog, unsigned int o= p) > > +{ > > + struct audit_context *ctx =3D NULL; > > + struct audit_buffer *ab; > > + > > + if (audit_enabled =3D=3D AUDIT_OFF) > > + return; > > + if (WARN_ON_ONCE(op >=3D BPF_AUDIT_MAX)) > > + return; >=20 > I feel bad saying this given the number of revisions we are at with > this patch, but since we aren't even at -rc1 yet (although it will be > here soon), I'm going to mention it anyway ;) >=20 > ... if we move the "op >=3D BPF_AUDIT_MAX" above the audit_enabled check > we will catch problems sooner in development, which is a very good > thing as far as I'm concerned. sure, np will post v3 >=20 > Other than that, this looks good to me, and I see Steve has already > given the userspace portion a thumbs-up. Have you started on the > audit-testsuite test for this yet? yep, it's ready.. waiting for kernel change ;-) https://github.com/olsajiri/audit-testsuite/commit/16888ea7f14fa0269feef623= d2a96f15f9ea71c9 jirka