Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6899277ybi; Wed, 29 May 2019 15:17:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzp+27UorWJ8KqNWPGZlcANysL20axXw2hWfBKj6GhkxEGOWyrLhxC9xM5q+4ehS8AA+6CX X-Received: by 2002:a63:1e62:: with SMTP id p34mr342954pgm.49.1559168271536; Wed, 29 May 2019 15:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559168271; cv=none; d=google.com; s=arc-20160816; b=z1zHqnSezXx3NjC9sY0ip6JURhsmQ+UQa9M2h139aqtcy0hysfXQ/b3inKCk38i0dq 7NpJkjfbk/Th6GEJKERk2u/0sC2zF/QEfm3zKdqb/Pr49CdS8GNeGVpIzTHvRQwmLmv9 +Pw4OggDKF1oHs0Er6IXi+sx+5OiFG8O4S9xxaEN8DO0T6XNEP2bWtHkP5BiB4kUBBwx 6h01OLwGOs1GPwIzBtTylMpbAaH+HoXdTYkLX26dN8blchWVMoCkO4ktIKyG/p3Yi2AM ulvok6lqZxkJnac/yyARecdMXca+uS6rBZ29OYcJo4fDmQrRxKn1iUvbXPeXGfR/OIzz 0tqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6zFd/+GKbjIaLT3OCgZNCCS2BROhgWZzYWnXfsPDAOI=; b=XZo+7HofzdxpwW7LkvEtP2g/q7BH3MFBFu6JyIVkT2N+hU09Ry6TdtJTExQXmw9gC1 n5OyZ6JbJwfeMlrVuf5nMABIdcgX1tlNa7n/tVNn/yWhLuFnFEp2gMjJsVxmkqT8R5Bc ldzbXQ4AJAUoPag5MZpxY0q8Sd/x7nxqlnjyCIL3zNjUnMp94yuvFQaGYsmOOtXsKnLp 47yON54Y1pwTMb0x6G4Xs/FkxC6fuVsTeqsQRK7ugu7RdAyom+va+GnMW3EZ5UXNKydQ DSQ3Nq0oL3kL+Nu0DiZYJnyZC7LxsIgYxuVh4GVfI3WoQAJmSsTXrL4aMpbCXYXPo+zY 2dWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b="WAja/FZQ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7si1029746pgi.408.2019.05.29.15.17.35; Wed, 29 May 2019 15:17:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b="WAja/FZQ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726761AbfE2WPq (ORCPT + 99 others); Wed, 29 May 2019 18:15:46 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:38317 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726439AbfE2WPo (ORCPT ); Wed, 29 May 2019 18:15:44 -0400 Received: by mail-lj1-f193.google.com with SMTP id o13so4089889lji.5 for ; Wed, 29 May 2019 15:15:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=6zFd/+GKbjIaLT3OCgZNCCS2BROhgWZzYWnXfsPDAOI=; b=WAja/FZQE2pFEgnKhl94IfcY8BDGBWqmDZ/K0LwYCwgZZCNgvoTkUHQRuwP3YNgoya z1f4MJuRSEu/GyirKTd7ZxEucg9gwE45Fe167cp9Gbt6SxK1m/9DrrJu7NRrAZY32bla 4p+eAFjbcp/9ChooQBY5FdmhiTSlOm5fiQ0RSbq2XomUdeG6vZOenF9TaeHTaq3oDL83 qHIT7T9Tcnfjs24oWWuvmRTPwH/ItgW4sLZxfljRcoBxDQ9Bb5BU8OKhEHtCsIEsk1yT MLqbkKb1a/gLfm9HlkJSnjDqX1VSLIKoT+vVxZCZOOatOa32W60AfV4fnv3pVeojRmLW 1+wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=6zFd/+GKbjIaLT3OCgZNCCS2BROhgWZzYWnXfsPDAOI=; b=gCeHqjg12UbLx/PSk0kFsHqwfwTihmWAeJcp5hbf8GPW8wwTSmBzdaKnrINX1VGXQ+ t44S1f39zS4qzMkyKZZuumGtty24g6DPH29fZoZiR6Gpq2NAWJX9T5ghORtdT9km6M60 pjUmFyvy7fOf9ktD/ImdZr9EhW4KSipQPEK/e8qmRm4063J1kPis5anVTpwxgnRsRoEH 108iqqeFDt8GILiTpJK0CKQa2fCRI2SkS5+zKxqsE6tSXfi5rhAK16Kvqwz+VfNfAD4B GnerRsT59Ra+8xzZFMynyJyAv0NrOrL06J7ITGFFDu8dxG29tSz+1rsRAodk9++Wudik qwmw== X-Gm-Message-State: APjAAAVGRo8lobngYfW8JDDAor3tKQ8i0ptFZBlijdDEATD3aKHDU+p3 4DpxXDPNyxzGRkJQK1JhNwosrsps0MaQIJUMJKc1 X-Received: by 2002:a2e:92cc:: with SMTP id k12mr132567ljh.16.1559168142045; Wed, 29 May 2019 15:15:42 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Paul Moore Date: Wed, 29 May 2019 18:15:30 -0400 Message-ID: Subject: Re: [PATCH ghak90 V6 04/10] audit: log container info of syscalls To: Richard Guy Briggs Cc: containers@lists.linux-foundation.org, linux-api@vger.kernel.org, Linux-Audit Mailing List , linux-fsdevel@vger.kernel.org, LKML , netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, sgrubb@redhat.com, omosnace@redhat.com, dhowells@redhat.com, simo@redhat.com, Eric Paris , Serge Hallyn , ebiederm@xmission.com, nhorman@tuxdriver.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 8, 2019 at 11:40 PM Richard Guy Briggs wrote: > > Create a new audit record AUDIT_CONTAINER_ID to document the audit > container identifier of a process if it is present. > > Called from audit_log_exit(), syscalls are covered. > > A sample raw event: > type=3DSYSCALL msg=3Daudit(1519924845.499:257): arch=3Dc000003e syscall= =3D257 success=3Dyes exit=3D3 a0=3Dffffff9c a1=3D56374e1cef30 a2=3D241 a3= =3D1b6 items=3D2 ppid=3D606 pid=3D635 auid=3D0 uid=3D0 gid=3D0 euid=3D0 sui= d=3D0 fsuid=3D0 egid=3D0 sgid=3D0 fsgid=3D0 tty=3Dpts0 ses=3D3 comm=3D"bash= " exe=3D"/usr/bin/bash" subj=3Dunconfined_u:unconfined_r:unconfined_t:s0-s0= :c0.c1023 key=3D"tmpcontainerid" > type=3DCWD msg=3Daudit(1519924845.499:257): cwd=3D"/root" > type=3DPATH msg=3Daudit(1519924845.499:257): item=3D0 name=3D"/tmp/" inod= e=3D13863 dev=3D00:27 mode=3D041777 ouid=3D0 ogid=3D0 rdev=3D00:00 obj=3Dsy= stem_u:object_r:tmp_t:s0 nametype=3D PARENT cap_fp=3D0 cap_fi=3D0 cap_fe=3D= 0 cap_fver=3D0 > type=3DPATH msg=3Daudit(1519924845.499:257): item=3D1 name=3D"/tmp/tmpcon= tainerid" inode=3D17729 dev=3D00:27 mode=3D0100644 ouid=3D0 ogid=3D0 rdev= =3D00:00 obj=3Dunconfined_u:object_r:user_tmp_t:s0 nametype=3DCREATE cap_fp= =3D0 cap_fi=3D0 cap_fe=3D0 cap_fver=3D0 > type=3DPROCTITLE msg=3Daudit(1519924845.499:257): proctitle=3D62617368002= D6300736C65657020313B206563686F2074657374203E202F746D702F746D70636F6E746169= 6E65726964 > type=3DCONTAINER_ID msg=3Daudit(1519924845.499:257): contid=3D123458 > > Please see the github audit kernel issue for the main feature: > https://github.com/linux-audit/audit-kernel/issues/90 > Please see the github audit userspace issue for supporting additions: > https://github.com/linux-audit/audit-userspace/issues/51 > Please see the github audit testsuiite issue for the test case: > https://github.com/linux-audit/audit-testsuite/issues/64 > Please see the github audit wiki for the feature overview: > https://github.com/linux-audit/audit-kernel/wiki/RFE-Audit-Container-ID > Signed-off-by: Richard Guy Briggs > Acked-by: Serge Hallyn > Acked-by: Steve Grubb > Acked-by: Neil Horman > Reviewed-by: Ondrej Mosnacek > --- > include/linux/audit.h | 5 +++++ > include/uapi/linux/audit.h | 1 + > kernel/audit.c | 20 ++++++++++++++++++++ > kernel/auditsc.c | 20 ++++++++++++++------ > 4 files changed, 40 insertions(+), 6 deletions(-) ... > diff --git a/kernel/audit.c b/kernel/audit.c > index 182b0f2c183d..3e0af53f3c4d 100644 > --- a/kernel/audit.c > +++ b/kernel/audit.c > @@ -2127,6 +2127,26 @@ void audit_log_session_info(struct audit_buffer *a= b) > audit_log_format(ab, "auid=3D%u ses=3D%u", auid, sessionid); > } > > +/* > + * audit_log_contid - report container info > + * @context: task or local context for record > + * @contid: container ID to report > + */ > +void audit_log_contid(struct audit_context *context, u64 contid) > +{ > + struct audit_buffer *ab; > + > + if (!audit_contid_valid(contid)) > + return; > + /* Generate AUDIT_CONTAINER_ID record with container ID */ > + ab =3D audit_log_start(context, GFP_KERNEL, AUDIT_CONTAINER_ID); > + if (!ab) > + return; > + audit_log_format(ab, "contid=3D%llu", (unsigned long long)contid)= ; We have a consistency problem regarding how to output the u64 contid values; this function uses an explicit cast, others do not. According to Documentation/core-api/printk-formats.rst the recommendation for u64 is %llu (or %llx, if you want hex). Looking quickly through the printk code this appears to still be correct. I suggest we get rid of the cast (like it was in v5). > + audit_log_end(ab); > +} > +EXPORT_SYMBOL(audit_log_contid); -- paul moore www.paul-moore.com