Message ID | 20230724151341.538889-2-roberto.sassu@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1881862vqg; Mon, 24 Jul 2023 08:40:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlGTvi++loiec3iU63tuLOQ69eis3w1QUmhGm2PCdJE7K0Zf4Q/y2a/ApWfaCgfOLR/vcv7n X-Received: by 2002:a05:6a20:88:b0:131:dc49:13eb with SMTP id 8-20020a056a20008800b00131dc4913ebmr11049030pzg.35.1690213215112; Mon, 24 Jul 2023 08:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690213215; cv=none; d=google.com; s=arc-20160816; b=tb+ytTiD1AWxFntinALUixidVNlI+cvM8buY5hWp77phyT0xBlanMA1vMVcl47S2LH nRDTjIGIDh6zR4rQzYsXyzS6YRE5GEcE4Sxpv2MKpugkhpychQPN8id68aK9BxnnIhJg FPVg/gt0Nl9BU0Sjzp+VdJP1K1ysYWrOzi1pG/EG+O11Ta9x47bVvCa8PBgdWTqhiMSE KiYk1EXeREp3njgcZ0Lm9tpztxyrCKh6F7WH/vxpm7szmjbJCldAw6IKacMtECIkIgVf g3AcwjWyBWqZ1u/68wyS7gSnPZAccH9ZAMuHKL/RIP18cenShR643o3Y2PDcFw2JtEQ7 eDYg== 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=s9ET0lG7gwYTYGmXFA0OxoH2hzuuWG+wdn/BJW8zUPg=; fh=ZKWcyA0kesGCMzuKNl8fCcnARFCiY872iRD37qc+xr4=; b=fDFdIaZWPxiskqOylL5yaxLOIOeEN4QZ9VBFCM3mLrcX3I7wu3/bYwDJetz0Rpq1fU uxTh0q2b36MOQ8gGhYx6terXW5j6KlnBV/9cizsXQg6HiTV1dOkxe2cuzPQRs6z5lNN5 EMsPD2Ps7vjsxM7dCtiRW8KtrQ0rd5chImK5/HHMyt/pBSYPuQN1tFa+UW+K8LZIpixY q7xPBq1OVC01mLRib8SR8rxDi7EIm8WoZclS47WGeHjMV9UBroLybuCeNQYR8jQpq9vq TPmTdrYVlre1bm3xSTykDF+Oj/sw1qJscIUI7Q9m06cFstD/kM13cDH7qsSxzYsV4LLo 2MyQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a123-20020a636681000000b0055bbc6e2c6csi8829742pgc.491.2023.07.24.08.40.02; Mon, 24 Jul 2023 08:40:15 -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 S230408AbjGXPTA (ORCPT <rfc822;kautuk.consul.80@gmail.com> + 99 others); Mon, 24 Jul 2023 11:19:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230309AbjGXPSs (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 24 Jul 2023 11:18:48 -0400 Received: from frasgout13.his.huawei.com (unknown [14.137.139.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFA0E1B3; Mon, 24 Jul 2023 08:18:46 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.228]) by frasgout13.his.huawei.com (SkyGuard) with ESMTP id 4R8k6R1vxDzB0hnC; Mon, 24 Jul 2023 23:07:27 +0800 (CST) Received: from huaweicloud.com (unknown [10.204.63.22]) by APP2 (Coremail) with SMTP id GxC2BwCHTlU3lr5kJcTzBA--.28220S3; Mon, 24 Jul 2023 16:18:33 +0100 (CET) From: Roberto Sassu <roberto.sassu@huaweicloud.com> 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 <roberto.sassu@huawei.com>, stable@vger.kernel.org Subject: [PATCH v2 1/5] smack: Set SMACK64TRANSMUTE only for dirs in smack_inode_setxattr() Date: Mon, 24 Jul 2023 17:13:37 +0200 Message-Id: <20230724151341.538889-2-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--.28220S3 X-Coremail-Antispam: 1UD129KBjvdXoWrtw1UKryUCFW8Gry7Jw4Utwb_yoWDCrb_Ka 40yas5JrZ8Aa17Zw4xCwnYqrn2g348Xr1rG3Waya9Iya4rXr1rZa15GFyfAFZ8ur17Ga95 uFn8Ga4Yy347XjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbsAYFVCjjxCrM7AC8VAFwI0_Xr0_Wr1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r18M2 8IrcIa0xkI8VCY1x0267AKxVWUCVW8JwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK 021l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r 4j6F4UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4U JVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7V C0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j 6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r 4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF 67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2I x0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2 z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnU UI43ZEXa7IU1M7K7UUUUU== X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAgAIBF1jj4zfVAAEs8 X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, MAY_BE_FORGED,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772317012218547135 X-GMAIL-MSGID: 1772317012218547135 |
Series |
Smack transmute fixes
|
|
Commit Message
Roberto Sassu
July 24, 2023, 3:13 p.m. UTC
From: Roberto Sassu <roberto.sassu@huawei.com> 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 <roberto.sassu@huawei.com> --- 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 679156601a1..e599ce9453c 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -1262,7 +1262,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