Received: by 10.213.65.68 with SMTP id h4csp261226imn; Fri, 16 Mar 2018 02:11:05 -0700 (PDT) X-Google-Smtp-Source: AG47ELtFCOIjcZhG0EOqrDhe2fcNfFXBm6vvLuoDyeXJqnbEkWNTaCL/EqP2QXFxa6wfiLoGADxI X-Received: by 2002:a17:902:a9c7:: with SMTP id b7-v6mr1281357plr.190.1521191465512; Fri, 16 Mar 2018 02:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521191465; cv=none; d=google.com; s=arc-20160816; b=kKg28dXa3gv9nLk0wKJywtk86tE189v2DU2uls7lA76tUTBvBvZbNOkbmgyNeQRwJ6 zgwwgpDtJ1SlB0v0ZHetXaZqYUdQ+0fMs7vZEJXcHzDLYp4ah4znrIdFm/7Nk/7X8Zkx GUbZLwE/lTJRzQFq+i1SgrF0Nmt659oUqG70a+68I/U3FhAi4MLKsVGEKPUg7YqKGW0H xMlZMKyPijF6RDzYeBz3Jya0dWNqMpAYSBgZSWEXwo5lJiVlkyrDoaOXd9MYMN0BHp3P xrLqLTcgQos648AKKl/o/dg7AcvyXMqYiKgjl0K5PbQHjM4lSMgph4Uwo7K+jI9CgwS0 ZH4Q== 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=4DvBXDiQ+12ESm5yVKf+gIru9caJaOLYUgDWH0UiyXY=; b=hVAlLbom3DgJ1rguzu7xTJcMG3E4vulaiXw9NuBQ+m6aNQdCyAhuXDH70bqBkv0dn9 wlMTx6q390/LhVpDS7jplMeAJ7GA/cospmwbMThxBlDDjAmaqkBQsflb99Eq6ErAchN7 8s3JyPPkGCZdJdP/h94demb9cWArxkf5UgDjG2Uu6Q3xRZMkQ48lStExv7EjN0d4RPzt xNkZohOmktiQ+WU/m+uDFiDsE586sY5xLTJ5UWd447o7KWuFAcEZVJHkIfcHWQ3ttCQO QPqN9O5xxSidPB7lHm08UvDHNuS9a5uxP2BNvhotwtTtJEwYTM89HMotdyuxsXUEqBVm q2Xw== 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 y131si5254114pfg.44.2018.03.16.02.10.51; Fri, 16 Mar 2018 02:11:05 -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; 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 S1752421AbeCPJGx (ORCPT + 99 others); Fri, 16 Mar 2018 05:06:53 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51404 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751724AbeCPJGt (ORCPT ); Fri, 16 Mar 2018 05:06:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B896E401DE7F; Fri, 16 Mar 2018 09:06:48 +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 5F6E110B00A2; Fri, 16 Mar 2018 09:06:45 +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: luto@kernel.org, jlayton@redhat.com, carlos@redhat.com, viro@zeniv.linux.org.uk, dhowells@redhat.com, simo@redhat.com, eparis@parisplace.org, serge@hallyn.com, ebiederm@xmission.com, madzcar@gmail.com, Richard Guy Briggs Subject: [RFC PATCH ghak32 V2 07/13] audit: add container aux record to watch/tree/mark Date: Fri, 16 Mar 2018 05:00:34 -0400 Message-Id: <737f914a88d048b9985984c0ce1f946c30ca374c.1521179281.git.rgb@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 16 Mar 2018 09:06:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 16 Mar 2018 09:06:48 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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 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; - 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(); - 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