Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp906432ybl; Thu, 23 Jan 2020 09:54:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxtwcr6nde6mOhi8DshaI02N2hCUkrV6SEloX5aambHgqbD/QFy0rSWzh4edpjA5mFrsZox X-Received: by 2002:aca:ec4f:: with SMTP id k76mr10781414oih.156.1579802091624; Thu, 23 Jan 2020 09:54:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579802091; cv=none; d=google.com; s=arc-20160816; b=jlMJOr913c+Vpo0jj+pp7f1DdAeEaqSvhNeXsOJJPxoE4H8jCzdF7awbtkD7hcqjW0 GeHcd5ZOYk7o02bgJYUzoUFZqpnY2YkhXp5d9YmcgriyQlXj69LXb6ZIUYfrDfwOk/1W KiXLvivfX1rfJANO4M89snrnvB87Enwp6QRMzUfEdce9G5AClZQEROQaxLM1jYtRM0bl V9jm2N1QLFeSUUUwh4HhUOh2DiFQrs1I3txoDr0EBBNkWWg1g1FO/8wHBx2570amHizg awJ+WzG5C8ohjU/+iIgpwtSCLQyMcYtWLnJbAtXEaWxO/VVZDWKMjZpinKeserhcQX1B bUgg== 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=EoI0l4kaWTQec4tn5Ld9ZCvI5RqFAqp9PrVGXBLYlGE=; b=TEK37iVXUKzy7e+AhDuyEarNRJvvCBvz2WyAoiutzJFyvHJSnbHk1VoXQ3vQDPCL34 0R79W45tWaRBkZy482msGxmLHzLJSjrizA2TZGjDMLneRi9H/X/GWUwHWzUdptgv68mf EVzVtJ4fO4+sTOEYrTNHNsxQcdSl6gTe9AFdIL67S6bpIcy3VZpoCKVbZyPlDOYfPkNP Mc2b+af1szCcSuqtyqbPihinMSwL1gB0reSc6asFOXSqydr0lLUdTijzCKLkajUvcTxZ UPcICnlosx0yJkUSPUTZ2RlrvdftDFFRkTmr54FT2TIQFh76aBWD/vEGxKKOE+eUEcbJ aslA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=fVFhxuuC; 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 u84si1173568oib.34.2020.01.23.09.54.39; Thu, 23 Jan 2020 09:54:51 -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=fVFhxuuC; 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 S1729224AbgAWRJT (ORCPT + 99 others); Thu, 23 Jan 2020 12:09:19 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45889 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729225AbgAWRJS (ORCPT ); Thu, 23 Jan 2020 12:09:18 -0500 Received: by mail-lj1-f194.google.com with SMTP id j26so4312015ljc.12 for ; Thu, 23 Jan 2020 09:09:16 -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=EoI0l4kaWTQec4tn5Ld9ZCvI5RqFAqp9PrVGXBLYlGE=; b=fVFhxuuC85CKWEXjWPZjUwe+E2ZvU24vSAIadJBa+Ft9IRArNmW35Swl+jhyL4SbSw Q9y1gY0sctni33PC0OvsTEp15m3qeF+Ox4KoeaR1j1bfiGK/un6S52NDn4Mmp7JZyTWN T4+GcR/uluwB+tQB+fNDYzVWf25RKz6Wf9cz/hgquK9Jxf67xA/gq61Jlji6pBo0BW1h pphNci+Itjc9Hy6EK728qegKSUWTqi4toMGOqpiG4FTi4ZVSa3Pyo+WL4giv/emjl4KZ N+8QV2duNaLjezM2vWW4tbJ2IqC9/1zcehqsTVQU1Cz0GaYOg/ae7LEcFoRy5LtZ74Xo fKgg== 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=EoI0l4kaWTQec4tn5Ld9ZCvI5RqFAqp9PrVGXBLYlGE=; b=uGxsduJMb+zCMbvu5mfQphw+PgJsABBRYDgKBpza+ysUcp5kXQZQRrDfR6yZi2wxWg DSj0S5r13m4RW+qtJUe/YNrR6UVqSJ48OM5JmVdWZIcBvW+cYhxHSheyppA210E7+Gi5 cFP1CNi6U9Fh5ZE2jGNlNdgqUwHnhxtohO6Dza/acPp5N6DTDrkhyWxqtBm1iYusdF1A H2S2ouE8p41aEhuPuRgu9N8rO3bhNfCe0tKijBLVoDhtBFH5kNHtIa6H33KaeEUWkfSM c4GcM81XhRlyQVQwmx89RgOF1pCc6D/ABj6V1RedUX0w7Ag9I5HdeR2Iq0hs2pVjwxDQ 1LFg== X-Gm-Message-State: APjAAAXVYIvUgwd1LZIssgdC0mHCg3kHhPYqo5t4h56rac0ZgBrLCa95 0TgNQWciXYyl5FU+EcGLSFeSNOqsZa680Xutmxdj X-Received: by 2002:a2e:9f52:: with SMTP id v18mr23988656ljk.30.1579799355718; Thu, 23 Jan 2020 09:09:15 -0800 (PST) MIME-Version: 1.0 References: <7d7933d742fdf4a94c84b791906a450b16f2e81f.1577736799.git.rgb@redhat.com> <20200123162918.b3jbed7tbvr2sf2p@madcap2.tricolour.ca> In-Reply-To: <20200123162918.b3jbed7tbvr2sf2p@madcap2.tricolour.ca> From: Paul Moore Date: Thu, 23 Jan 2020 12:09:04 -0500 Message-ID: Subject: Re: [PATCH ghak90 V8 07/16] audit: add contid support for signalling the audit daemon To: Richard Guy Briggs Cc: 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, sgrubb@redhat.com, omosnace@redhat.com, dhowells@redhat.com, simo@redhat.com, Eric Paris , Serge Hallyn , ebiederm@xmission.com, nhorman@tuxdriver.com, Dan Walsh , mpatel@redhat.com 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 Thu, Jan 23, 2020 at 11:29 AM Richard Guy Briggs wrote: > On 2020-01-22 16:28, Paul Moore wrote: > > On Tue, Dec 31, 2019 at 2:50 PM Richard Guy Briggs wrote: > > > > > > Add audit container identifier support to the action of signalling the > > > audit daemon. > > > > > > Since this would need to add an element to the audit_sig_info struct, > > > a new record type AUDIT_SIGNAL_INFO2 was created with a new > > > audit_sig_info2 struct. Corresponding support is required in the > > > userspace code to reflect the new record request and reply type. > > > An older userspace won't break since it won't know to request this > > > record type. > > > > > > Signed-off-by: Richard Guy Briggs > > > --- > > > include/linux/audit.h | 7 +++++++ > > > include/uapi/linux/audit.h | 1 + > > > kernel/audit.c | 35 +++++++++++++++++++++++++++++++++++ > > > kernel/audit.h | 1 + > > > security/selinux/nlmsgtab.c | 1 + > > > 5 files changed, 45 insertions(+) > > > > ... > > > > > diff --git a/kernel/audit.c b/kernel/audit.c > > > index 0871c3e5d6df..51159c94041c 100644 > > > --- a/kernel/audit.c > > > +++ b/kernel/audit.c > > > @@ -126,6 +126,14 @@ struct auditd_connection { > > > kuid_t audit_sig_uid = INVALID_UID; > > > pid_t audit_sig_pid = -1; > > > u32 audit_sig_sid = 0; > > > +/* Since the signal information is stored in the record buffer at the > > > + * time of the signal, but not retrieved until later, there is a chance > > > + * that the last process in the container could terminate before the > > > + * signal record is delivered. In this circumstance, there is a chance > > > + * the orchestrator could reuse the audit container identifier, causing > > > + * an overlap of audit records that refer to the same audit container > > > + * identifier, but a different container instance. */ > > > +u64 audit_sig_cid = AUDIT_CID_UNSET; > > > > I believe we could prevent the case mentioned above by taking an > > additional reference to the audit container ID object when the signal > > information is collected, dropping it only after the signal > > information is collected by userspace or another process signals the > > audit daemon. Yes, it would block that audit container ID from being > > reused immediately, but since we are talking about one number out of > > 2^64 that seems like a reasonable tradeoff. > > I had thought that through and should have been more explicit about that > situation when I documented it. We could do that, but then the syscall > records would be connected with the call from auditd on shutdown to > request that signal information, rather than the exit of that last > process that was using that container. This strikes me as misleading. > Is that really what we want? ??? I think one of us is not understanding the other; maybe it's me, maybe it's you, maybe it's both of us. Anyway, here is what I was trying to convey with my original comment ... When we record the audit container ID in audit_signal_info() we take an extra reference to the audit container ID object so that it will not disappear (and get reused) until after we respond with an AUDIT_SIGNAL_INFO2. In audit_receive_msg() when we do the AUDIT_SIGNAL_INFO2 processing we drop the extra reference we took in audit_signal_info(). Unless I'm missing some other change you made, this *shouldn't* affect the syscall records, all it does is preserve the audit container ID object in the kernel's ACID store so it doesn't get reused. (We do need to do some extra housekeeping in audit_signal_info() to deal with the case where nobody asks for AUDIT_SIGNAL_INFO2 - basically if audit_sig_cid is not NULL we should drop a reference before assigning it a new object pointer, and of course we would need to set audit_sig_cid to NULL in audit_receive_msg() after sending it up to userspace and dropping the extra ref.) -- paul moore www.paul-moore.com