Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3356792imm; Fri, 20 Jul 2018 15:15:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdUcpPZVJ05Q/9Y+WBPkoyPsc6813wHqShjcZQ7qR05LNfS4oo8fd9oDS3h7YR3cni8ZTAS X-Received: by 2002:a17:902:7592:: with SMTP id j18-v6mr3594331pll.51.1532124907442; Fri, 20 Jul 2018 15:15:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532124907; cv=none; d=google.com; s=arc-20160816; b=mPVMoQhZEj45t2vXCKxotXJzmvX/UR7TJhBjEaCJC6La40dqfoj81/7aFiTid27SIE f6ezxKbhCOFn3u/OqxjIIkeCuC1isdfuxhQsR4ddxzlvNF0nwLU2ZSnOYwIoyY9qg8eL cZArtiQF6Fn/SWJfumPRfbKbqBrrgyLjlzG+82WMd7NI4McM8822ZKVERMag2cO/b3eg 5+3q4DpdRdLuVT46pqozgOzVLQPtKOBxRB/XnPzkaOegGEvxzp8nNE+WM55sxT6wiO9D DjPspCIgXFEat87ur4BrAyQid2OYGE0PHNcxRHCI+vZSTGq1BOHy1RNLsSTUT7Ni6tHS JtbA== 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:arc-authentication-results; bh=qQRO8JslV/D45SYzlaapeBo2WrE231JiOaAYPJomDFI=; b=B1ZUw4CTHdsnsapS2368tQrqciduYvzuM1mgpHHNE53LFUl/rcWljA+XBtOv1Tsc+B 9BG9Qypfz6DR/6gNWBZ4Y+nFreeJXoG6ivhP7Zi4nLdsB/cKakXODwmKtbXEE5nhXlix OHoyhWYWcM7B6xdLTmPz7O+RLTKakO28DAsHECYx/hC280UPJQw7balzGUvsQBVNhsl8 vyG6rMRzhNryrxgXYVBz1ZeJw+27eSWNQIV2Lmu4QhLKj8U9qQ7/1H9ANhZJpwg1115L ZHBr/mNV3gBzaI0XFlqR9Kf5sEx1PtXaBITNuTUTEUt0tdcv24pXf9vf21YoUkzV3p3G QXqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=VldwclZG; 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 g185-v6si2555839pgc.151.2018.07.20.15.14.52; Fri, 20 Jul 2018 15:15:07 -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=VldwclZG; 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 S1730889AbeGTXEF (ORCPT + 99 others); Fri, 20 Jul 2018 19:04:05 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:45407 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730199AbeGTXEE (ORCPT ); Fri, 20 Jul 2018 19:04:04 -0400 Received: by mail-lj1-f196.google.com with SMTP id q5-v6so12253312ljh.12 for ; Fri, 20 Jul 2018 15:13:50 -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=qQRO8JslV/D45SYzlaapeBo2WrE231JiOaAYPJomDFI=; b=VldwclZGBdR1ZrXPB39oPvY4KtbsrbHqU8Mug3uxibd5Ezp/XyixaZdAVv81kTYmIK o6gzYNh4u0y/hG3UDQaJSLMZ+zmn2qyZaUmeEiAoZ9A55ogZrG9lu00xPpdk11hoZ+wu 4TM6KzcLo6P4UjCfUcKwVTEfZvXBnlKwjhr+nYV/azEcoG5+Wzq0he29UiB+0AMfzVzh jws6dYFY5K3AdYKoW9hPnlm+VaU90sHpQECgBf4Mketb6HhZ5XIsWCJZ+acNfEKfmTbm edddnpvI4H+I/0cZXve/4VmIrCtCJgruuyjqLgpcGfz9zwVAG5Nlusvg3fqPovintxdd Ktig== 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=qQRO8JslV/D45SYzlaapeBo2WrE231JiOaAYPJomDFI=; b=ZYfy6PSYAr6lwfOiWjoTdj4pnSg2ERGyab/I16T1kNO6ljNwZ+0W+TOist7W3Chwzb X48qMk4WyV8QN2qP7jXeDv380b/q8R9/PiNtB5RivihzRdIf8PcPVg+ShaCTyl4WS66d h7v9nsBudYdhIeqWcEIM5r4nqnn/aFjzMjV4+aKBNySDaJTxs/EXrAfoPaAyFUAxvDW7 cjJbA/AU6c8xu21Xf4MNlyxLhu/twbSNrAZtxK61dCJn5a8dGXW2qtJA9+iwcpXJo6cw 1EatYK3ftkU7eBzzJYM3Lj2iK6pvEAKD6qoDXNkVHDZqBi9LUwGw3vQI70Q0zISGTU5M RtAg== X-Gm-Message-State: AOUpUlEtXFFp/U0Qeyjq/lfWFLmjDNLjNzZW9HQZVVGYR66LhNL8Xob1 cb8QSsZ+AiLZZwfsUjrYfDb9A2Yc22/LBxMXvJeW X-Received: by 2002:a2e:44c6:: with SMTP id b67-v6mr2676277ljf.102.1532124829055; Fri, 20 Jul 2018 15:13:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Paul Moore Date: Fri, 20 Jul 2018 18:13:38 -0400 Message-ID: Subject: Re: [RFC PATCH ghak90 (was ghak32) V3 02/10] audit: log container info of syscalls To: rgb@redhat.com Cc: cgroups@vger.kernel.org, containers@lists.linux-foundation.org, linux-api@vger.kernel.org, linux-audit@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, ebiederm@xmission.com, luto@kernel.org, jlayton@redhat.com, carlos@redhat.com, dhowells@redhat.com, viro@zeniv.linux.org.uk, simo@redhat.com, Eric Paris , serge@hallyn.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 Wed, Jun 6, 2018 at 1:00 PM Richard Guy Briggs wrote: > Create a new audit record AUDIT_CONTAINER 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=3D0000000000000000 cap_f= i=3D0000000000000000 cap_fe=3D0 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= =3D0000000000000000 cap_fi=3D0000000000000000 cap_fe=3D0 cap_fver=3D0 > type=3DPROCTITLE msg=3Daudit(1519924845.499:257): proctitle=3D62617368002= D6300736C65657020313B206563686F2074657374203E202F746D702F746D70636F6E746169= 6E65726964 > type=3DCONTAINER msg=3Daudit(1519924845.499:257): op=3Dtask contid=3D1234= 58 > > See: https://github.com/linux-audit/audit-kernel/issues/90 > See: https://github.com/linux-audit/audit-userspace/issues/51 > See: https://github.com/linux-audit/audit-testsuite/issues/64 > See: https://github.com/linux-audit/audit-kernel/wiki/RFE-Audit-Container= -ID > Signed-off-by: Richard Guy Briggs > --- > include/linux/audit.h | 7 +++++++ > include/uapi/linux/audit.h | 1 + > kernel/audit.c | 23 +++++++++++++++++++++++ > kernel/auditsc.c | 3 +++ > 4 files changed, 34 insertions(+) ... > --- a/include/uapi/linux/audit.h > +++ b/include/uapi/linux/audit.h > @@ -115,6 +115,7 @@ > #define AUDIT_REPLACE 1329 /* Replace auditd if this packet = unanswerd */ > #define AUDIT_KERN_MODULE 1330 /* Kernel Module events */ > #define AUDIT_FANOTIFY 1331 /* Fanotify access decision */ > +#define AUDIT_CONTAINER 1332 /* Container ID */ I'm not sure I'm completely sold on the AUDIT_CONTAINER_ID and AUDIT_CONTAINER record type names. From what I can tell AUDIT_CONTAINER_ID seems to be used for audit container ID management operations, e.g. setting the ID, whereas the AUDIT_CONTAINER is used to tag events with the corresponding audit container ID. Assuming that is correct, it seems like AUDIT_CONTAINER might be better served if it was named AUDIT_CONTAINER_ID and if we could change AUDIT_CONTAINER_ID to AUDIT_CONTAINER_OP/MGMT/etc. Thoughts? > #define AUDIT_AVC 1400 /* SE Linux avc denial or grant *= / > #define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */ > diff --git a/kernel/audit.c b/kernel/audit.c > index e7478cb..5e150c6 100644 > --- a/kernel/audit.c > +++ b/kernel/audit.c > @@ -2048,6 +2048,29 @@ 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 > + * @tsk: task to be recorded > + * @context: task or local context for record > + * @op: contid string description > + */ > +int audit_log_contid(struct task_struct *tsk, > + struct audit_context *context, char *op) > +{ > + struct audit_buffer *ab; > + > + if (!audit_contid_set(tsk)) > + return 0; > + /* Generate AUDIT_CONTAINER record with container ID */ > + ab =3D audit_log_start(context, GFP_KERNEL, AUDIT_CONTAINER); > + if (!ab) > + return -ENOMEM; > + audit_log_format(ab, "op=3D%s contid=3D%llu", > + op, audit_get_contid(tsk)); Can you explain your reason for including an "op" field in this record type? I've been looking at the rest of the patches in this patchset and it seems to be used more as an indicator of the record's generating context rather than any sort of audit container ID operation. > + audit_log_end(ab); > + return 0; > +} -- paul moore www.paul-moore.com