Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1184321rwl; Wed, 5 Apr 2023 13:04:09 -0700 (PDT) X-Google-Smtp-Source: AKy350amrC07CBo/Ri/AfiM1ukhnRiBG5g6QlL/J0/TFFdlExoKKHElfjhU+EI7rAwWbU4NMzPZh X-Received: by 2002:a62:4e06:0:b0:62d:df1a:167c with SMTP id c6-20020a624e06000000b0062ddf1a167cmr6212036pfb.1.1680725049193; Wed, 05 Apr 2023 13:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680725049; cv=none; d=google.com; s=arc-20160816; b=b1e8onmXHBEofT/X13Q5Mwdt+AcQIPaPIS0BV/vmEYb6W62SS3uB2u300JXs5dALFa XKkIs4asRx0BmmmCdWBvh6tZQFxGClh1MaSiyPlwpMQypWisVQQJ79R75yF4FRM8sxEU Oeuu6oEmQkvV3kx3C9WucdCeEDitQjbEJpsEvzgRhInGNF6qgGEali5O/lB1xhsfDltf MWpRU3AlWpt6Dsf6BkeLEwfLEYxRQzRDheLmee3ncTayI6r2mZpbEYR9uQ0whZIpD3D4 RcF927yLYnT17sSNKA+zh+/qGcTeNIrtIEa8OdN0qCEJfIlcXQRJrNcUmjyt5y7mQ1Uq 0OdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=16oMn1NNzoMGhRBfxhPQbT5X5eCgj0j1VfPTFGPRXYA=; b=TIfYlr6FrXYVqsgjsVmRtBYqX2VSg2AFT9ITFm/ft2r+Y82S2215Aj/sABDBPQ+2JI PxR/7YYt7Pe5gUzVCgDoC6j284J8K7fStRbAZV4NlH0OZPVoTrJE50fr+fxTln+S3CDw AZ2YMYBaVxrIptablr7CtQT7gr8slvDX3hhxUDa5EBTzqc/WYcuV1Qt2v1lo5HN6JMzX dl0lACYS4HRvYIfH0/ldTo1C7S9/L7w486g6Zg4+eTinvTGO25xqThMRXMwf7t4sk5DU PC+ciCZak3T98bverbiQJEETICPES8CEDbwoorTOo7fChalf9UxVb1JA3pnYXLJB5aPu ZeTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=M6bRM2Kl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x71-20020a63864a000000b005139e0d2b5csi13506714pgd.487.2023.04.05.13.03.41; Wed, 05 Apr 2023 13:04:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=M6bRM2Kl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230307AbjDEUAK (ORCPT + 99 others); Wed, 5 Apr 2023 16:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233867AbjDET7u (ORCPT ); Wed, 5 Apr 2023 15:59:50 -0400 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCFD746B4 for ; Wed, 5 Apr 2023 12:59:47 -0700 (PDT) Received: by mail-yb1-xb34.google.com with SMTP id d3so16069272ybu.1 for ; Wed, 05 Apr 2023 12:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1680724787; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=16oMn1NNzoMGhRBfxhPQbT5X5eCgj0j1VfPTFGPRXYA=; b=M6bRM2KlH9Lx5lsl1rif9t0ScqLJIdivfDowNos4t0MnSqxdPlWxdu1CtgPNVsf6PQ 8U5VUfoOsmfJmq2XRa8ctGuBct1KIf4mat5CVl4r9vCtgWvPc73og4XPAPJKiOsAPB+Q TzbfcFogPV6U8zGTa4ijQ6IBjmsU6UYaRrrgV+MOlHiWQwISa6b0bt+EsHa7MUmooDWm 1rx7Y/edmVIxZTJxu4jBKhmeO+u5C9tr4U0UPwgtrDnUgxq6zmZDc1w3LPqaQTij0hMF tRaNkccvCmTc4mjM2PROEHzoz75i9wuaWNb56YFKuf2qr5UxdsWp10j3px0yPT+mbFd2 LPNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680724787; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=16oMn1NNzoMGhRBfxhPQbT5X5eCgj0j1VfPTFGPRXYA=; b=pktDzk8j8z2owfpYuckaR1z7Xqtj0vCOcJSAzVQdXdIzJcgINbVdDgem+0k0Ur1sBp 3kQNAKvoqkUpXzS7Yq1LGmPyo7gUgrXTQT2IgQ+8VDgK2g5ZU4hA/Zpy6ZYtSH+kbmG3 o63/Ef7eoX71dutswmnrdn2w0gm/zORknhH4iAm2OQrjToqZna9h9BSzKOSYU0LoMUIE bkfnvo6rlqoAI1zWfQR1rn4V+SRbbkoeT+90i5PiX+kmOyiJQWM0umUAq1USiE5v/yEn iVCc0tkP8G3puO0Sium+fQrEkA057oCNhrOaYg2lF2HIDaBDliSjJAohX7mCU7vlPZdi nNHQ== X-Gm-Message-State: AAQBX9foClgumWCD9YiQojHEo/1N+Xw3SACX5fTrN926Le4iVyT/T3p6 vVKpTJ1j2mhbDdS3GmyOyIcX0q5xZcJ2aWUcKQea X-Received: by 2002:a25:d707:0:b0:b68:7a4a:5258 with SMTP id o7-20020a25d707000000b00b687a4a5258mr390159ybg.3.1680724786891; Wed, 05 Apr 2023 12:59:46 -0700 (PDT) MIME-Version: 1.0 References: <20230331123221.3273328-1-roberto.sassu@huaweicloud.com> <20230331123221.3273328-3-roberto.sassu@huaweicloud.com> <5dbb9430-1e26-ec12-26a2-3718c84e33c2@schaufler-ca.com> <7549b624-421e-30b9-ca99-de42929354c7@huaweicloud.com> In-Reply-To: <7549b624-421e-30b9-ca99-de42929354c7@huaweicloud.com> From: Paul Moore Date: Wed, 5 Apr 2023 15:59:36 -0400 Message-ID: Subject: Re: [PATCH v10 2/4] security: Allow all LSMs to provide xattrs for inode_init_security hook To: Roberto Sassu Cc: Casey Schaufler , zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, jmorris@namei.org, serge@hallyn.com, stephen.smalley.work@gmail.com, eparis@parisplace.org, reiserfs-devel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, bpf@vger.kernel.org, kpsingh@kernel.org, keescook@chromium.org, nicolas.bouchinet@clip-os.org, Roberto Sassu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 5, 2023 at 5:44=E2=80=AFAM Roberto Sassu wrote: > On 4/5/2023 4:08 AM, Casey Schaufler wrote: > > On 4/4/2023 11:54 AM, Paul Moore wrote: > >> On Fri, Mar 31, 2023 at 8:33=E2=80=AFAM Roberto Sassu > >> wrote: ... > >>> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c > >>> index cfcbb748da2..8392983334b 100644 > >>> --- a/security/smack/smack_lsm.c > >>> +++ b/security/smack/smack_lsm.c > >>> @@ -52,6 +52,15 @@ > >>> #define SMK_RECEIVING 1 > >>> #define SMK_SENDING 2 > >>> > >>> +/* > >>> + * Smack uses multiple xattrs. > >>> + * SMACK64 - for access control, SMACK64EXEC - label for the program= , > >> I think it would be good to move SMACK64EXEC to its own line; it took > >> me a minute to figure out why SMACK_INODE_INIT_XATTRS was set to '4' > >> when I only say three comment lines ... ;) > >> > >>> + * SMACK64MMAP - controls library loading, > >>> + * SMACK64TRANSMUTE - label initialization, > >>> + * Not saved on files - SMACK64IPIN and SMACK64IPOUT > >>> + */ > >>> +#define SMACK_INODE_INIT_XATTRS 4 > >> > >> If smack_inode_init_security() only ever populates a single xattr, and > >> that is the only current user of SMACK_INODE_INIT_XATTRS, can we make > >> this '1' and shrink the xattr allocation a bit? > > > > If the parent directory is marked with SMACK64_TRANSMUTE, the access > > rule allowing the access has the "t" mode, and the object being initial= ized > > is a directory, the new inode should get the SMACK64_TRANSMUTE attribut= e. > > The callers of security_inode_init_security() don't seem to care. > > I can't say if the evm code is getting SMACK64_TRANSMUTE or, for that > > matter, SMACK64_EXEC and SMACK64_MMAP, some other way. The older system > > allowed for multiple Smack xattrs, but I'm not clear on exactly how. > > If you like to set an additional xattr, that would be possible now. > Since we reserve multiple xattrs, we can call lsm_get_xattr_slot() > another time and set SMACK64_TRANSMUTE. > > I think, if the kernel config has CONFIG_EVM_EXTRA_SMACK_XATTRS set, > EVM would protect SMACK64_TRANSMUTE too. Ooookay, but can someone explain to me how either the current, or patched, smack_inode_init_security() function can return multiple xattrs via the security_inode_init_security() LSM hook? I'm hoping I'm missing something really obvious, but I can only see a single Smack xattr being returned ... --=20 paul-moore.com