Received: by 10.192.165.156 with SMTP id m28csp80480imm; Wed, 18 Apr 2018 17:45:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/c6m14P4aKNo7aLoeY1AK3ZBOzDJRtZy2w4fKPCkuRKwXrwXGdk6opNbwuDwq/YfyZb8Lx X-Received: by 10.99.117.2 with SMTP id q2mr3433937pgc.248.1524098719540; Wed, 18 Apr 2018 17:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524098719; cv=none; d=google.com; s=arc-20160816; b=RmSk9Djv9ZtOt/YL138JdtlAP0QGTJMMIXean4HhcUMPyrTBTVpE+gdawB2R8WXjTH EAjLIeL9qZQ8r46vsZFDVBE5HuKCm8cODD8rUTBjQ2vKsqtuGCNSCXobnYY3F7Q8qf/d rrIADwCJke054FCg7wOj/mCi3RQQ6UygQX6mtnvhPhsEiBv4GX+dyvigyCEJfxzH+HLs /z0m725eg4fT0/MQUBa9LihBqLnzrTGdKOA2ojdsT/uAaUgj2CXSDQtR6NDY3h1cqv3o yAs/+G+cm47Y/tvBW+/hyI4mNc3Mw7DyHJbdiwf7EZRyCJvpCO0UyDHuZikhDF0a50pI Uchw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=v2130Rwkt5V/lqLvIGBzplFEuVHe4QQNvD4kog4USUo=; b=vN9Td+AHaCGah8+niQh9Ed949N8mLMz4URnHmvCYu6DKSo+ohJMkZps9RekPyc+yok /+yAuwsIYKNhbNQxjFMSKXAaNYhfqYxzP8qG2mAFJ/dwiy4B5mVIr6iO8sthT/tH4J3g 3j3m350Sq7RBhApLz9YU6F8C+/cI3aRzc9IPN/sAj+jbGhO09sT1jmcRkpGzUTR0d2Vu I7YnM/FpV2dvYBbUMYSn64xoDcvlWXVvIvIG+/9DQQ8JU6x1EEM22vSUf0vocIgExdhz IkBsx8phBm63DzcbRNqx+VT5OsVOXEQU6JGzumjDXprktd8U2fHH+h9VvFIbU4pCOCy4 eZyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=Jfo2FwDH; 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 o1si1981529pga.523.2018.04.18.17.45.05; Wed, 18 Apr 2018 17:45:19 -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=Jfo2FwDH; 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 S1753187AbeDSAms (ORCPT + 99 others); Wed, 18 Apr 2018 20:42:48 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:43621 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752907AbeDSAmp (ORCPT ); Wed, 18 Apr 2018 20:42:45 -0400 Received: by mail-lf0-f68.google.com with SMTP id v207-v6so5225051lfa.10 for ; Wed, 18 Apr 2018 17:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=v2130Rwkt5V/lqLvIGBzplFEuVHe4QQNvD4kog4USUo=; b=Jfo2FwDHHVbjSCMGDuKqFlRfboSy48An9d+JnA8T89t6rT5D6XK4e2PBc/T7tDUEZl 4eth/1VomBRCxIhF6IZEQvyKgwDkZDi/qj9uM9U73w1h/yKZmVMnRx13Z6KBNR5QvyeK R891iA91Tv/OZRkmaWspL0Pw1lSI5/lM1B3S8Pnli0YijpqGTuTQhrY4cUeL027Ujudg QXJq0+3l1AX3JlvhvCd7jrSIs5JjS8FcEYr5GTR5AW7YjeZbEhGjP1dDZz4IcANnEO0X sUMYuylR5sKzxcokBWaJjfMs4SmG9BSDRq6L7m8UVwGITgz5yjOLtcq4/mQq5MkXIxeq +Lfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=v2130Rwkt5V/lqLvIGBzplFEuVHe4QQNvD4kog4USUo=; b=AE5jpAkFGyT8pEoDImZtzvS40GHHrKThfCuFfa+v/+2iXc5/HO0WzwngdNuLfIgIGi SUnoGwi8rXdyunteZj+Vp6JkIiSmGfnkgScp+oW5PFmfikOAWoP7VuQuXeE0ZNqOKq2H zGN0OSr5bfr17k0TJCUsvP0zEDJlqc7K+dkiV6EOqaDUgRukEnNLNrMwWrg/KeH89cCl qks7L9shuMq+cXccnRH4+pNm3bcXQa5XQpfpb8AWjl8N4fqZ9+Ucw8TWHd/tocI6dZKh A87oh1pLRsgUwgnfD8VvM8j9TQM+LGRF74YW+pY0hVhYp148TOj5hU+bt97GlGdu5swi HiRg== X-Gm-Message-State: ALQs6tAuekda3ltctFWq5S7R5MPvJAjK369V2DF3aPwjGcBSZdSpSQTX f/lwOiG4exa3T58ncg5S7REZYH90RhF994AGJGs5 X-Received: by 10.46.157.210 with SMTP id x18mr2606186ljj.135.1524098563928; Wed, 18 Apr 2018 17:42:43 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:a5c3:0:0:0:0:0 with HTTP; Wed, 18 Apr 2018 17:42:43 -0700 (PDT) X-Originating-IP: [108.20.156.165] In-Reply-To: <737f914a88d048b9985984c0ce1f946c30ca374c.1521179281.git.rgb@redhat.com> References: <737f914a88d048b9985984c0ce1f946c30ca374c.1521179281.git.rgb@redhat.com> From: Paul Moore Date: Wed, 18 Apr 2018 20:42:43 -0400 Message-ID: Subject: Re: [RFC PATCH ghak32 V2 07/13] audit: add container aux record to watch/tree/mark To: Richard Guy Briggs Cc: cgroups@vger.kernel.org, containers@lists.linux-foundation.org, linux-api@vger.kernel.org, Linux-Audit Mailing List , linux-fsdevel@vger.kernel.org, LKML , 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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 16, 2018 at 5:00 AM, Richard Guy Briggs wrote: > Add container ID auxiliary record to mark, watch and tree rule > configuration standalone records. > > Signed-off-by: Richard Guy Briggs > --- > kernel/audit_fsnotify.c | 5 ++++- > kernel/audit_tree.c | 5 ++++- > kernel/audit_watch.c | 33 +++++++++++++++++++-------------- > 3 files changed, 27 insertions(+), 16 deletions(-) > > diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c > index 52f368b..18c110d 100644 > --- a/kernel/audit_fsnotify.c > +++ b/kernel/audit_fsnotify.c > @@ -124,10 +124,11 @@ static void audit_mark_log_rule_change(struct audit_fsnotify_mark *audit_mark, c > { > struct audit_buffer *ab; > struct audit_krule *rule = audit_mark->rule; > + struct audit_context *context = audit_alloc_local(); > > if (!audit_enabled) > return; Move the audit_alloc_local() after the audit_enabled check. > - ab = audit_log_start(NULL, GFP_NOFS, AUDIT_CONFIG_CHANGE); > + ab = audit_log_start(context, GFP_NOFS, AUDIT_CONFIG_CHANGE); > if (unlikely(!ab)) > return; > audit_log_format(ab, "auid=%u ses=%u op=%s", > @@ -138,6 +139,8 @@ static void audit_mark_log_rule_change(struct audit_fsnotify_mark *audit_mark, c > audit_log_key(ab, rule->filterkey); > audit_log_format(ab, " list=%d res=1", rule->listnr); > audit_log_end(ab); > + audit_log_container_info(context, "config", audit_get_containerid(current)); > + audit_free_context(context); > } > > void audit_remove_mark(struct audit_fsnotify_mark *audit_mark) > diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c > index 67e6956..7c085be 100644 > --- a/kernel/audit_tree.c > +++ b/kernel/audit_tree.c > @@ -496,8 +496,9 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) > static void audit_tree_log_remove_rule(struct audit_krule *rule) > { > struct audit_buffer *ab; > + struct audit_context *context = audit_alloc_local(); Sort of independent of the audit container ID work, but shouldn't we have an audit_enabled check here? > - ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE); > + ab = audit_log_start(context, GFP_KERNEL, AUDIT_CONFIG_CHANGE); > if (unlikely(!ab)) > return; > audit_log_format(ab, "op=remove_rule"); > @@ -506,6 +507,8 @@ static void audit_tree_log_remove_rule(struct audit_krule *rule) > audit_log_key(ab, rule->filterkey); > audit_log_format(ab, " list=%d res=1", rule->listnr); > audit_log_end(ab); > + audit_log_container_info(context, "config", audit_get_containerid(current)); > + audit_free_context(context); > } > > static void kill_rules(struct audit_tree *tree) > diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c > index 9eb8b35..60d75a2 100644 > --- a/kernel/audit_watch.c > +++ b/kernel/audit_watch.c > @@ -238,20 +238,25 @@ static struct audit_watch *audit_dupe_watch(struct audit_watch *old) > > static void audit_watch_log_rule_change(struct audit_krule *r, struct audit_watch *w, char *op) > { > - if (audit_enabled) { > - struct audit_buffer *ab; > - ab = audit_log_start(NULL, GFP_NOFS, AUDIT_CONFIG_CHANGE); > - if (unlikely(!ab)) > - return; > - audit_log_format(ab, "auid=%u ses=%u op=%s", > - from_kuid(&init_user_ns, audit_get_loginuid(current)), > - audit_get_sessionid(current), op); > - audit_log_format(ab, " path="); > - audit_log_untrustedstring(ab, w->path); > - audit_log_key(ab, r->filterkey); > - audit_log_format(ab, " list=%d res=1", r->listnr); > - audit_log_end(ab); > - } > + struct audit_buffer *ab; > + struct audit_context *context = audit_alloc_local(); > + > + if (!audit_enabled) > + return; Same as above, do the allocation after the audit_enabled check. > + ab = audit_log_start(context, GFP_NOFS, AUDIT_CONFIG_CHANGE); > + if (unlikely(!ab)) > + return; > + audit_log_format(ab, "auid=%u ses=%u op=%s", > + from_kuid(&init_user_ns, audit_get_loginuid(current)), > + audit_get_sessionid(current), op); > + audit_log_format(ab, " path="); > + audit_log_untrustedstring(ab, w->path); > + audit_log_key(ab, r->filterkey); > + audit_log_format(ab, " list=%d res=1", r->listnr); > + audit_log_end(ab); > + audit_log_container_info(context, "config", audit_get_containerid(current)); > + audit_free_context(context); > } -- paul moore www.paul-moore.com