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: Thu, 28 Nov 2019 10:18:12 +0100 Message-ID: <20191128091812.GC1209@krava> References: <20191128091633.29275-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: <20191128091633.29275-1-jolsa@kernel.org> Content-Disposition: inline Sender: netdev-owner@vger.kernel.org To: Jiri Olsa Cc: 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 , Paul Moore , Eric Paris , Jiri Benc List-Id: linux-audit@redhat.com On Thu, Nov 28, 2019 at 10:16:32AM +0100, Jiri Olsa wrote: > From: Daniel Borkmann >=20 > Allow for audit messages to be emitted upon BPF program load and > unload for having a timeline of events. The load itself is in > syscall context, so additional info about the process initiating > the BPF prog creation can be logged and later directly correlated > to the unload event. >=20 > The only info really needed from BPF side is the globally unique > prog ID where then audit user space tooling can query / dump all > info needed about the specific BPF program right upon load event > and enrich the record, thus these changes needed here can be kept > small and non-intrusive to the core. >=20 > Raw example output: >=20 > # auditctl -D > # auditctl -a always,exit -F arch=3Dx86_64 -S bpf > # ausearch --start recent -m 1334 > ... > ---- > time->Wed Nov 27 16:04:13 2019 > type=3DPROCTITLE msg=3Daudit(1574867053.120:84664): proctitle=3D"./bpf" > type=3DSYSCALL msg=3Daudit(1574867053.120:84664): arch=3Dc000003e sysca= ll=3D321 \ > success=3Dyes exit=3D3 a0=3D5 a1=3D7ffea484fbe0 a2=3D70 a3=3D0 items= =3D0 ppid=3D7477 \ > pid=3D12698 auid=3D1001 uid=3D1001 gid=3D1001 euid=3D1001 suid=3D1001= fsuid=3D1001 \ > egid=3D1001 sgid=3D1001 fsgid=3D1001 tty=3Dpts2 ses=3D4 comm=3D"bpf" = \ > exe=3D"/home/jolsa/auditd/audit-testsuite/tests/bpf/bpf" = \ > subj=3Dunconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=3D(n= ull) > type=3DUNKNOWN[1334] msg=3Daudit(1574867053.120:84664): prog-id=3D76 op= =3DLOAD > ---- > time->Wed Nov 27 16:04:13 2019 > type=3DUNKNOWN[1334] msg=3Daudit(1574867053.120:84665): prog-id=3D76 op= =3DUNLOAD > ... >=20 > Signed-off-by: Daniel Borkmann > Co-developed-by: Jiri Olsa > Signed-off-by: Jiri Olsa fyi I prepared userspace changes: https://github.com/olsajiri/audit-userspace/commit/3108a81fa8d937f07b4c78= be8ae00fcd3d64f94d https://github.com/olsajiri/audit-testsuite/commit/16888ea7f14fa0269feef6= 23d2a96f15f9ea71c9 I'll sumbit github PRs once the kernel change is pulled in thanks, jirka