Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1371491ybt; Sat, 27 Jun 2020 06:24:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNcvtCoYYxdw7VADVILkPLzcF1d/M6W5vBbFEKzZnB74kHOueXx2tFFgUA2vLkSzcvi2yc X-Received: by 2002:a50:c8c9:: with SMTP id k9mr8176073edh.157.1593264263641; Sat, 27 Jun 2020 06:24:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593264263; cv=none; d=google.com; s=arc-20160816; b=P9WQ3HXd2pW3LecOI99h0EfO3e2Ovy3wLJqWCP1kK8fpH2WGcBi/L/I8OKeznqETKn XeRi8gco9X0wrM/5/ZCZ3IzmxNEXdzWaaXjM0kqDFvEudHo+7WpSdCGGNsYSFsKT1Imp wlM/p+1fSPRw7teN0rkm0KaUZLk1f8FUoSvAN4a/SMduBuPgutEd7X0kyJp1F8055G47 4A2djsWpBmjRdAW0PkI9ksusikpPdTG9gckkP30zEuooHkkVvLl/jWT2/pm2t+T7/Axi DsxeVdQ1B4FxSYvgG5MpDrUQia9cvGISnGAvmlACXaYZfdtIEJmiLDJnms4YQF5PSjLX 8pdg== 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:dkim-signature; bh=tPpITunFHHYrcdgkS8NMc5qG45e+XjOoU0/iyAqJAFs=; b=xgg7+2zFISfbqrl0WSphJ7iUHbyMg1rCxnXrRKYb0GMh9kjjzUd/vcO1QzwHEABmvK 4mSOFVcPjXsfK1relTGtCFQ3cn2Bz/Xw42o+JRk6OUiWEphJe5BTL9PA/3WH84efG+sj fTMRHcaR6a5Lp989UU071Tk00GT1eOg6YSHLhezjx7MeU8RwJfLWcfgkD6E90sALZOoU 7T4mayPaZldfbwyG1S9snANwmPzTtI9xOZNf7Ut0Q7v6YWxukdNpPDnBRzvAgYgn4NRx F0C6DGlRhjHvFOG1I+nUckaSbewH/c9iYIjH3rqF6pY9XfU9hWbSqdsff7PU/2NJtnye Iugw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TeaK9T3q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m16si12194119eji.77.2020.06.27.06.23.59; Sat, 27 Jun 2020 06:24:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TeaK9T3q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726854AbgF0NXC (ORCPT + 99 others); Sat, 27 Jun 2020 09:23:02 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:40164 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726819AbgF0NXB (ORCPT ); Sat, 27 Jun 2020 09:23:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593264180; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:in-reply-to: references:references:references; bh=tPpITunFHHYrcdgkS8NMc5qG45e+XjOoU0/iyAqJAFs=; b=TeaK9T3qGT9ZsBjmbBKAsI6NEimUpGzyAWHpKsSVtKXOdHbY955XXqN3V8yOYqoiPB6amg G2K+Hf9hRJhzlq3lwTvcI4GNOP4yQQp9E/fiv6qyFoHKqW1eTRSbpNWeKG8dEmlmC/WKmJ r+hDEew+tJA49vLcXx1Q1Vt6Gse8lso= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-282-qHRZtAcSO1e6JqqbOV4o6Q-1; Sat, 27 Jun 2020 09:22:58 -0400 X-MC-Unique: qHRZtAcSO1e6JqqbOV4o6Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 985B680058A; Sat, 27 Jun 2020 13:22:56 +0000 (UTC) Received: from madcap2.tricolour.ca (unknown [10.10.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5413C71662; Sat, 27 Jun 2020 13:22:45 +0000 (UTC) From: Richard Guy Briggs To: 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 Cc: Paul Moore , sgrubb@redhat.com, omosnace@redhat.com, dhowells@redhat.com, simo@redhat.com, eparis@parisplace.org, serge@hallyn.com, ebiederm@xmission.com, nhorman@tuxdriver.com, dwalsh@redhat.com, mpatel@redhat.com, Richard Guy Briggs Subject: [PATCH ghak90 V9 08/13] audit: add containerid support for user records Date: Sat, 27 Jun 2020 09:20:41 -0400 Message-Id: <4a5019ed3cfab416aeb6549b791ac6d8cc9fb8b7.1593198710.git.rgb@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add audit container identifier auxiliary record to user event standalone records. Signed-off-by: Richard Guy Briggs Acked-by: Neil Horman Reviewed-by: Ondrej Mosnacek --- kernel/audit.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index 54dd2cb69402..997c34178ee8 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -1212,12 +1212,6 @@ static void audit_log_common_recv_msg(struct audit_context *context, audit_log_task_context(*ab); } -static inline void audit_log_user_recv_msg(struct audit_buffer **ab, - u16 msg_type) -{ - audit_log_common_recv_msg(NULL, ab, msg_type); -} - int is_audit_feature_set(int i) { return af.features & AUDIT_FEATURE_TO_MASK(i); @@ -1486,6 +1480,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) err = audit_filter(msg_type, AUDIT_FILTER_USER); if (err == 1) { /* match or error */ char *str = data; + struct audit_context *context; + struct audit_contobj *cont; err = 0; if (msg_type == AUDIT_USER_TTY) { @@ -1493,7 +1489,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) if (err) break; } - audit_log_user_recv_msg(&ab, msg_type); + context = audit_alloc_local(GFP_KERNEL); + audit_log_common_recv_msg(context, &ab, msg_type); if (msg_type != AUDIT_USER_TTY) { /* ensure NULL termination */ str[data_len - 1] = '\0'; @@ -1507,6 +1504,14 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) audit_log_n_untrustedstring(ab, str, data_len); } audit_log_end(ab); + rcu_read_lock(); + cont = _audit_contobj_get(current); + rcu_read_unlock(); + audit_log_container_id(context, cont); + rcu_read_lock(); + _audit_contobj_put(cont); + rcu_read_unlock(); + audit_free_context(context); } break; case AUDIT_ADD_RULE: -- 1.8.3.1