From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiri Olsa Subject: Re: [RFC] bpf: Emit audit messages upon successful prog load and unload Date: Wed, 4 Dec 2019 16:26:49 +0100 Message-ID: <20191204152649.GB15573@krava> References: <20191128091633.29275-1-jolsa@kernel.org> <20191203093837.GC17468@krava> <20191204140827.GB12431@krava> 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 Wed, Dec 04, 2019 at 09:38:10AM -0500, Paul Moore wrote: SNIP > > + > > +static const char * const bpf_audit_str[] =3D { > > + [BPF_AUDIT_LOAD] =3D "LOAD", > > + [BPF_AUDIT_UNLOAD] =3D "UNLOAD", > > +}; > > + > > +static void bpf_audit_prog(const struct bpf_prog *prog, enum bpf_audit= op) > > +{ > > + struct audit_context *ctx =3D NULL; > > + struct audit_buffer *ab; > > + > > + if (audit_enabled =3D=3D AUDIT_OFF) > > + return; > > + if (op =3D=3D BPF_AUDIT_LOAD) > > + ctx =3D audit_context(); > > + ab =3D audit_log_start(ctx, GFP_ATOMIC, AUDIT_BPF); > > + if (unlikely(!ab)) > > + return; > > + audit_log_format(ab, "prog-id=3D%u op=3D%s", > > + prog->aux->id, bpf_audit_str[op]); > > + audit_log_end(ab); > > +} >=20 > As mentioned previously, I still think it might be a good idea to > ensure "op" is within the bounds of bpf_audit_str, but the audit bits > look reasonable to me. ok, I'll add that, I'll send out full patch thanks for the review, jirka