Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1225131lqp; Fri, 22 Mar 2024 08:49:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWyhdyzSssddtdCW3qIO9jbPP9SSU+7Uyda30bW7h7P6l9vEX+f3EMW3ZDvIJ7n1G/BC0mSuA0uD/O+6o+vkNBii3MVqcF+gnElyqzM1Q== X-Google-Smtp-Source: AGHT+IGSZXXLvEZBnMakGJ1beOya99opTKvWMNfUtyMjsK3V/aX21SIYR2EHRdxshW2itqAHf/0i X-Received: by 2002:a17:90a:a902:b0:29f:a21e:3520 with SMTP id i2-20020a17090aa90200b0029fa21e3520mr1099pjq.43.1711122541731; Fri, 22 Mar 2024 08:49:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711122541; cv=pass; d=google.com; s=arc-20160816; b=B6JEK++8LCZJR2d596n2Bo1cXpixEJhXPI5YLDSdS5quK3uGbo4vqsF6D/iVfAcQvO 5uLbzErcPMtFVo1F2qzZrj2Xc8HneB+hOfdPIC4CltW6yTYJ+3rrAEYHwgM3PnBnOw2R 3Vogl/S2uguDs/JdigZBNFVdZG/akZFUL29aKGUjccy8QBJUqJ/RgTyxQ71e7sScOu/C zhZwba/IVOg8Q0FWuA9kuQLdqPiTzYjC9jnbOiYmUEyRpGplgpQnw2HuhOF7YviWeNhD EqvdTxHQm+MPyjckOWXP/Huzm64S/9IO2T4VFYxcQcmoB/V983Up58rw2jW6QbdhAVNr 6Etg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=V3xopeBqRHsaQdRj5IXLLEe8nPrzVg+x2GrrcJuO/NA=; fh=1xzdCevvnfLOvZcaUAUwD/PlXBYI+9rUJSnP5t+NW80=; b=VjSwMEPXpz14AX+Usotd+/Wx86uGatGYioFmLRxN9Riy0CGZovFt+fUmGEIQflxT8+ huQK+0goxYrmIX4VjLXQ9zuMp+zw7/zPhOedHPQnV/YngwFlzBWhs+J2srVG7RAu1IGs p5rFrBAJeBtjegcxaQwx+wFTDYpdS+2fOGjzwUqQec2wiyKi+n4lbS5M/917FKa8Fo4S VfU5IOq+2sLZ0EuawfYvrXNHSZ9e045zR6VxsOD+ABN+HYyEy9VzaeTH6905KifQYB4+ hxynvLVD5BDoN2mSEiauwmHtWou5jxlcvZvw18FTLZbT/VRauGfcvgl8VfFnR+0bQNq7 nn9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-111723-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111723-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id om6-20020a17090b3a8600b0029c6a7260ddsi2400557pjb.51.2024.03.22.08.49.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 08:49:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111723-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-111723-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111723-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E31A8285F9B for ; Fri, 22 Mar 2024 15:49:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DA0F5A0EE; Fri, 22 Mar 2024 15:48:27 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7645453E33; Fri, 22 Mar 2024 15:48:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711122507; cv=none; b=OWemclt5LykBR9+TuC8UWq8SSWQlbuy6FZDAAvREZhgqVsj4uZbD2FwK0qyu5fm6e7qF2x6Voacjo8fBJGUIjUcMxaPMcnsnIZfiY37u/EKdm2pIUdxsfDCj9RQNNKt4zqHEVDWt6nIuFrXcNplzz7vxMdUv1bS40/Jv8hu5HSw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711122507; c=relaxed/simple; bh=acFs/MQ+m3wH/w6F9F25EZh7RH06LQFjK8XjUdS9LF4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IVm27xP6bE5Yz+bjF8/Zr75Rk00YvV/ku4eZGeR/vIF51m7bLcJK6NY82d1ZSvIlzxMW54JNzCq0dyQNVGckeYUqGEfVs+NbnY4taVT6Lgtxc3vY14bmllTf5LLAbIXQj2Vnlzos+9ujpmndONMueccDy0uskUPOEJvkkUomV0A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4V1RWF35WJztQVr; Fri, 22 Mar 2024 23:46:01 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 7663D140157; Fri, 22 Mar 2024 23:48:20 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Fri, 22 Mar 2024 23:48:19 +0800 From: Li Zetao To: , , , , CC: , , , Subject: [RFC PATCH v2 3/5] ubifs: Initialize or update ACLs for inode Date: Fri, 22 Mar 2024 23:48:10 +0800 Message-ID: <20240322154812.215369-4-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240322154812.215369-1-lizetao1@huawei.com> References: <20240322154812.215369-1-lizetao1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemd500012.china.huawei.com (7.221.188.25) There are two scenarios where ACL needs to be updated, the first one is when creating the inode, and the second one is in the chmod process. When creating directories/files/device node/tmpfile, ACLs needs to be initialized, but symlink do not. Signed-off-by: Li Zetao --- v1 -> v2: Add initialization ACL in create_whiteout() v1: https://lore.kernel.org/all/20240319161646.2153867-3-lizetao1@huawei.com/ fs/ubifs/dir.c | 20 ++++++++++++++++++++ fs/ubifs/file.c | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index eac0fef801f1..243dfb478984 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -316,6 +316,10 @@ static int ubifs_create(struct mnt_idmap *idmap, struct inode *dir, goto out_fname; } + err = ubifs_init_acl(inode, dir); + if (err) + goto out_inode; + err = ubifs_init_security(dir, inode, &dentry->d_name); if (err) goto out_inode; @@ -376,6 +380,10 @@ static struct inode *create_whiteout(struct inode *dir, struct dentry *dentry) init_special_inode(inode, inode->i_mode, WHITEOUT_DEV); ubifs_assert(c, inode->i_op == &ubifs_file_inode_operations); + err = ubifs_init_acl(inode, dir); + if (err) + goto out_inode; + err = ubifs_init_security(dir, inode, &dentry->d_name); if (err) goto out_inode; @@ -466,6 +474,10 @@ static int ubifs_tmpfile(struct mnt_idmap *idmap, struct inode *dir, } ui = ubifs_inode(inode); + err = ubifs_init_acl(inode, dir); + if (err) + goto out_inode; + err = ubifs_init_security(dir, inode, &dentry->d_name); if (err) goto out_inode; @@ -1013,6 +1025,10 @@ static int ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir, goto out_fname; } + err = ubifs_init_acl(inode, dir); + if (err) + goto out_inode; + err = ubifs_init_security(dir, inode, &dentry->d_name); if (err) goto out_inode; @@ -1108,6 +1124,10 @@ static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir, ui->data = dev; ui->data_len = devlen; + err = ubifs_init_acl(inode, dir); + if (err) + goto out_inode; + err = ubifs_init_security(dir, inode, &dentry->d_name); if (err) goto out_inode; diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index a1f46919934c..808a2ded4f8c 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -41,6 +41,7 @@ #include #include #include +#include static int read_block(struct inode *inode, void *addr, unsigned int block, struct ubifs_data_node *dn) @@ -1297,6 +1298,9 @@ int ubifs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, else err = do_setattr(c, inode, attr); + if (!err && (attr->ia_valid & ATTR_MODE)) + err = posix_acl_chmod(idmap, dentry, inode->i_mode); + return err; } -- 2.34.1