Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3273639rwo; Mon, 24 Jul 2023 08:40:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlHmE/StNttp57+ntzlWHRswjs87ds+kpFeDzacr6wnY/jx4iguLk1jpALlLOnVq4LyqRHru X-Received: by 2002:a05:6358:2786:b0:135:62de:ff7d with SMTP id l6-20020a056358278600b0013562deff7dmr6254481rwb.8.1690213246857; Mon, 24 Jul 2023 08:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690213246; cv=none; d=google.com; s=arc-20160816; b=ROx6fNIHgsAidI5IkGptcu/8RMJxiUc0dAwSMac1l8O2nq04RlRBplkfcnCTwt6ogB O2nyr+3uE/4jSi8SiijpNC4ybqlNUQzGjnm8VWkYZIjM4QN4vDaFw7pHydV0LXp9qL6S z8AiwRZhsmIYAXuLJc1UqqdsKiJSkO76/laRh06I68wjmKfiMyf42oHbtXJMB+Gob2pa H/ETJ2oQFRr/POcrt4IFrwbA4yi7Br37vH2sfraHk8hbnyvL6MBijO9Msuf/yVVRxTEo Cpckfdugzfts3YPWEdXHDnY9ZnJQReTAcTCn4uSifPiXwNjcN+9uopD6s3uloTzQapPW WWaA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Db25gBuWGl7dYsXhriAf38OhpNNBwS/d3RS2RRiH6S0=; fh=ZKWcyA0kesGCMzuKNl8fCcnARFCiY872iRD37qc+xr4=; b=rSes9f1tmzrnHC+Rg5x6YXTTVTvUWJ0u7NfrbpGF/jSQGvRI1FH8QbTQapcIQWhyiD R8LJFYDVsHWexpito0wDEIIQneGYl3sv79IqZ4pcmV/501vWcQTyU80ExAvAT2qgJM31 /P4NFRAvy5QGPSLp/7todidohy3IyfUtTEWcgo3BOGi+o5kEDMsSPnLW5v1DSagpcOTU wOPg+qlZrLvF2xSsCTawPEOE58bmaKhDdB5yW/OsUxqCNPcsgIwxZVALnzwHR0dSqZgx qS18GhH8H8NudGlL/DHTnQH5OCpKd3MK1LLcnIUgoNr/CorVSUx3L5cr879xjxcOEzzj 0rZA== 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 n7-20020a6543c7000000b0054febdc8ea2si6927710pgp.87.2023.07.24.08.40.33; Mon, 24 Jul 2023 08:40:46 -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 S229562AbjGXPTC (ORCPT + 99 others); Mon, 24 Jul 2023 11:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231131AbjGXPS5 (ORCPT ); Mon, 24 Jul 2023 11:18:57 -0400 Received: from frasgout11.his.huawei.com (unknown [14.137.139.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C2DA10EC; Mon, 24 Jul 2023 08:18:51 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.229]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4R8k6V1swTz9yGhH; Mon, 24 Jul 2023 23:07:30 +0800 (CST) Received: from huaweicloud.com (unknown [10.204.63.22]) by APP2 (Coremail) with SMTP id GxC2BwCHTlU3lr5kJcTzBA--.28220S4; Mon, 24 Jul 2023 16:18:38 +0100 (CET) From: Roberto Sassu To: casey@schaufler-ca.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Roberto Sassu , stable@vger.kernel.org Subject: [PATCH v2 2/5] smack: Handle SMACK64TRANSMUTE in smack_inode_setsecurity() Date: Mon, 24 Jul 2023 17:13:38 +0200 Message-Id: <20230724151341.538889-3-roberto.sassu@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724151341.538889-1-roberto.sassu@huaweicloud.com> References: <20230724151341.538889-1-roberto.sassu@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GxC2BwCHTlU3lr5kJcTzBA--.28220S4 X-Coremail-Antispam: 1UD129KBjvdXoW7Wr15tF17uw4xtrWfZFyxXwb_yoWkZFg_Wr 1jya4kXrs8A3W3Wa97Ar1Fvr92g3y8Xr1rW3Wft343Za4rXr1kta15Jry5WFW5Zw1xJ397 CFn8WFyfJw12qjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbsAYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r15M2 8IrcIa0xkI8VCY1x0267AKxVW8JVW5JwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK 021l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r 4j6F4UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4U JVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7V C0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j 6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r 4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF 67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2I x0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2 z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnU UI43ZEXa7IU8fcTPUUUUU== X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAQAIBF1jj5DcNQAAsF X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, MAY_BE_FORGED,RCVD_IN_MSPIKE_BL,RCVD_IN_MSPIKE_L3,RDNS_DYNAMIC, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Roberto Sassu If the SMACK64TRANSMUTE xattr is provided, and the inode is a directory, update the in-memory inode flags by setting SMK_INODE_TRANSMUTE. Cc: stable@vger.kernel.org Fixes: 5c6d1125f8db ("Smack: Transmute labels on specified directories") # v2.6.38.x Signed-off-by: Roberto Sassu --- security/smack/smack_lsm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index e599ce9453c..9eae830527d 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -2804,6 +2804,15 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name, if (value == NULL || size > SMK_LONGLABEL || size == 0) return -EINVAL; + if (strcmp(name, XATTR_SMACK_TRANSMUTE) == 0) { + if (!S_ISDIR(inode->i_mode) || size != TRANS_TRUE_SIZE || + strncmp(value, TRANS_TRUE, TRANS_TRUE_SIZE) != 0) + return -EINVAL; + + nsp->smk_flags |= SMK_INODE_TRANSMUTE; + return 0; + } + skp = smk_import_entry(value, size); if (IS_ERR(skp)) return PTR_ERR(skp); -- 2.34.1