Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp869534rwr; Thu, 20 Apr 2023 07:18:25 -0700 (PDT) X-Google-Smtp-Source: AKy350Y9XHNwua974+vwbqHl5O/j67oEq+V/rfHfntp02KIxqMojDHeVVDeCLUepxNPjAgcF51U2 X-Received: by 2002:a05:6a21:340a:b0:f2:5a2:c05f with SMTP id yn10-20020a056a21340a00b000f205a2c05fmr1383212pzb.13.1682000305374; Thu, 20 Apr 2023 07:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682000305; cv=none; d=google.com; s=arc-20160816; b=jpR/veLaw26HC3qTQ5B5Ip4lEli94S/I85SHcjGaIHLFFIlapeOVKMMhicgIW6Wcpk XVgCZCh/I9Y963p1XhjLTlZAtx+X0cnlhQ2ipv7tAW3A6I81HYP8SXDy3uzBgejzr7zG jJTmKLan6uCOtSo727xUWZ6A9UHRRGQQeVLNzbPIY+bBNh2XhaHXdnBuSRwtL2ABdGpP 83XCpWDgYoBGhigcnm/YRv+fv/TfZ79Rt0nmyfSMbOnngw3GXpWaoW8pogFw7zHGmCt+ HQF8wm0zz6enOVmIVXWDlskGLQ2lud7N3YU6Wpvy6n6QHTOWmwjQnTXMQ5tGfiX4MqYc YjOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=AEhsOt/fenov5R7I+7Cc+XU/g2yMeFfA9Kf1hNK1Y4U=; b=LTvJi9yH3etJJJsc1LTOLcLj9tuVdgsDj3qxfIv8KD3A0PbbriXec3pxqKjh9jv6F2 jP8t85P2mWsicss2CO6WwL9jXs588Wfri+eyIobtx/4JnkH2WuLYZlPYWJi7vaeS350R KnCDOwRkuyMdiUYM2gNQtIFg2a+HiLTOzpz8fDKB5CRtC6x4D/wpr1RL4mrCDh5W2VMA EwrwrmZzx96Tc6nkaXVfm6Tk/nDOrbAdpfu89KP2ca83qEaLWZU6hYAUd4+zJPsvekPp T9aLRNfPJLsHvkneF0XOXEBlq7LvFc5Wex2r+xMd3Tv7ZQbdzkEFHIPJX+WaE9H21jy6 ZI4Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j62-20020a638041000000b005186b2f7b2csi1777387pgd.236.2023.04.20.07.18.10; Thu, 20 Apr 2023 07:18:25 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231918AbjDTOLc (ORCPT + 99 others); Thu, 20 Apr 2023 10:11:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbjDTOLa (ORCPT ); Thu, 20 Apr 2023 10:11:30 -0400 Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F83A212D; Thu, 20 Apr 2023 07:11:28 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.227]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4Q2K8c0mhtz9v7fx; Thu, 20 Apr 2023 22:01:52 +0800 (CST) Received: from roberto-ThinkStation-P620 (unknown [10.204.63.22]) by APP2 (Coremail) with SMTP id GxC2BwB3JDvmR0Fk1Yo8Ag--.1954S2; Thu, 20 Apr 2023 15:10:59 +0100 (CET) Message-ID: <5a9ba6618b37a592cda13ce36ea35cf78c98122b.camel@huaweicloud.com> Subject: Re: [PATCH] Smack modifications for: security: Allow all LSMs to provide xattrs for inode_init_security hook From: Roberto Sassu To: Mimi Zohar , Casey Schaufler , dmitry.kasatkin@gmail.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, stephen.smalley.work@gmail.com, eparis@parisplace.org Cc: 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 , Mengchi Cheng , miklos@szeredi.hu, linux-unionfs@vger.kernel.org, kamatam@amazon.com, yoonjaeh@amazon.com Date: Thu, 20 Apr 2023 16:10:42 +0200 In-Reply-To: <97849695ef53ab3186e59d8a2c6b74812f13ee19.camel@linux.ibm.com> References: <20230411172337.340518-1-roberto.sassu@huaweicloud.com> <2dc6486f-ce9b-f171-14fe-48a90386e1b7@schaufler-ca.com> <8e7705972a0f306922d8bc4893cf940e319abb19.camel@huaweicloud.com> <72b46d0f-75c7-ac18-4984-2bf1d6dad352@schaufler-ca.com> <82ee6ddf66bb34470aa7b591df4d70783fdb2422.camel@huaweicloud.com> <91f05dc4-a4b7-b40a-ba1a-0ccc489c84b2@schaufler-ca.com> <5c50d98f1e5745c88270ae4ad3de6d9a803db4c6.camel@huaweicloud.com> <48c6073f-59b0-f5d1-532e-fe4b912b939d@schaufler-ca.com> <0fccab67e496f10f4ee7bf2220e70a655013935f.camel@huaweicloud.com> <97849695ef53ab3186e59d8a2c6b74812f13ee19.camel@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-CM-TRANSID: GxC2BwB3JDvmR0Fk1Yo8Ag--.1954S2 X-Coremail-Antispam: 1UD129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/1tbiAQANBF1jj4xFswAAsD X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Thu, 2023-04-20 at 06:44 -0400, Mimi Zohar wrote: > On Thu, 2023-04-20 at 10:50 +0200, Roberto Sassu wrote: > > > It's possible. It's been a long time since I've looked at this. > > > I'm tempted to take a change to make overlayfs work upstream and > > > then worry about the ima changes. There seems to be a lot more > > > going on with the ima changes than is obvious from what's in the > > > Smack code. > > It doesn't sound like the patch set introduces the overlayfs bug. Correct. The first problem of overlayfs is that smack_dentry_create_files_as() override the credentials in a way that transmuting is not detected correctly anymore in smack_inode_init_security(). The process label is already overwritten with the directory label, at the time smack_inode_i nit_security() calls smk_access_entry(), so the latter will not find the transmuting rule that refers to the original process label. The second problem is that overlayfs temporarily creates the new directory in the working directory, that does not necessarily have the same label of the parent directory the new file/directory will be added to, causing the transmuting to be computed incorrectly. > The security_inode_init_security() change to initialize multiple LSMs > and IMA xattrs and include them in the EVM hmac calculation is straight > forward. > > In addition, the patch set creates the infrastructure for allowing > multiple per LSM xattrs, as requested, to be initialized in > security_inode_init_security() and included in the EVM hmac. > > Mimi > > > We could also set only SMACK64 in smack_inode_init_security(), and move > > SMACKTRANSMUTE64 later, when we figure out how to fix the case of > > overlayfs. > > > > IMA and EVM would work in both cases. Thanks to Mimi, I realized that adding SMACKTRANSMUTE64 in smack_inode_init_security() is actually necessary. Calling __vfs_getxattr() in smack_d_instantiate() causes the xattr to be added without EVM updating the HMAC (thus, making the HMAC invalid). Thanks Roberto