From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14D99C388F9 for ; Wed, 28 Oct 2020 01:35:36 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 908F722249 for ; Wed, 28 Oct 2020 01:35:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=paul-moore-com.20150623.gappssmtp.com header.i=@paul-moore-com.20150623.gappssmtp.com header.b="Lj2eTMWd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 908F722249 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=paul-moore.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=containers-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 1AC508743E; Wed, 28 Oct 2020 01:35:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ENzFz3YaKYoe; Wed, 28 Oct 2020 01:35:34 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 0E2078743A; Wed, 28 Oct 2020 01:35:34 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E632EC088B; Wed, 28 Oct 2020 01:35:33 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id DB3BBC0051 for ; Wed, 28 Oct 2020 01:35:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 9642A203DC for ; Wed, 28 Oct 2020 01:35:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0VNLbwSL+ani for ; Wed, 28 Oct 2020 01:35:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ej1-f66.google.com (mail-ej1-f66.google.com [209.85.218.66]) by silver.osuosl.org (Postfix) with ESMTPS id 60BBA203CE for ; Wed, 28 Oct 2020 01:35:30 +0000 (UTC) Received: by mail-ej1-f66.google.com with SMTP id dt13so4892708ejb.12 for ; Tue, 27 Oct 2020 18:35:30 -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:content-transfer-encoding; bh=EhaQv7Xqn9C10/6kPilmFG/LY90YB69CHHSm/P4LmUk=; b=Lj2eTMWdQNRX51rp+69kJ+7MIJveC7lv8t0w/6GAwNCZDU97tO7fXzTZewOx55Ac1l qfo9NYf3w/1oZOOMsUpmk5QFBOLD6rEq4Y+xGwdcqgYSlAvt/V1eCOoLhOGtMpxn22lY BpPv8So2RSzkwV4VqW9Z81xo/sm6G/2qErp4megpsjRLRnCsLMimzT//EYKnBmWXYPYY Sljt2SxpJGW+CX70ABsj4p+oWaehsd7e48Xa9uvPlScUQdjQsFInIzQICwjOLHYNYT2Z rVKc0MWZtpSmx99XULBfKIiPaFC7zAwivfy+JYaPy+FhDaqHk6y3p83LlgRiUo5yGc2I JWSg== 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:content-transfer-encoding; bh=EhaQv7Xqn9C10/6kPilmFG/LY90YB69CHHSm/P4LmUk=; b=srQBHlphClLVvFzJbJbkgJ1ThQPlpBxpz/+3PLRCi0eCTMN0Ox/r1SGk+YLEbailvq WdusYy8ZJIMF2+0UJZpE2ug6YWPkCoyBCYz+vWBGVs9muZeK06ms9ApnQQB+h46KbmI0 W6oVvjDireuWYfHJwUaHl6m3wfuCnXJ6InsuYLXYKBZJ+RfDzN93vI1xwVLCsXS8WFnT PpCmmkUp7VI2Jhe19m0lA+bhPp+rCdmNuIK3qosQrSWIHMAlNmhGoAD/8WqJxxEee9nY O+MHVwFnW2MhowjOiayDgN/wNLPffnOvao4ZfkJAOCz0yE43z5tbqW4w/Rlkq9SyI/M/ nZTg== X-Gm-Message-State: AOAM530L0KVDoDqjvppUenS0W77nFtR3LxeelWep8PN9vpTXittvTUVa zf+KecJiBPeezM5vRK6lv/LDFsBK/6MHhhzllZbk X-Google-Smtp-Source: ABdhPJydImqf6rjIcFvdKoVKRijlUJM6c3tT5+zpyIh0DgksT/WwCUJmb9M0MAWnaqlVZBE1LbPiRD1v+2NmrHAlBa8= X-Received: by 2002:a17:906:4811:: with SMTP id w17mr4982322ejq.431.1603848928683; Tue, 27 Oct 2020 18:35:28 -0700 (PDT) MIME-Version: 1.0 References: <6e2e10432e1400f747918eeb93bf45029de2aa6c.1593198710.git.rgb@redhat.com> <20200729194058.kcbsqjhzunjpipgm@madcap2.tricolour.ca> <20201002195231.GH2882171@madcap2.tricolour.ca> <20201021163926.GA3929765@madcap2.tricolour.ca> <20201023204033.GI2882171@madcap2.tricolour.ca> In-Reply-To: <20201023204033.GI2882171@madcap2.tricolour.ca> From: Paul Moore Date: Tue, 27 Oct 2020 21:35:17 -0400 Message-ID: Subject: Re: [PATCH ghak90 V9 05/13] audit: log container info of syscalls To: Richard Guy Briggs Cc: nhorman@tuxdriver.com, linux-api@vger.kernel.org, containers@lists.linux-foundation.org, LKML , dhowells@redhat.com, Linux-Audit Mailing List , netfilter-devel@vger.kernel.org, ebiederm@xmission.com, simo@redhat.com, netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, Eric Paris , mpatel@redhat.com X-BeenThere: containers@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux Containers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: containers-bounces@lists.linux-foundation.org Sender: "Containers" On Fri, Oct 23, 2020 at 4:40 PM Richard Guy Briggs wrote: > On 2020-10-22 21:21, Paul Moore wrote: > > On Wed, Oct 21, 2020 at 12:39 PM Richard Guy Briggs wrote: > > > Here is an exmple I was able to generate after updating the testsuite > > > script to include a signalling example of a nested audit container > > > identifier: > > > > > > ---- > > > type=PROCTITLE msg=audit(2020-10-21 10:31:16.655:6731) : proctitle=/usr/bin/perl -w containerid/test > > > type=CONTAINER_ID msg=audit(2020-10-21 10:31:16.655:6731) : contid=7129731255799087104^3333941723245477888 > > > type=OBJ_PID msg=audit(2020-10-21 10:31:16.655:6731) : opid=115583 oauid=root ouid=root oses=1 obj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 ocomm=perl > > > type=CONTAINER_ID msg=audit(2020-10-21 10:31:16.655:6731) : contid=3333941723245477888 > > > type=OBJ_PID msg=audit(2020-10-21 10:31:16.655:6731) : opid=115580 oauid=root ouid=root oses=1 obj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 ocomm=perl > > > type=CONTAINER_ID msg=audit(2020-10-21 10:31:16.655:6731) : contid=8098399240850112512^3333941723245477888 > > > type=OBJ_PID msg=audit(2020-10-21 10:31:16.655:6731) : opid=115582 oauid=root ouid=root oses=1 obj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 ocomm=perl > > > type=SYSCALL msg=audit(2020-10-21 10:31:16.655:6731) : arch=x86_64 syscall=kill success=yes exit=0 a0=0xfffe3c84 a1=SIGTERM a2=0x4d524554 a3=0x0 items=0 ppid=115564 pid=115567 auid=root uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=ttyS0 ses=1 comm=perl exe=/usr/bin/perl subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=testsuite-1603290671-AcLtUulY > > > ---- > > > > > > There are three CONTAINER_ID records which need some way of associating with OBJ_PID records. An additional CONTAINER_ID record would be present if the killing process itself had an audit container identifier. I think the most obvious way to connect them is with a pid= field in the CONTAINER_ID record. > > > > Using a "pid=" field as a way to link CONTAINER_ID records to other > > records raises a few questions. What happens if/when we need to > > represent those PIDs in the context of a namespace? Are we ever going > > to need to link to records which don't have a "pid=" field? I haven't > > done the homework to know if either of these are a concern right now, > > but I worry that this might become a problem in the future. > > Good point about PID namespaces in the future but those accompanying > records will already have to be conditioned for the PID namespace > context that is requesting it, so I don't see this as a showstopper. Possibly, it just gets very messy. Doubly so when you start looking at potentially adjusting for multiple audit daemons. Thankfully it doesn't look like using the PID is a good idea for other reasons. > I've forgotten about an important one we already hit, which is a network > event that only has a NETFILTER_PKT record, but in that case, there is > no ambiguity since there are no other records associated with that > event. So the second is already an issue now. Using > task_tgid_nr(current), in the contid testsuite script network event it > attributed it to ping which caused the event, but we cannot use this > since it wasn't triggered by a syscall and doesn't accurately reflect > the kernel thread that received it. It could just be set to zero for > network events. Possibly. It just seems like too much hackery to start; that's the stuff you do once it has been in a kernel release for years and need to find a workaround that doesn't break everything. I think we should aim a bit higher right now. > > The idea of using something like "item=" is interesting. As you > > mention, the "item=" field does present some overlap problems with the > > PATH record, but perhaps we can do something similar. What if we > > added a "record=" (or similar, I'm not worried about names at this > > point) to each record, reset to 0/1 at the start of each event, and > > when we needed to link records somehow we could add a "related=1,..,N" > > field. This would potentially be useful beyond just the audit > > container ID work. > > Does it make any sense to use the same keyword in each type of record > such as record/records as in PATH/SYSCALL: item/items ? That was mentioned above, if you can assure yourself and the rest of us that it can be safely reused I think that might be okay, but I'm not convinced that is safe at the moment. Although I will admit those are fears are not based on an exhaustive search through the code (or a determined "think"). > (I prefer 0-indexed like item=...) I have no preference on where we start the index, but it makes sense to keep the same index starting point as the PATH records. -- paul moore www.paul-moore.com _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/containers From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=3.0 tests=BAYES_00,DATE_IN_PAST_12_24, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21F21C388F7 for ; Wed, 28 Oct 2020 23:33:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B94EE207BC for ; Wed, 28 Oct 2020 23:33:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore-com.20150623.gappssmtp.com header.i=@paul-moore-com.20150623.gappssmtp.com header.b="Lj2eTMWd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390511AbgJ1XdT (ORCPT ); Wed, 28 Oct 2020 19:33:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725885AbgJ1XbN (ORCPT ); Wed, 28 Oct 2020 19:31:13 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83FC9C0613CF for ; Wed, 28 Oct 2020 16:31:13 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id b1so939195lfp.11 for ; Wed, 28 Oct 2020 16:31:13 -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:content-transfer-encoding; bh=EhaQv7Xqn9C10/6kPilmFG/LY90YB69CHHSm/P4LmUk=; b=Lj2eTMWdQNRX51rp+69kJ+7MIJveC7lv8t0w/6GAwNCZDU97tO7fXzTZewOx55Ac1l qfo9NYf3w/1oZOOMsUpmk5QFBOLD6rEq4Y+xGwdcqgYSlAvt/V1eCOoLhOGtMpxn22lY BpPv8So2RSzkwV4VqW9Z81xo/sm6G/2qErp4megpsjRLRnCsLMimzT//EYKnBmWXYPYY Sljt2SxpJGW+CX70ABsj4p+oWaehsd7e48Xa9uvPlScUQdjQsFInIzQICwjOLHYNYT2Z rVKc0MWZtpSmx99XULBfKIiPaFC7zAwivfy+JYaPy+FhDaqHk6y3p83LlgRiUo5yGc2I JWSg== 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:content-transfer-encoding; bh=EhaQv7Xqn9C10/6kPilmFG/LY90YB69CHHSm/P4LmUk=; b=N8xlzn1ytvaCJNatccpDiK4EgYIQecWs7gTfLp+1vmDOjDmxi70bbGJ7DT+ELL/42/ Ah5yFwnsGjiaHrxf+glGGE5Hb+rh5USxl2p/jLCG3CgmdnCeRokqjMzznaFF1HrQg3d9 iIk1Qcro8cPqalRJyP7r6T2q3/jR9pdNOmhH06J50L1y0JkLHb6HB0VU5pSY8B2BvTtz bkkRJC4KP4YM+tbjQ4pE05F2ZZ4+SmE6U2sOLFzEk8Fv3IZ85g9yKimYhW9MfvRse70m 1/0uQi7rtaBKh1MN9WP2D7nEhI0WHITSMal/lFYcSwfFttunIZinmYWQb0zpfe4i9kcz zDaw== X-Gm-Message-State: AOAM530wnxftTPFV/X2Lcg0NZ1aIlG1MC8SBdmSfXV4/zewNHG6oh82E Hso7Q5J06H4U9gqzki4OmHY2w/6fSg1UPSkoNYHXlkpv2w== X-Google-Smtp-Source: ABdhPJydImqf6rjIcFvdKoVKRijlUJM6c3tT5+zpyIh0DgksT/WwCUJmb9M0MAWnaqlVZBE1LbPiRD1v+2NmrHAlBa8= X-Received: by 2002:a17:906:4811:: with SMTP id w17mr4982322ejq.431.1603848928683; Tue, 27 Oct 2020 18:35:28 -0700 (PDT) MIME-Version: 1.0 References: <6e2e10432e1400f747918eeb93bf45029de2aa6c.1593198710.git.rgb@redhat.com> <20200729194058.kcbsqjhzunjpipgm@madcap2.tricolour.ca> <20201002195231.GH2882171@madcap2.tricolour.ca> <20201021163926.GA3929765@madcap2.tricolour.ca> <20201023204033.GI2882171@madcap2.tricolour.ca> In-Reply-To: <20201023204033.GI2882171@madcap2.tricolour.ca> From: Paul Moore Date: Tue, 27 Oct 2020 21:35:17 -0400 Message-ID: Subject: Re: [PATCH ghak90 V9 05/13] audit: log container info of syscalls To: Richard Guy Briggs Cc: nhorman@tuxdriver.com, linux-api@vger.kernel.org, containers@lists.linux-foundation.org, LKML , dhowells@redhat.com, Linux-Audit Mailing List , netfilter-devel@vger.kernel.org, ebiederm@xmission.com, simo@redhat.com, netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, Eric Paris , mpatel@redhat.com, Serge Hallyn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 23, 2020 at 4:40 PM Richard Guy Briggs wrote: > On 2020-10-22 21:21, Paul Moore wrote: > > On Wed, Oct 21, 2020 at 12:39 PM Richard Guy Briggs wr= ote: > > > Here is an exmple I was able to generate after updating the testsuite > > > script to include a signalling example of a nested audit container > > > identifier: > > > > > > ---- > > > type=3DPROCTITLE msg=3Daudit(2020-10-21 10:31:16.655:6731) : proctitl= e=3D/usr/bin/perl -w containerid/test > > > type=3DCONTAINER_ID msg=3Daudit(2020-10-21 10:31:16.655:6731) : conti= d=3D7129731255799087104^3333941723245477888 > > > type=3DOBJ_PID msg=3Daudit(2020-10-21 10:31:16.655:6731) : opid=3D115= 583 oauid=3Droot ouid=3Droot oses=3D1 obj=3Dunconfined_u:unconfined_r:uncon= fined_t:s0-s0:c0.c1023 ocomm=3Dperl > > > type=3DCONTAINER_ID msg=3Daudit(2020-10-21 10:31:16.655:6731) : conti= d=3D3333941723245477888 > > > type=3DOBJ_PID msg=3Daudit(2020-10-21 10:31:16.655:6731) : opid=3D115= 580 oauid=3Droot ouid=3Droot oses=3D1 obj=3Dunconfined_u:unconfined_r:uncon= fined_t:s0-s0:c0.c1023 ocomm=3Dperl > > > type=3DCONTAINER_ID msg=3Daudit(2020-10-21 10:31:16.655:6731) : conti= d=3D8098399240850112512^3333941723245477888 > > > type=3DOBJ_PID msg=3Daudit(2020-10-21 10:31:16.655:6731) : opid=3D115= 582 oauid=3Droot ouid=3Droot oses=3D1 obj=3Dunconfined_u:unconfined_r:uncon= fined_t:s0-s0:c0.c1023 ocomm=3Dperl > > > type=3DSYSCALL msg=3Daudit(2020-10-21 10:31:16.655:6731) : arch=3Dx86= _64 syscall=3Dkill success=3Dyes exit=3D0 a0=3D0xfffe3c84 a1=3DSIGTERM a2= =3D0x4d524554 a3=3D0x0 items=3D0 ppid=3D115564 pid=3D115567 auid=3Droot uid= =3Droot gid=3Droot euid=3Droot suid=3Droot fsuid=3Droot egid=3Droot sgid=3D= root fsgid=3Droot tty=3DttyS0 ses=3D1 comm=3Dperl exe=3D/usr/bin/perl subj= =3Dunconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=3Dtestsuite-16= 03290671-AcLtUulY > > > ---- > > > > > > There are three CONTAINER_ID records which need some way of associati= ng with OBJ_PID records. An additional CONTAINER_ID record would be presen= t if the killing process itself had an audit container identifier. I think= the most obvious way to connect them is with a pid=3D field in the CONTAIN= ER_ID record. > > > > Using a "pid=3D" field as a way to link CONTAINER_ID records to other > > records raises a few questions. What happens if/when we need to > > represent those PIDs in the context of a namespace? Are we ever going > > to need to link to records which don't have a "pid=3D" field? I haven'= t > > done the homework to know if either of these are a concern right now, > > but I worry that this might become a problem in the future. > > Good point about PID namespaces in the future but those accompanying > records will already have to be conditioned for the PID namespace > context that is requesting it, so I don't see this as a showstopper. Possibly, it just gets very messy. Doubly so when you start looking at potentially adjusting for multiple audit daemons. Thankfully it doesn't look like using the PID is a good idea for other reasons. > I've forgotten about an important one we already hit, which is a network > event that only has a NETFILTER_PKT record, but in that case, there is > no ambiguity since there are no other records associated with that > event. So the second is already an issue now. Using > task_tgid_nr(current), in the contid testsuite script network event it > attributed it to ping which caused the event, but we cannot use this > since it wasn't triggered by a syscall and doesn't accurately reflect > the kernel thread that received it. It could just be set to zero for > network events. Possibly. It just seems like too much hackery to start; that's the stuff you do once it has been in a kernel release for years and need to find a workaround that doesn't break everything. I think we should aim a bit higher right now. > > The idea of using something like "item=3D" is interesting. As you > > mention, the "item=3D" field does present some overlap problems with th= e > > PATH record, but perhaps we can do something similar. What if we > > added a "record=3D" (or similar, I'm not worried about names at this > > point) to each record, reset to 0/1 at the start of each event, and > > when we needed to link records somehow we could add a "related=3D1,..,N= " > > field. This would potentially be useful beyond just the audit > > container ID work. > > Does it make any sense to use the same keyword in each type of record > such as record/records as in PATH/SYSCALL: item/items ? That was mentioned above, if you can assure yourself and the rest of us that it can be safely reused I think that might be okay, but I'm not convinced that is safe at the moment. Although I will admit those are fears are not based on an exhaustive search through the code (or a determined "think"). > (I prefer 0-indexed like item=3D...) I have no preference on where we start the index, but it makes sense to keep the same index starting point as the PATH records. --=20 paul moore www.paul-moore.com From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BE1AC388F9 for ; Wed, 28 Oct 2020 01:35:49 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 72BD522249 for ; Wed, 28 Oct 2020 01:35:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 72BD522249 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=paul-moore.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=linux-audit-bounces@redhat.com 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-345-Vz-QP3vqMXObMex-VmxVGg-1; Tue, 27 Oct 2020 21:35:43 -0400 X-MC-Unique: Vz-QP3vqMXObMex-VmxVGg-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 BED2A100746B; Wed, 28 Oct 2020 01:35:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A53795B4AD; Wed, 28 Oct 2020 01:35:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 46131181A86E; Wed, 28 Oct 2020 01:35:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09S1ZZt0028127 for ; Tue, 27 Oct 2020 21:35:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id CA2152011569; Wed, 28 Oct 2020 01:35:35 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C1AB4201156B for ; Wed, 28 Oct 2020 01:35:32 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3B8498D6327 for ; Wed, 28 Oct 2020 01:35:32 +0000 (UTC) Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-JIsTJ8eCM4-8D84xLw-FlA-1; Tue, 27 Oct 2020 21:35:30 -0400 X-MC-Unique: JIsTJ8eCM4-8D84xLw-FlA-1 Received: by mail-ej1-f65.google.com with SMTP id h24so4905397ejg.9 for ; Tue, 27 Oct 2020 18:35:29 -0700 (PDT) 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:content-transfer-encoding; bh=EhaQv7Xqn9C10/6kPilmFG/LY90YB69CHHSm/P4LmUk=; b=T90xNrXG2kT9fKuyraQWJxXak7ghWpiDYxx1PCwvpuFdcZ+3baGn2bnfVW2RewYoTI Yj8D0yaQtrg5HZwcFudoNKBYQ5pB0eddkRaaKwndYA6nI89/t17TDtNXjorljUTOgkzU YzyJeyDNRWFYzLt5Ro+WirzzhRLtVQZyxn+u03r1HYlhGgj14OXzmo3iLzXWJL+Ge85w +krIP1qKTGaIJJsFrc2JqSTbkS2gNGhJq648WDf+34AAyjv8/rAelsxip1jN0v7TJ2k2 4Ch6nRSYZjX0i6oHcLX6S9CwYw2TxagFvJHWWmzL/TvfAK+RO1iTEDUZwTH01BYNTmih Cepw== X-Gm-Message-State: AOAM533Yt5fCQeKDb/5ocVfz3SYoiKYvSbE2MjJ7vXDTA83d169YHLRW WMgo/2dNeOvaVDCVXXFvoHS71KiAlTZPygJEhKWi X-Google-Smtp-Source: ABdhPJydImqf6rjIcFvdKoVKRijlUJM6c3tT5+zpyIh0DgksT/WwCUJmb9M0MAWnaqlVZBE1LbPiRD1v+2NmrHAlBa8= X-Received: by 2002:a17:906:4811:: with SMTP id w17mr4982322ejq.431.1603848928683; Tue, 27 Oct 2020 18:35:28 -0700 (PDT) MIME-Version: 1.0 References: <6e2e10432e1400f747918eeb93bf45029de2aa6c.1593198710.git.rgb@redhat.com> <20200729194058.kcbsqjhzunjpipgm@madcap2.tricolour.ca> <20201002195231.GH2882171@madcap2.tricolour.ca> <20201021163926.GA3929765@madcap2.tricolour.ca> <20201023204033.GI2882171@madcap2.tricolour.ca> In-Reply-To: <20201023204033.GI2882171@madcap2.tricolour.ca> From: Paul Moore Date: Tue, 27 Oct 2020 21:35:17 -0400 Message-ID: Subject: Re: [PATCH ghak90 V9 05/13] audit: log container info of syscalls To: Richard Guy Briggs X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 09S1ZZt0028127 X-loop: linux-audit@redhat.com Cc: nhorman@tuxdriver.com, linux-api@vger.kernel.org, containers@lists.linux-foundation.org, LKML , dhowells@redhat.com, Linux-Audit Mailing List , netfilter-devel@vger.kernel.org, ebiederm@xmission.com, simo@redhat.com, netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, Eric Paris , mpatel@redhat.com, Serge Hallyn X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=linux-audit-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Fri, Oct 23, 2020 at 4:40 PM Richard Guy Briggs wrote: > On 2020-10-22 21:21, Paul Moore wrote: > > On Wed, Oct 21, 2020 at 12:39 PM Richard Guy Briggs wrote: > > > Here is an exmple I was able to generate after updating the testsuite > > > script to include a signalling example of a nested audit container > > > identifier: > > > > > > ---- > > > type=PROCTITLE msg=audit(2020-10-21 10:31:16.655:6731) : proctitle=/usr/bin/perl -w containerid/test > > > type=CONTAINER_ID msg=audit(2020-10-21 10:31:16.655:6731) : contid=7129731255799087104^3333941723245477888 > > > type=OBJ_PID msg=audit(2020-10-21 10:31:16.655:6731) : opid=115583 oauid=root ouid=root oses=1 obj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 ocomm=perl > > > type=CONTAINER_ID msg=audit(2020-10-21 10:31:16.655:6731) : contid=3333941723245477888 > > > type=OBJ_PID msg=audit(2020-10-21 10:31:16.655:6731) : opid=115580 oauid=root ouid=root oses=1 obj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 ocomm=perl > > > type=CONTAINER_ID msg=audit(2020-10-21 10:31:16.655:6731) : contid=8098399240850112512^3333941723245477888 > > > type=OBJ_PID msg=audit(2020-10-21 10:31:16.655:6731) : opid=115582 oauid=root ouid=root oses=1 obj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 ocomm=perl > > > type=SYSCALL msg=audit(2020-10-21 10:31:16.655:6731) : arch=x86_64 syscall=kill success=yes exit=0 a0=0xfffe3c84 a1=SIGTERM a2=0x4d524554 a3=0x0 items=0 ppid=115564 pid=115567 auid=root uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=ttyS0 ses=1 comm=perl exe=/usr/bin/perl subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=testsuite-1603290671-AcLtUulY > > > ---- > > > > > > There are three CONTAINER_ID records which need some way of associating with OBJ_PID records. An additional CONTAINER_ID record would be present if the killing process itself had an audit container identifier. I think the most obvious way to connect them is with a pid= field in the CONTAINER_ID record. > > > > Using a "pid=" field as a way to link CONTAINER_ID records to other > > records raises a few questions. What happens if/when we need to > > represent those PIDs in the context of a namespace? Are we ever going > > to need to link to records which don't have a "pid=" field? I haven't > > done the homework to know if either of these are a concern right now, > > but I worry that this might become a problem in the future. > > Good point about PID namespaces in the future but those accompanying > records will already have to be conditioned for the PID namespace > context that is requesting it, so I don't see this as a showstopper. Possibly, it just gets very messy. Doubly so when you start looking at potentially adjusting for multiple audit daemons. Thankfully it doesn't look like using the PID is a good idea for other reasons. > I've forgotten about an important one we already hit, which is a network > event that only has a NETFILTER_PKT record, but in that case, there is > no ambiguity since there are no other records associated with that > event. So the second is already an issue now. Using > task_tgid_nr(current), in the contid testsuite script network event it > attributed it to ping which caused the event, but we cannot use this > since it wasn't triggered by a syscall and doesn't accurately reflect > the kernel thread that received it. It could just be set to zero for > network events. Possibly. It just seems like too much hackery to start; that's the stuff you do once it has been in a kernel release for years and need to find a workaround that doesn't break everything. I think we should aim a bit higher right now. > > The idea of using something like "item=" is interesting. As you > > mention, the "item=" field does present some overlap problems with the > > PATH record, but perhaps we can do something similar. What if we > > added a "record=" (or similar, I'm not worried about names at this > > point) to each record, reset to 0/1 at the start of each event, and > > when we needed to link records somehow we could add a "related=1,..,N" > > field. This would potentially be useful beyond just the audit > > container ID work. > > Does it make any sense to use the same keyword in each type of record > such as record/records as in PATH/SYSCALL: item/items ? That was mentioned above, if you can assure yourself and the rest of us that it can be safely reused I think that might be okay, but I'm not convinced that is safe at the moment. Although I will admit those are fears are not based on an exhaustive search through the code (or a determined "think"). > (I prefer 0-indexed like item=...) I have no preference on where we start the index, but it makes sense to keep the same index starting point as the PATH records. -- paul moore www.paul-moore.com -- Linux-audit mailing list Linux-audit@redhat.com https://www.redhat.com/mailman/listinfo/linux-audit