Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp160861imu; Thu, 3 Jan 2019 16:30:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN7RWbY1NTzKUcjxIya+hl0Px9OaPGE0unmml1jNYRl7oEKDEMtirMOOcFcbmLW7fn0I0+FZ X-Received: by 2002:a63:b0a:: with SMTP id 10mr18954811pgl.423.1546561815977; Thu, 03 Jan 2019 16:30:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546561815; cv=none; d=google.com; s=arc-20160816; b=C048LsXrhAv0vhF9j/Hts10NC7BkvUKxA7ScHDcySjB7JOChImk1Z2lbO/vciXnUlX 37sWBXwCrJWDBdRjVVPiwR6wn2JPFV7caUdn0BLv5ebgyGZgpVAyAmQRjsfRkJzoHbyQ OUnN6R1hPWTn+Ht9kCEiPUIGaotZrsMa33jyYWZ7ups40hWf6xmue2kRerWGp5/aH4lm Ab0OF6gXQpgPVRstWZsgUe85dKRutg2Tc3wXqDlA1WI/RK7L/7jcJG3nY63V2hf+GJ+O bR8RrnG+xmdqbShNMvZoyU/gC1YyL7m9GEqJf2D5nZ8fM82aWYYT98Wf3eI5O67i5pfZ 4tVw== 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; bh=AuxKHbU9FA81XXd/F2+f249n1iltP9iaImAvKk/KBLo=; b=b0QRjqFE06vD0jCirkhtsrZ4TEg6+7h9+XONFicPrhALOPizvbbXn/tMjHVQ3gdm1z I9QeFbNMTzvZeMR+g6StDp4jEQ9zUQ9V0n47BsmTAL0+Z32+/Sx/gGvjdqfvDe0HxHA4 HxMpu76dAr02dIf5bgsKm1x3kGwGf5QQWRs+IYwFpWO6LuVpcJjXFxEPKATytLLC4Yeq Yd/gP8iqBOSDDT93HX8f1HYBiqczccCMC7UNKvKT0g9ksX1UBYfeKHHGKMMV5echwkaq wbRDZ4GBSDqZS+X/04Dlq+Yl+wUePPKEWviHwltwnpsGvwplq7Ngb8tUQpxLBN0csESH gDtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=0KAh+OAm; 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 e37si49257523plb.172.2019.01.03.16.30.00; Thu, 03 Jan 2019 16:30:15 -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; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=0KAh+OAm; 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 S1727766AbfACULh (ORCPT + 99 others); Thu, 3 Jan 2019 15:11:37 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:34481 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726601AbfACULg (ORCPT ); Thu, 3 Jan 2019 15:11:36 -0500 Received: by mail-lf1-f68.google.com with SMTP id p6so24061889lfc.1 for ; Thu, 03 Jan 2019 12:11:34 -0800 (PST) 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=AuxKHbU9FA81XXd/F2+f249n1iltP9iaImAvKk/KBLo=; b=0KAh+OAmbN8yvt0xS91hvxVkI/GT4U+/eNqcFSohWk1CO80gzWSEIdCc6OA9VvrQSO ajzz55bAfdPLsdZwIlNf4YcbydC3FNiuX1+fQ9N6nMAkaBSqm+SwKDdAF9PqVGuak7fM A57SFO7j3/Oo4FT7396yd8+ZMjHzZvP7IJD5WGV0uQFbgesFzdC8JmlY6jP0AORFBKKD t7cDNtEVaDQta03x3WO6522MLw/hrdYS+MvLW4kKlWpvMehW/+CvKvSJpahYiAgwpG75 4GaIudkMf5GQq3Qc2xWXT8IdSyD05UBYXD0+OH1kf9hGyBnaxARkSXfT3mBTfaVF8aKd uVnw== 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=AuxKHbU9FA81XXd/F2+f249n1iltP9iaImAvKk/KBLo=; b=TbhPVRFdTlaEj++d0AfUU5/bNfklGm4Tqrrh8ved6XJ/jNjp4qQC2IDpzk9cGZi/Dl mtOoMBdSwss//R7DANbGCt/39iDhqlDmBf0JvS4jXl6ptQI+uM4wjFdJIr//m2PuZOPS uzuQxWlh01Yiv4Gq+0YgwGdZgVh0QEcEIhHfJIzJOoQRD0AGecyfGxysl6vwv6cM34Gd rXE5cuxPezLsXOZAHB6Zl8y0GxIJWewBjfClUaFT/wl+NW6EYPb34S/1U7bU7GcV/Z4r rnLhUv5et0phfllmU23dcDL22jYR/XInBwGqHXkF+dUGfPyz64z7z9xpv3UwfLGbUATO TZcw== X-Gm-Message-State: AA+aEWawDp5RVjm20qo6jD5g4DFVFO+llHGXqI7bJc84SAruAYdQCilC 2R7SvAwyKAAk+qQciSCon1gF9/uxkFGc4SZ/sj72 X-Received: by 2002:a19:a7c1:: with SMTP id q184mr22852635lfe.4.1546546293731; Thu, 03 Jan 2019 12:11:33 -0800 (PST) MIME-Version: 1.0 References: <20181031211739.6jag6b5qve77qmmu@madcap2.tricolour.ca> In-Reply-To: <20181031211739.6jag6b5qve77qmmu@madcap2.tricolour.ca> From: Paul Moore Date: Thu, 3 Jan 2019 15:11:22 -0500 Message-ID: Subject: Re: [PATCH ghak90 (was ghak32) V4 06/10] audit: add containerid support for tty_audit To: Richard Guy Briggs Cc: containers@lists.linux-foundation.org, linux-audit@redhat.com, linux-kernel@vger.kernel.org, ebiederm@xmission.com, luto@kernel.org, carlos@redhat.com, dhowells@redhat.com, viro@zeniv.linux.org.uk, simo@redhat.com, Eric Paris , Serge Hallyn 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 Wed, Oct 31, 2018 at 5:17 PM Richard Guy Briggs wrote: > On 2018-10-19 19:17, Paul Moore wrote: > > On Sun, Aug 5, 2018 at 4:33 AM Richard Guy Briggs wrote: > > > Add audit container identifier auxiliary record to tty logging rule > > > event standalone records. > > > > > > Signed-off-by: Richard Guy Briggs > > > Acked-by: Serge Hallyn > > > --- > > > drivers/tty/tty_audit.c | 5 ++++- > > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c > > > index 50f567b..3e21477 100644 > > > --- a/drivers/tty/tty_audit.c > > > +++ b/drivers/tty/tty_audit.c > > > @@ -66,8 +66,9 @@ static void tty_audit_log(const char *description, dev_t dev, > > > uid_t uid = from_kuid(&init_user_ns, task_uid(tsk)); > > > uid_t loginuid = from_kuid(&init_user_ns, audit_get_loginuid(tsk)); > > > unsigned int sessionid = audit_get_sessionid(tsk); > > > + struct audit_context *context = audit_alloc_local(GFP_KERNEL); > > > > > > - ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_TTY); > > > + ab = audit_log_start(context, GFP_KERNEL, AUDIT_TTY); > > > if (ab) { > > > char name[sizeof(tsk->comm)]; > > > > > > @@ -80,6 +81,8 @@ static void tty_audit_log(const char *description, dev_t dev, > > > audit_log_n_hex(ab, data, size); > > > audit_log_end(ab); > > > } > > > + audit_log_contid(context, "tty", audit_get_contid(tsk)); > > > + audit_free_context(context); > > > } > > > > Since I never polished up my task_struct/current fix patch enough to > > get it past RFC status during this development window (new job, stolen > > laptop, etc.) *and* it looks like you are going to need at least one > > more respin of this patchset, go ahead and fix this patch to use > > current instead of generating a local context. I'll deal with the > > merge fallout if/when it happens. > > Sure, I will switch it to current in the call to audit_get_contid(). > > The local context is a distinct issue. Like USER records, I prefer > local due to potential record volume, it is already trackable as far as > Steve is concerned, and if it is to be connected with the syscall > record, it should be linked to syscall records in a seperate new github > issue with its own patch. It accumulates events until the buffer is > flushed to a record, so the timestamp only represents the flush (usually > user "CR/enter"). Generally, yes, associating records is a separate issue, but in this particular case you are changing this record by making it a "local" record, which as we've discussed before, I view as a necessary evil and something that must be minimized. A quick look at the tty_audit_log() callers shows tty_audit_tiocsti() which is an ioctl handler (and thus current should be valid and correct), and tty_audit_buf_push() whose callers all seem have valid and correct current values; if you find that not to be the case please let me know. > > Local contexts are a last resort. If you ever find yourself writing > > code that generates a local context, you should first be 100% certain > > that the event is not the the result of a process initiated action (in > > which case it should take from the task's context). > > Well, I'm 100% certain it is linked to a process, but so are USER > records that are already being discussed as the exception. This is > basically a keystroke logger (that has a flag to omit passwords). -- paul moore www.paul-moore.com