From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93EF6C2BD09 for ; Wed, 4 Dec 2019 15:27:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 69FE7207DD for ; Wed, 4 Dec 2019 15:27:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Kw8wYTx6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728256AbfLDP1G (ORCPT ); Wed, 4 Dec 2019 10:27:06 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:28335 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728350AbfLDP1E (ORCPT ); Wed, 4 Dec 2019 10:27:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575473223; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2lwIXgMuS4fQPvhpFYE841g9Z0lJi8SuqMdlRhxoWcs=; b=Kw8wYTx6/XJlW/3KfAbXjHi9ONbStjIYT5TfyO2EQCl4YNRU7nvETmZgUpW3lDAScdKO7i WXdYUZGSYvo4Ndlts6LMqN4wzdnzr4+y8nH/A7SPgoCS9D9kEUBrENLY1gjvnMc6QjkkDt KB7Xd17acSdIT6w+RK/iJ+qIEMJS4Vo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-203-NDKHiQmrMOiWI_VHJOLqbg-1; Wed, 04 Dec 2019 10:27:00 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 960F6802566; Wed, 4 Dec 2019 15:26:58 +0000 (UTC) Received: from krava (ovpn-204-212.brq.redhat.com [10.40.204.212]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E54610246E3; Wed, 4 Dec 2019 15:26:51 +0000 (UTC) Date: Wed, 4 Dec 2019 16:26:49 +0100 From: Jiri Olsa 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 Subject: Re: [RFC] bpf: Emit audit messages upon successful prog load and unload Message-ID: <20191204152649.GB15573@krava> References: <20191128091633.29275-1-jolsa@kernel.org> <20191203093837.GC17468@krava> <20191204140827.GB12431@krava> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: NDKHiQmrMOiWI_VHJOLqbg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org 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