Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1247865rwl; Wed, 5 Apr 2023 14:07:54 -0700 (PDT) X-Google-Smtp-Source: AKy350b1XQidov1koy8QklRoOProxpBzMcBAeNxERocaglqFF9uq6xSEN6Ge2neX0my9EaDaXjLa X-Received: by 2002:a62:84d8:0:b0:628:134b:6b1c with SMTP id k207-20020a6284d8000000b00628134b6b1cmr7874292pfd.2.1680728874689; Wed, 05 Apr 2023 14:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680728874; cv=none; d=google.com; s=arc-20160816; b=J/8DQx2X3FOaxctNYt8we20UAQH4+reBUC8Sxh1zRIy4mNx7RAdjo7KJY7dx+FSzRv 1f7jkm7gkVZS4s+4X0o+hfpUD/8eQjunEvHcUeYNXXMjjKlZ51BRXWwdS/xSWyfA/AHK kMbls6Qsx+DjhZEH88DOinv4GBXqWc49xgTuW+StmEjMtoMgUXiLv5o4jj84ysjJzyY6 hKd2LqTE3enAWiQt8b9g+YKJuci2F6VGINvtNZF1UMOw8+L8KHtsOhca5fNBRYTsOBjj Fc7TXwcHKXHFT7nbwhmSNDpg9UIE4JUJUoGiFOg9aIjdCek8qaKyZ9K1hoQiPAoILoSb KOSQ== 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=5pWPy9H+by09Lc7YU/CRUS1UICIUAlLK+lHzVatngeE=; b=IevnOY7yHW415OjhDHHcxNIFQ6wJtkfocdw+089N9F3ELOFPhhZSx/YTgdrWHy7f2w k7NimFvTeyTZQRP7vDXhkvsEtmVj2RYCb5o/qGrDDXq97TOn/U8/BT8bnGqx2XmMqoSa CvPTglkyiwBtLJVcRopXRFtAdMStE3HRV5sI9tea5WRU5c8ylAfqbZLJZw7amH/nxpO0 SPBgRXZGAYJg1YHgb2D78H1SXbCPx32wDVvq8BGOn8IFTl9Upu9iws/GSd2M6g5ChTqL lfijv/dLTZvqV0HSsBAnUYuena8/ZendV/ov5HUH4hiknVNvCGzt8Y7JXQR42YyiW93q Fy5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=B3041m78; 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 j8-20020a63cf08000000b0050c0c9d2916si12469319pgg.870.2023.04.05.14.07.35; Wed, 05 Apr 2023 14:07:54 -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=B3041m78; 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 S233603AbjDEUth (ORCPT + 99 others); Wed, 5 Apr 2023 16:49:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232640AbjDEUtf (ORCPT ); Wed, 5 Apr 2023 16:49:35 -0400 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67AF21736 for ; Wed, 5 Apr 2023 13:49:34 -0700 (PDT) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-545e907790fso585059947b3.3 for ; Wed, 05 Apr 2023 13:49:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1680727773; 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=5pWPy9H+by09Lc7YU/CRUS1UICIUAlLK+lHzVatngeE=; b=B3041m78p7E6ryUg79fJRRVjBHF6S5BGYn5Vxoe4WzJgWCwBFKMhH3uCrn1/jJZWeS NXL4m6wLhrcYN8Cq+JD9SYut3PwbUIAvvnyWIsyR4gtqbKFLTA4ut4VA+q54zO0CEnvn NwZn2DeWuS1gOoYvfcIQU+VbqBTOmwV8Xs0cWCB7OYPx22b47dy3J6jpF7Mhe2SukCUT vtyztoHiaW1wpek56l3thVBng3IVX+R6LFPLTIhNA75IEwUltMDMC4F9hI9m9gxYURRZ noi73sXaKEWbUT4DnrKeFoRs9BbqSnAf7R2DrdsWNWeP5E9GfbnBUjlymoBdW5qqnskd 4UJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680727773; 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=5pWPy9H+by09Lc7YU/CRUS1UICIUAlLK+lHzVatngeE=; b=egR8CMRot6ckXi04GQP9EPBk/JJIc+kwmSfTcoCF8H9vg2QJ/KuD2xEWit5cUYQ1xJ cOLAVXWKldB3mPfMQsijBH5j4RV+HpmjLe3d2rfqBXiOfqr92m1ymN834BOtIyRDpPX4 czNIgiICx1B4z5HiQiKFuIx6pXdp0C6cOR9vDdi4y6Eqc9ctMf/gbFAdogLn+eS5IJbe Vu52PzDniVRlgGV5mawLS404aZXW0wIniuLR8qcSxtFmZ7qSCrzYQUoKhA1DFXbNNBkG pgb6Aota985OoUclLaQc+Xy1woU1q38Vi3wkQUTxuw2dKh2ZSImnis4hI+t+eod6N7xe 813w== X-Gm-Message-State: AAQBX9evV5tEfCLQeGrL8APhwTW+shwQfU95p1jD7A9Jch9G+9mpdfa/ yvmc2BINaZDdddKJTtBJ/oy6vLEhuY7TuMNBL4Be X-Received: by 2002:a81:9902:0:b0:545:632d:e78b with SMTP id q2-20020a819902000000b00545632de78bmr2838427ywg.0.1680727773518; Wed, 05 Apr 2023 13:49:33 -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> <83ddfcb9-b4a6-71b4-a20c-62f484c8e040@schaufler-ca.com> In-Reply-To: <83ddfcb9-b4a6-71b4-a20c-62f484c8e040@schaufler-ca.com> From: Paul Moore Date: Wed, 5 Apr 2023 16:49:22 -0400 Message-ID: Subject: Re: [PATCH v10 2/4] security: Allow all LSMs to provide xattrs for inode_init_security hook To: Casey Schaufler Cc: Roberto Sassu , 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 4:43=E2=80=AFPM Casey Schaufler wrote: > On 4/5/2023 12:59 PM, Paul Moore wrote: > > 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 progr= am, > >>>> I think it would be good to move SMACK64EXEC to its own line; it too= k > >>>> 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, a= nd > >>>> that is the only current user of SMACK_INODE_INIT_XATTRS, can we mak= e > >>>> 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 initi= alized > >>> is a directory, the new inode should get the SMACK64_TRANSMUTE attrib= ute. > >>> 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 syst= em > >>> 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? > > It can't. I didn't think so. To be really specific, that's what we're talking about with this patch: the number of xattrs that smack_inode_init_security() can return to the LSM hook (and EVM, and the caller ...). If it's only ever going to be one, I think we can adjust the 'SMACK_INODE_INIT_XATTRS' down to '1' and save ourselves some allocation space. --=20 paul-moore.com