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=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 6D17EC10F25 for ; Mon, 9 Mar 2020 23:58:55 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B017F2146E for ; Mon, 9 Mar 2020 23:58:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HqqwDBCt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B017F2146E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=schaufler-ca.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-audit-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583798333; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:autocrypt:autocrypt; bh=OpmZi0O76hYsKUmEUgOcCFmOg/eVkjLhUq/GRymLrCw=; b=HqqwDBCtxk6ZHZYuBmwYQreBACQpO9R5FDcntlEK79uJWNbmd64Z4O7nTN9uJdgLMJS//H SB+namIqGN7t0sOjtlDC2Io5wUxPxPVBOjiLLx5bFG1rRJkL8YrrXx25HpyaeyTRQ9NBYW ljMu1nqgPBuQOflVhswpsV5g1fwo6to= 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-487-MZa4BwvgMmaobhmhrfpe6g-1; Mon, 09 Mar 2020 19:58:52 -0400 X-MC-Unique: MZa4BwvgMmaobhmhrfpe6g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9174A800D53; Mon, 9 Mar 2020 23:58:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6221519C70; Mon, 9 Mar 2020 23:58:48 +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 F2ECC86A00; Mon, 9 Mar 2020 23:58:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 029NwjU0001874 for ; Mon, 9 Mar 2020 19:58:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9ED8B10F8E07; Mon, 9 Mar 2020 23:58:45 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 50DF410F8E0B for ; Mon, 9 Mar 2020 23:58:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 6044F8007B3 for ; Mon, 9 Mar 2020 23:58:43 +0000 (UTC) Received: from sonic309-27.consmr.mail.ne1.yahoo.com (sonic309-27.consmr.mail.ne1.yahoo.com [66.163.184.153]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-344-k_zkB7f3PFe9TgQiYryFfQ-1; Mon, 09 Mar 2020 19:58:41 -0400 X-MC-Unique: k_zkB7f3PFe9TgQiYryFfQ-1 X-YMail-OSG: hr6BUJwVM1lnn7JDVHb6e4HKlZHqLQa2peWyZw6OGEoKeMriTLxFFkpBjqs2Egb xLMPMbAoRR8xSQG6TemlDjvFg8duAiMrLeFRT9MGPWrpXqHS_DQv3mHQ91R8LwOE7Sb1uTQuNMJk u30DqAakRr_Bo7__MmVt.TMiYOHXVieplGq_bwBy_XMFGEwJ7G3aDHcmqKPSNZ7sAedFQImVETSj dAccATqX1HDZfGRp2C7lp5sSG4G8FAgu85O8mj9jaysOyIzzOQQtNdscjfKJ99vNp9H4y4l_6oYn wjuPKAGURDGDPtv80vRGk0dFWp6F5IefZNwhh2X0MZZ3zKTD6jnSx8KdBsTiD3usaAzudj_BeMbb U6bXtzXqGUSGv5VMcARGIEmgm2HotPyPhj0jyVLvdwsZrcOGKav5PwXzwFxBzS.xLjTNRAi7UdeJ Xwj_kurcZVs0vHbHVj5OlPwaO4OvvSHUMmMpQXGTzbs4p2D_Y0K_scpXfsgDLm1L64SybzO15Y8C mbaiPSLsFhj3L6Ih53SwGkD6Fc6Qvws3Zdi4zRfp7q1MWGAv6b_f.Up2tMmKe6bq6YiHO9Cf7w9z Pe_K5CnRI8L5owtZJGLH30O6HJyURoaolIl9kMmDiWBGpc4BUdSJXnNs0thhARGd20a4YiED50Q3 .bAVGzUNz2anSxweliMaZiO3c_73mbZTDhIKRthqimi2O2eUqD6SPhlunI6HKDg0tj9lL5oAQEd. ZSI8YL8I07G1BCqHoPZ7wvmutvtlHaDw6YxRahukh.hOCAH4UMDJRXwfk0ONqgqHBSMoYu_TzAwV _fw_u6bXSlw4ohfwK6XlWUuVLJDwBVXb0nWHuyCEc0uwEAZmMqaSosv1onzsocjlLpbUejbvlpml wMkl43e8iaTq8Hi4huTUOsSN4GdBmISgdpMcsjODDkuyQd8COaUpaRmMgOllKmhEb6CRemCyvXNT B2aPt20piUFwND9xfHMtgWdaEtScVL3UXfBb6tpVx57I7PXDZ.B.FXU2ene0F0JFzrR5SIFQX61s EuF44F_aXcKNwHCuiVNQU5PsLiep0qJheVS.On_LwUHRab2KZYdzKjsXqOiYP7pY4ZD.FEgYWj0u oxVXWSEsGQWrUFk1_7PRroyUMby.DmBHBbeQ.PLeYmJAT.xI6eJaa85_Kr78NPpX6pZCurs3DBj7 pTAPoq9krnrLPC8qdeLGTvGdkkzr3zEmjo4hls8.hzaiyjraa5fHHdfO7naj6JjvIld.lGYtzXH6 4ID7rEYQnLX.24ZDHSVri5SmM_8cr_ijp6FHpOk9JYSVs9dJSVzntTQgOofGLnl3rFwfrwgg36D6 CzgcKwFoPx9j8_brBSBLkA7SwoUxEf18lmPVXLU0ECbt79wCqs30jU1DNhwAZtjWjunKDpxDdxFT 3iM4m2E2zVp7Dz5lbD6p2UQaZapMHBWfPjz0va4E- Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ne1.yahoo.com with HTTP; Mon, 9 Mar 2020 23:58:40 +0000 Received: by smtp425.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 7a38e42435f828e6426264079edb10c1; Mon, 09 Mar 2020 23:58:38 +0000 (UTC) Subject: Re: [PATCH v15 03/23] LSM: Use lsmblob in security_audit_rule_match To: Paul Moore References: <20200222000407.110158-1-casey@schaufler-ca.com> <20200222000407.110158-4-casey@schaufler-ca.com> From: Casey Schaufler Autocrypt: addr=casey@schaufler-ca.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7Hl6WdW19BXOZ7v3jo1q6lWwcFYth esJfk3ZPPJXuBokrFH8kqnEQ9W2QgrjDX3et2WwZFLOoOCItWxT0/1QO4ikcef/E7HXQf/ij Dxf9HG2o5hOlMIAkJq/uLNMvABEBAAGJAjwEGAEIACYWIQQL720fVjJTAhDNQh44pRV8jEPI EQUCXNX0cAIbDAUJEswDAAAKCRA4pRV8jEPIEWkzEACKFUnpp+wIVHpckMfBqN8BE5dUbWJc GyQ7wXWajLtlPdw1nNw0Wrv+ob2RCT7qQlUo6GRLcvj9Fn5tR4hBvR6D3m8aR0AGHbcC62cq I7LjaSDP5j/em4oVL2SMgNTrXgE2w33JMGjAx9oBzkxmKUqprhJomPwmfDHMJ0t7y39Da724 oLPTkQDpJL1kuraM9TC5NyLe1+MyIxqM/8NujoJbWeQUgGjn9uxQAil7o/xSCjrWCP3kZDID vd5ZaHpdl8e1mTExQoKr4EWgaMjmD/a3hZ/j3KfTVNpM2cLfD/QwTMaC2fkK8ExMsz+rUl1H icmcmpptCwOSgwSpPY1Zfio6HvEJp7gmDwMgozMfwQuT9oxyFTxn1X3rn1IoYQF3P8gsziY5 qtTxy2RrgqQFm/hr8gM78RhP54UPltIE96VywviFzDZehMvuwzW//fxysIoK97Y/KBZZOQs+ /T+Bw80Pwk/dqQ8UmIt2ffHEgwCTbkSm711BejapWCfklxkMZDp16mkxSt2qZovboVjXnfuq wQ1QL4o4t1hviM7LyoflsCLnQFJh6RSBhBpKQinMJl/z0A6NYDkQi6vEGMDBWX/M2vk9Jvwa v0cEBfY3Z5oFgkh7BUORsu1V+Hn0fR/Lqq/Pyq+nTR26WzGDkolLsDr3IH0TiAVH5ZuPxyz6 abzjfg== Message-ID: Date: Mon, 9 Mar 2020 16:58:37 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 029NwjU0001874 X-loop: linux-audit@redhat.com Cc: casey.schaufler@intel.com, linux-audit@redhat.com 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.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On 3/6/2020 2:01 PM, Paul Moore wrote: > On Fri, Feb 21, 2020 at 7:04 PM Casey Schaufler wrote: >> Change the secid parameter of security_audit_rule_match >> to a lsmblob structure pointer. Pass the entry from the >> lsmblob structure for the approprite slot to the LSM hook. >> >> Change the users of security_audit_rule_match to use the >> lsmblob instead of a u32. In some cases this requires a >> temporary conversion using lsmblob_init() that will go >> away when other interfaces get converted. >> >> Reviewed-by: Kees Cook >> Reviewed-by: John Johansen >> Acked-by: Stephen Smalley >> Signed-off-by: Casey Schaufler >> --- >> include/linux/security.h | 7 ++++--- >> kernel/auditfilter.c | 6 ++++-- >> kernel/auditsc.c | 14 ++++++++++---- >> security/integrity/ima/ima.h | 4 ++-- >> security/integrity/ima/ima_policy.c | 7 +++++-- >> security/security.c | 8 +++++--- >> 6 files changed, 30 insertions(+), 16 deletions(-) > ... > >> diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c >> index 3a44abf4fced..509eb21eff7f 100644 >> --- a/kernel/auditfilter.c >> +++ b/kernel/auditfilter.c >> @@ -1327,6 +1327,7 @@ int audit_filter(int msgtype, unsigned int listtype) >> struct audit_field *f = &e->rule.fields[i]; >> pid_t pid; >> u32 sid; >> + struct lsmblob blob; >> >> switch (f->type) { >> case AUDIT_PID: >> @@ -1357,8 +1358,9 @@ int audit_filter(int msgtype, unsigned int listtype) >> case AUDIT_SUBJ_CLR: >> if (f->lsm_isset) { >> security_task_getsecid(current, &sid); >> - result = security_audit_rule_match(sid, >> - f->type, f->op, >> + lsmblob_init(&blob, sid); >> + result = security_audit_rule_match( >> + &blob, f->type, f->op, >> f->lsm_rules); > Unless I'm mistaken this patch is almost exclusively the following pattern: > > lsmblob_init(blob, sid); > security_audit_rule_match(blob, ...); > > ... which means we are assigning every array member in @blob the same > value of "sid" and then sending that into the LSM where each LSM is > going to then have to index into that array, to all get the same > value, and then do their match. I'm assuming this will make more > sense as I progress through the rest of the patchset, but right now it > seems like we could get by just fine with a u32 here. When I do the next version I'll put considerably more effort into explaining the scaffolding strategy. I'm definitely in that area where the advantage of keeping patches small and the advantage of making a change obvious are at odds. This will apply to the next few patches in the series as well. -- Linux-audit mailing list Linux-audit@redhat.com https://www.redhat.com/mailman/listinfo/linux-audit