Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6232502imm; Mon, 23 Jul 2018 14:02:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcYWDKDanHQ19qkcdRgCbXu0Q48soSfOSSNwBktKDZoNaEdT+oM8I4DvOqPiHGEMZ15kkO8 X-Received: by 2002:a62:47c4:: with SMTP id p65-v6mr15016600pfi.170.1532379740420; Mon, 23 Jul 2018 14:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532379740; cv=none; d=google.com; s=arc-20160816; b=GP2wPaXTAmaUF1cT5IJYJeyzDb2+vnP7UbsoF7tdtC15ZYc+MCyPusizDvuiRTTd/G sffjcGicGGxD1fezNDE+L8KFnkUyeuTWWNlX60HqYGnyP6xwlSEH/InUu2jF5NkgDByI iQTQsRdLitluKwr/sMWgmWUr13Y6tIKEPPbI2YMCEo0WTOJQ/0Ep/nfQI7GzWWpH5y9l LEN21aZNQG28yRz022b6RhiJDzXkgGjpJKqiYPP2LJOWrbceEU1MDlpiWxt/o6ONzePD fwplt0uvaE3fUkEVtepVPF+mZrtT/L0+jhobw4rfDPb5XxN1qRtZ4lENXqX1AmrtST/5 3x5Q== 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 :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=IrB6alzCcsA2cBmWipaiXQNqFleBghFpiQmO4z7c78Q=; b=cq/d5u1QdfPkQkHTbm0bu3/9BdjyQNpwIPCzoUSPT2kMUYv24kQFY7NN7HlJYMpRtS ePvTHOp9CLncPCqEccI2wyxMaqJpDfuZsAwqhltWB12Uaps8gTWeZLe6xatCGgv0Xydt 9uiZlb7ESr1OYzUOKzbr3lcelpylnwpmZMFDVzZCkdUnB+nOVVtmZwABWWFdPM8UKdx2 0bvty5sPfAm92+106GNFggC1db8VLx60t8Y8Xiw4rxzFrzBST520G7cF/pHOBO3xZtDm fggoeJYHIoipPjhP/PozPYRJV200OTmt62ChRGY/WI1NzdjEgA30OW3FzaZIYPgwy5kw QeZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=LE9CRfso; 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 t128-v6si7023714pgt.614.2018.07.23.14.02.05; Mon, 23 Jul 2018 14:02:20 -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=LE9CRfso; 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 S2388192AbeGWWD4 (ORCPT + 99 others); Mon, 23 Jul 2018 18:03:56 -0400 Received: from mail-lf1-f44.google.com ([209.85.167.44]:44567 "EHLO mail-lf1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388109AbeGWWD4 (ORCPT ); Mon, 23 Jul 2018 18:03:56 -0400 Received: by mail-lf1-f44.google.com with SMTP id g6-v6so1453127lfb.11 for ; Mon, 23 Jul 2018 14:00:54 -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; bh=IrB6alzCcsA2cBmWipaiXQNqFleBghFpiQmO4z7c78Q=; b=LE9CRfso2Ot0vDgvyflvb0SKCamD+Mf+OBYE1puFllWmRDNLeLv2XJACHpFV1Sr9Je IBBX2jPzRgqMosyoMTC3Ymax/AKvBg3jP1pmlJGDgv4zqpW+AbtkQFpXXKTo1IM4lCVf T/FSD/EqmiKy9kHSOW6EQn5nlMIQyE2YXQ9avDdjZTjZtVZ6TSgRXSXRMn7FvCWgSmIl EVF/2lR/zPmSBoXUq+KCWR0OVXfwYRo8O2WdbAllTRGcGiCUchdlQ5VANU8Sh/A/v06b An9WNhDsVGyabH8qmu2MU+3bZA+EZZnamZ9kL81cUIuw0WlD6epfzRTzuVxuUpVoPOrD 6+6w== 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; bh=IrB6alzCcsA2cBmWipaiXQNqFleBghFpiQmO4z7c78Q=; b=MAQhlUi0P3JfmYpRgL5J5Wr3vyRwRpBZ5IaRejcCPm/cd5vCshql3xrJnBB6JOYt6+ xlzkKpv3H+AGE3pq8IqY5C1n0HLsfuvFzmQB/lTZWsGrFaswTmlIr02whs6/73GBJbAn QZCd1D3tEyWRSy9rVjBzU9LEf7hgGSYpuvUcpaTmlXYeYP834kUeRY+VMHQSj8w/+zZT sRYi2ew8b+FJCbd3PIs4eboQp+O6vw4BYvrFNeO5dU4/QkrZ0wxo2MC/ChFQSKwZHnmZ 1XmnmiGFcjW0ma29bSUgVHuB8/kXej19kLqmzQv+VECGmIv34fGtMWUa3pElbz+olqYr dIzQ== X-Gm-Message-State: AOUpUlGRBGurqX0oOusruep5yXDGpCL4gMHJempPRihE62TLANvsfrKh No19vaom96OFG0QxF7cEwH2fiZlZdlmL+4Obo9Dv X-Received: by 2002:a19:169f:: with SMTP id 31-v6mr8056709lfw.72.1532379653076; Mon, 23 Jul 2018 14:00:53 -0700 (PDT) MIME-Version: 1.0 References: <907e32319825bb6336a662f4f6f6d173f56f3226.1529003588.git.rgb@redhat.com> <20180712214608.ed4chli7mdc7ymin@madcap2.tricolour.ca> <20180723164035.wkazolpmpf3mvdxw@madcap2.tricolour.ca> In-Reply-To: <20180723164035.wkazolpmpf3mvdxw@madcap2.tricolour.ca> From: Paul Moore Date: Mon, 23 Jul 2018 17:00:41 -0400 Message-ID: Subject: Re: [RFC PATCH ghak59 V1 3/6] audit: exclude user records from syscall context To: rgb@redhat.com Cc: Eric Paris , linux-audit@redhat.com, linux-kernel@vger.kernel.org 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 Mon, Jul 23, 2018 at 12:43 PM Richard Guy Briggs wrote: > On 2018-07-12 17:46, Richard Guy Briggs wrote: > > On 2018-06-28 18:11, Paul Moore wrote: > > > On Thu, Jun 14, 2018 at 4:23 PM Richard Guy Briggs wrote: > > > > Since the function audit_log_common_recv_msg() is shared by a number of > > > > AUDIT_CONFIG_CHANGE and the entire range of AUDIT_USER_* record types, > > > > and since the AUDIT_CONFIG_CHANGE message type has been converted to a > > > > syscall accompanied record type, special-case the AUDIT_USER_* range of > > > > messages so they remain standalone records. > > > > > > > > See: https://github.com/linux-audit/audit-kernel/issues/59 > > > > Signed-off-by: Richard Guy Briggs > > > > --- > > > > kernel/audit.c | 12 +++++++++--- > > > > 1 file changed, 9 insertions(+), 3 deletions(-) > > > > > > I think this is fine, but see my previous comment about combining 2/6 > > > and 3/6 as a safety measure. > > > > This one I left as a seperate patch for discussion. We'd previously > > talked about connecting all possible records with syscall records if > > they exist, but this one I'm unsure about, since we don't really care > > what userspace process is issuing this message. It is just the message > > content itself that is important. Or is it? Are we concerned about > > CAP_AUDIT_WRITE holders/abusers and want as much info about them as we > > can get in case they go rogue or pear-shaped? > > I'm waiting on re-spinning this patchset because of this open question. > > Is connecting AUDIT_USER* records desirable or a liability? Like I said, I think special casing the AUDIT_USER* records so they are *not* associated with other records is okay, and perhaps even the right thing to do. The problem is that we don't have the necessary context (har har) to match any kernel events (and there is the possibility that there are none) to the userspace generated AUDIT_USER* event. Further, I don't think this is something we would ever be able to solve in a reasonable manner. > > > > diff --git a/kernel/audit.c b/kernel/audit.c > > > > index e469234..c8c2efc 100644 > > > > --- a/kernel/audit.c > > > > +++ b/kernel/audit.c > > > > @@ -1057,7 +1057,8 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type) > > > > return err; > > > > } > > > > > > > > -static void audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type) > > > > +static void __audit_log_common_recv_msg(struct audit_context *context, > > > > + struct audit_buffer **ab, u16 msg_type) > > > > { > > > > uid_t uid = from_kuid(&init_user_ns, current_uid()); > > > > pid_t pid = task_tgid_nr(current); > > > > @@ -1067,7 +1068,7 @@ static void audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type) > > > > return; > > > > } > > > > > > > > - *ab = audit_log_start(audit_context(), GFP_KERNEL, msg_type); > > > > + *ab = audit_log_start(context, GFP_KERNEL, msg_type); > > > > if (unlikely(!*ab)) > > > > return; > > > > audit_log_format(*ab, "pid=%d uid=%u", pid, uid); > > > > @@ -1075,6 +1076,11 @@ static void audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type) > > > > audit_log_task_context(*ab); > > > > } > > > > > > > > +static inline void audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type) > > > > +{ > > > > + __audit_log_common_recv_msg(audit_context(), ab, msg_type); > > > > +} > > > > + > > > > int is_audit_feature_set(int i) > > > > { > > > > return af.features & AUDIT_FEATURE_TO_MASK(i); > > > > @@ -1341,7 +1347,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) > > > > if (err) > > > > break; > > > > } > > > > - audit_log_common_recv_msg(&ab, msg_type); > > > > + __audit_log_common_recv_msg(NULL, &ab, msg_type); > > > > if (msg_type != AUDIT_USER_TTY) > > > > audit_log_format(ab, " msg='%.*s'", > > > > AUDIT_MESSAGE_TEXT_MAX, > > > > -- > > > > 1.8.3.1 > > > > > > > > > > > > > -- > > > paul moore > > > www.paul-moore.com > > > > > > -- > > > Linux-audit mailing list > > > Linux-audit@redhat.com > > > https://www.redhat.com/mailman/listinfo/linux-audit > > > > - RGB > > > > -- > > Richard Guy Briggs > > Sr. S/W Engineer, Kernel Security, Base Operating Systems > > Remote, Ottawa, Red Hat Canada > > IRC: rgb, SunRaycer > > Voice: +1.647.777.2635, Internal: (81) 32635 > > > > -- > > Linux-audit mailing list > > Linux-audit@redhat.com > > https://www.redhat.com/mailman/listinfo/linux-audit > > - RGB > > -- > Richard Guy Briggs > Sr. S/W Engineer, Kernel Security, Base Operating Systems > Remote, Ottawa, Red Hat Canada > IRC: rgb, SunRaycer > Voice: +1.647.777.2635, Internal: (81) 32635 -- paul moore www.paul-moore.com