Received: by 10.223.185.116 with SMTP id b49csp7826774wrg; Thu, 1 Mar 2018 11:49:21 -0800 (PST) X-Google-Smtp-Source: AG47ELuretOpAoKbbiWU3kkc94iykRGV+N1jsLzht6VWVCYCVllyF3gefPFfZvsbQW1hpkJXnRxF X-Received: by 10.99.140.85 with SMTP id q21mr2385471pgn.51.1519933761301; Thu, 01 Mar 2018 11:49:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519933761; cv=none; d=google.com; s=arc-20160816; b=g6FFPsSJIzezWeqTMLSldrm6RGAlj0IlJI3YSYP6WjxGtqRRac16p3EYlovhSBUPGH luHLZft8RIHF2Aq0GhbeWsvdnUxoINWSsxKEeSj/34aPeEk/zVinCqySdHAhFfK+6yVF oBx+MSO6x4rhBmOkLncpNfdQ7XoiY6lssI3bgUPvX5j5E12H2DSrk47tu3cYU8F8Debb argNVM51HgBMMBJ18ciS3521fX1CKZ0qfiUTEdeWF/fsS98XuIc5GbEOYC5cX5KtQ/IX 4+xelcU03t4TjWbn4Kvw5NCjOSFCLIqoAd5EFVpwgpU7BmB6B4QG3HNFSxopvx1JpEA2 NmeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=0S1lNEEwzJ435mLZhU5tQawrwQck6E57LFz0PJzQH7g=; b=TZS/XFoQOBmpsg9KBaYGodkeykOM/ZJ2nxXT2624VRC02bKDcsMXD3Sn+AFCDA+JG0 xefY1rVj8THje65O+qLy/1IXNQ/lkzqHljeRVcaYuoeF8h+42UCcBLL/y97uet0yEeiv 1yReDcfiTVljk41sQEKhhGi/8t2RUqM0NWdfQpvpgNYdu/ndBT4Cpvt9MhB9cL/VKBR5 0acP2013zCozJv57/8TgGnK2G2dM+YaZr9gvGx9zFkMEF5Z+KvB18YcmGnvkpHRohbqP 0w/Drl5MLwIRYd1n4XG7R0gjnEClPzD/oZNrnNqzV40C1YlgrAh/YRIQu6Q35lV9F+Of 7opQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1-v6si3462793pld.322.2018.03.01.11.49.06; Thu, 01 Mar 2018 11:49:21 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161467AbeCATrC (ORCPT + 99 others); Thu, 1 Mar 2018 14:47:02 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42468 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1034175AbeCATq7 (ORCPT ); Thu, 1 Mar 2018 14:46:59 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 88A0681638F1; Thu, 1 Mar 2018 19:46:58 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-12.rdu2.redhat.com [10.10.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AE279C070; Thu, 1 Mar 2018 19:46:55 +0000 (UTC) From: Richard Guy Briggs To: 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 Cc: mszeredi@redhat.com, luto@kernel.org, jlayton@redhat.com, carlos@redhat.com, viro@zeniv.linux.org.uk, dhowells@redhat.com, simo@redhat.com, trondmy@primarydata.com, eparis@parisplace.org, serge@hallyn.com, ebiederm@xmission.com, madzcar@gmail.com, Richard Guy Briggs Subject: [RFC PATCH V1 07/12] audit: add container aux record to watch/tree/mark Date: Thu, 1 Mar 2018 14:41:10 -0500 Message-Id: <6c071b3e4fbe848ccd692c7dc27c9f75589852c0.1519930146.git.rgb@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 01 Mar 2018 19:46:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 01 Mar 2018 19:46:58 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rgb@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add container ID information to mark, watch and tree rule 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; - 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 fd35312..2ad85d4 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(); - 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; + + 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); } /* Update inode info in audit rules based on filesystem event. */ -- 1.8.3.1