Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1460409pxj; Fri, 21 May 2021 15:07:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3FQA9uWyWZFRYh/101pbvY8OU/M8iTWYdLFvGXd4V6XCQuam7UOqXH/PHCpAXS61VUUOB X-Received: by 2002:a17:906:4155:: with SMTP id l21mr11806843ejk.424.1621634858691; Fri, 21 May 2021 15:07:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621634858; cv=none; d=google.com; s=arc-20160816; b=FSjX3UGF0cYrGn0TuyzZGXLgvSUCssNIeSv8W09yQcBkMJPLJMY0Rbfow5AjU++Jlo ddLEB/3OvttMmYQf+WbiIrdDxekEwMX3W6zUdG00xHbmA0VVXPYqA8PTN/me7XD599ZP uNQsuGlQgEcu+2Tjz3L4ZtwhbHdQOOBzeei/TGC2OV7A3hbRRxpl6wEOviVuTBJFgkR5 PMxMcCq9fo4lRFUZSqHUwabcOQdaJ7qs4qKsX/lLvYu+Uf1r+L1OAiTWyekkbUgnlwWy Cg3cEjklidYBaJZ2V/WCe+Auin4jD/clp8DrEdLcDDQHkLncmNEn9EYIua41XtaUejBf Gnow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=aSHcnHFaJCW0nUDhY7hbjuJXu9n+xFG+sWnFXaRVTUI=; b=ORZMSMUQihlYnsMdhb/K0uqGIpiWg+hhcbxyIqr6GphY/5IEnxhLFysq9fkpLCjyP5 PIOge7a+v5bmT0GphE8SaHLX21jkxL3B1BjFxcbrJn2j3JfgByrTSxCtczFRnTXOM6g/ uopEQizPZgsmGA0rsJPbc/D4HFdEGm0Akda19GoyQK7Lu48NjXaBKQdUlnoA+mbkJPA3 2QZqztQpmNIscAg7gq+Jxi38AWhZkDJCFksffmaYAMwu1vprrxZvC8XYWXCZisDsOakx Zf8iItbkxmB0Wk7IttYyouajFZD4viFG+XCGQIrq28vp29uREprEizC+56Dw3yHkmjRa v6vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=QFUWJ2qN; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si6072724ejd.87.2021.05.21.15.07.15; Fri, 21 May 2021 15:07:38 -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=@yahoo.com header.s=s2048 header.b=QFUWJ2qN; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229757AbhEUWHN (ORCPT + 99 others); Fri, 21 May 2021 18:07:13 -0400 Received: from sonic317-39.consmr.mail.ne1.yahoo.com ([66.163.184.50]:43149 "EHLO sonic317-39.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbhEUWHK (ORCPT ); Fri, 21 May 2021 18:07:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1621634746; bh=aSHcnHFaJCW0nUDhY7hbjuJXu9n+xFG+sWnFXaRVTUI=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject:Reply-To; b=QFUWJ2qNKTxCqlnpPvO/j5Qu22dfrkcuPx9j0giRBAUlaSlgniWT1t3yat9wmk2tgPfHC+1XR/YndYjyd2OAYzas1/uwcF0CbnRJDxAMB+oFqJhJvYJRgUQE2wUPJ0HDxHWqlLBYhPOtO2Cxv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Y cMXHhX.Afd0GCUqdCBJav.jUwArqjw6wWT.bhTeD.2N76zYrsM8q5S8FWCc25yfgdgHR0ruqnCmC 3HIx0TQlMIHA6iMQwfMV8Ba3CCXtRsmWCrmcKrPDkQFu__7PEo_hZDgTH9ABMF1X1DCE1VDJdvK6 fSD7rcXdZEw9oKd5UejAb0Xp9IkyLA.yeIM.Nd8cEkaYW1naBxVbcPd_EOnpWf4eb2am4kUI58Fy CtZMfE2lqD3vXPej87fVIJOluyCXNrsIefzo2ZODstV3blg5pqZwneNTS3rTqBEWAcNfrHXsrOS1 _iaIRZ6WIWedw1ehISTwHSFs_pagRwerWt1lRKbH9wvfAaqXz_PtTaK12b7jpTvwV.4MnPzcpc_J BZ4eFFWGMwq8pCuslH_SE8pZMjjCmXigecxxmA0vcz.8pHJESZExi5QYM7rYQDX7MGu2WQFbPIr5 7FSWaQZGNxGcbXSCp7ZQkFCnP3qFZKU6_v8usXPD12RKT9_cXY5qT0Wm6vZMYg_HPpn2PMdvn1mR 1688L09HeiNPPNd7Y600lPVyBtUGw_UY9w9xFS8BazNwDd.s8_5ScOIdpaMeE21s0ravL4kPzMD8 oaqnVHUDaJeZlS2qLV74X9WC7mdwbVnIMNmVr4QLjgksr1OKFhu6dtb4JbofyyMnI1Hq9jLJipjE 3qUw5.oRvMGgTnAE0QE8.20wXwyXovWcvAFnP7Lvv78Z9owzzDX3ptMZlI6keB7uUO4XvsV8bQip 1UGp1bmWMybAhH_1ypl49UiOYw4htNXM4nafHc83ngYHni4p9q5MZy9gTISrbngHiwctWO5iJ7wm bffIrp.tU6PnLXm64_gfpN2LtP2M3l6NrT_f8ub.SJCx2im2uP_bLv5OOtS4ele8C5W2lsATbi.E afMi6INmmP_S1xBf5UhmU30hKBxb3FI7NN2H37qUT1mU- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.ne1.yahoo.com with HTTP; Fri, 21 May 2021 22:05:46 +0000 Received: by kubenode572.mail-prod1.omega.gq1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID e695631a07a97c834a4ba421db0199a4; Fri, 21 May 2021 22:05:43 +0000 (UTC) Subject: Re: [PATCH v26 22/25] Audit: Add new record for multiple process LSM attributes To: Paul Moore Cc: casey.schaufler@intel.com, James Morris , linux-security-module@vger.kernel.org, selinux@vger.kernel.org, linux-audit@redhat.com, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, Stephen Smalley , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Casey Schaufler References: <20210513200807.15910-1-casey@schaufler-ca.com> <20210513200807.15910-23-casey@schaufler-ca.com> From: Casey Schaufler Message-ID: Date: Fri, 21 May 2021 15:05:41 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-Mailer: WebService/1.1.18368 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 4565 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/21/2021 1:19 PM, Paul Moore wrote: > On Thu, May 13, 2021 at 4:32 PM Casey Schaufler wrote: >> Create a new audit record type to contain the subject information >> when there are multiple security modules that require such data. >> This record is linked with the same timestamp and serial number >> using the audit_alloc_local() mechanism. > The record is linked with the other associated records into a single > event, it doesn't matter if it gets the timestamp/serial from > audit_alloc_local() or an existing audit event, e.g. ongoing syscall. > >> The record is produced only in cases where there is more than one >> security module with a process "context". >> In cases where this record is produced the subj=3D fields of >> other records in the audit event will be set to "subj=3D?". >> >> An example of the MAC_TASK_CONTEXTS (1420) record is: >> >> type=3DUNKNOWN[1420] >> msg=3Daudit(1600880931.832:113) >> subj_apparmor=3D=3Dunconfined > It should be just a single "=3D" in the line above. AppArmor provides the 2nd "=3D" as part of the subject context. What's here is correct. I won't argue that it won't case confusion or worse. >> subj_smack=3D_ >> >> There will be a subj_$LSM=3D entry for each security module >> LSM that supports the secid_to_secctx and secctx_to_secid >> hooks. The BPF security module implements secid/secctx >> translation hooks, so it has to be considered to provide a >> secctx even though it may not actually do so. >> >> Signed-off-by: Casey Schaufler >> To: paul@paul-moore.com >> To: linux-audit@redhat.com >> To: rgb@redhat.com >> Cc: netdev@vger.kernel.org >> --- >> drivers/android/binder.c | 2 +- >> include/linux/audit.h | 24 ++++++++ >> include/linux/security.h | 16 ++++- >> include/net/netlabel.h | 3 +- >> include/net/scm.h | 2 +- >> include/net/xfrm.h | 13 +++- >> include/uapi/linux/audit.h | 1 + >> kernel/audit.c | 80 ++++++++++++++++++------= - >> kernel/audit.h | 3 + >> kernel/auditfilter.c | 6 +- >> kernel/auditsc.c | 75 ++++++++++++++++++++--- >> net/ipv4/ip_sockglue.c | 2 +- >> net/netfilter/nf_conntrack_netlink.c | 4 +- >> net/netfilter/nf_conntrack_standalone.c | 2 +- >> net/netfilter/nfnetlink_queue.c | 2 +- >> net/netlabel/netlabel_domainhash.c | 4 +- >> net/netlabel/netlabel_unlabeled.c | 24 ++++---- >> net/netlabel/netlabel_user.c | 20 ++++--- >> net/netlabel/netlabel_user.h | 6 +- >> net/xfrm/xfrm_policy.c | 10 ++-- >> net/xfrm/xfrm_state.c | 20 ++++--- >> security/integrity/ima/ima_api.c | 7 ++- >> security/integrity/integrity_audit.c | 6 +- >> security/security.c | 46 +++++++++----- >> security/smack/smackfs.c | 3 +- >> 25 files changed, 274 insertions(+), 107 deletions(-) > ... > >> diff --git a/include/linux/audit.h b/include/linux/audit.h >> index 97cd7471e572..229cd71fbf09 100644 >> --- a/include/linux/audit.h >> +++ b/include/linux/audit.h >> @@ -386,6 +395,19 @@ static inline void audit_ptrace(struct task_struc= t *t) >> __audit_ptrace(t); >> } >> >> +static inline struct audit_context *audit_alloc_for_lsm(gfp_t gfp) >> +{ >> + struct audit_context *context =3D audit_context(); >> + >> + if (context) >> + return context; >> + >> + if (lsm_multiple_contexts()) >> + return audit_alloc_local(gfp); >> + >> + return NULL; >> +} > See my other comments, but this seems wrong at face value. The > additional LSM record should happen as part of the existing audit log > functions. I'm good with that. But if you defer calling audit_alloc_local() until you know you need it you may be in a place where you can't associate the new context with the event. I think. I will have another go at it. =20 > I think I was distracted with the local context issue and I've lost > track of the details here, perhaps it's best to fix the local context > issue first (that should be a big change to this patch) and then we > can take another look. I really need to move forward. I'll give allocation of local contexts as necessary in audit_log_task_context() another shot.=20 > > > -- > paul moore > www.paul-moore.com