Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3143131rdb; Thu, 16 Nov 2023 01:02:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/0Y/Wf1Pe79rc6p2uMtwoU2mTKyqzJem/SEsaGkhSBYssn7RGNsFgid5bEm1dwW03TmKA X-Received: by 2002:a17:903:485:b0:1cc:38e6:f097 with SMTP id jj5-20020a170903048500b001cc38e6f097mr1443953plb.7.1700125334155; Thu, 16 Nov 2023 01:02:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700125334; cv=none; d=google.com; s=arc-20160816; b=F6ClzZ7uygW09SKZs1sx9zJMtwpUZyBnRzyH9dq0Ay2Apg20SoRide7aPJVjJhhs+V M8Y/5gZtSFKoMeVwxExcT1T2siPAA029Wfi6nyYESFb2neNDmqI5pUWsSnz08t7Rd2Pi EGxSFvye469Sz8AYXHUm5m6pf0Swim1HOQ+N9PQzq4SU7+4SN7mDtef0gUWJnhdvOLqw Gq/V0AkUA3QN7uoWqHke++k4vklrL7G7adgGgbR2espHtwpkWauliwdhF9IHr0QMZuah ghdk5c0NamsrzZ0FcI3IgT2J6C7gkH2jfZT1jL0U8Pq7TKweJcZbrDWbc0Ap48FLBJVe 5EpA== 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=DE88AvAXuRlZ47LoCDTP9lOl3t/dJ/v0qM8UArlVrDo=; fh=7LGHJjxlgu98T/OBO4+U/pprB9WbjW7wNGdLE5+Tdi8=; b=uJNNVDf+3kWD8ZwkzolbkaJgGAZPSG5HrbHUmWxeZoONic7IGPc/5wzlM+meXIJtXM PNeLqlH4xQ9GXoRmeSQ/ZP+83d8xS9PIOxe1SWm7SEeem+FnhKhoJiNwhptt7erEpMY6 bc60YRAgp1xb7bslEEVpkbaOQXF3fBDp2vQgXUrGCxxbeAKp5QeRHAqjzh/Jab9/Hr3j ITO3KEwX3bqMlqd2nJ45v17CcSoOSgtCXg01+Hn5R4cC/u5uH0YfZni9qfQQoIcNp3rh Crm6XThGesnOOHfmzzlxLmWZx1pof/R3fadSiASjUjmyKTvf38t2BGkYopC2G1n6s7VB vA7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id k17-20020a170902c41100b001cad3a9ff1dsi12950583plk.571.2023.11.16.01.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 01:02:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7A05380A186F; Thu, 16 Nov 2023 01:02:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344976AbjKPJCL (ORCPT + 99 others); Thu, 16 Nov 2023 04:02:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235223AbjKPJCB (ORCPT ); Thu, 16 Nov 2023 04:02:01 -0500 Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5DB7A4; Thu, 16 Nov 2023 01:01:57 -0800 (PST) Received: from mail02.huawei.com (unknown [172.18.147.228]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4SWDFz1fbHz9yTLB; Thu, 16 Nov 2023 16:48:23 +0800 (CST) Received: from huaweicloud.com (unknown [10.204.63.22]) by APP1 (Coremail) with SMTP id LxC2BwAnY3Nq2lVlSdzEAA--.16671S3; Thu, 16 Nov 2023 10:01:43 +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 v3 1/5] smack: Set SMACK64TRANSMUTE only for dirs in smack_inode_setxattr() Date: Thu, 16 Nov 2023 10:01:21 +0100 Message-Id: <20231116090125.187209-2-roberto.sassu@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231116090125.187209-1-roberto.sassu@huaweicloud.com> References: <20231116090125.187209-1-roberto.sassu@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: LxC2BwAnY3Nq2lVlSdzEAA--.16671S3 X-Coremail-Antispam: 1UD129KBjvdXoWrtw1UKryUCFW8Gry7Jw4Utwb_yoWDCrg_Ga 40yas5XrZ8A3W7Zws7CwnY9Fn2gay8Xr1rGa1aya9Iya4rXw1rZa15GFyrAFZ8uw17Ga95 CFnxG34Yy347XjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbsAYFVCjjxCrM7AC8VAFwI0_Xr0_Wr1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r18M2 8IrcIa0xkI8VCY1x0267AKxVWUCVW8JwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK 021l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r 4j6F4UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4j 6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7V C0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j 6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r 4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF 67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2I x0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2 z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnU UI43ZEXa7IU1M7K7UUUUU== X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAQADBF1jj5aE+QAAsc X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 16 Nov 2023 01:02:12 -0800 (PST) From: Roberto Sassu Since the SMACK64TRANSMUTE xattr makes sense only for directories, enforce this restriction in smack_inode_setxattr(). 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 53336d7daa93..0027803a43ac 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -1313,7 +1313,8 @@ static int smack_inode_setxattr(struct mnt_idmap *idmap, check_star = 1; } else if (strcmp(name, XATTR_NAME_SMACKTRANSMUTE) == 0) { check_priv = 1; - if (size != TRANS_TRUE_SIZE || + if (!S_ISDIR(d_backing_inode(dentry)->i_mode) || + size != TRANS_TRUE_SIZE || strncmp(value, TRANS_TRUE, TRANS_TRUE_SIZE) != 0) rc = -EINVAL; } else -- 2.34.1