Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp258321lqe; Wed, 10 Apr 2024 00:47:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3yZpgXubbdUwkwJ//DWZ4FgLeLZNjiPSDozs1sSqeLaiCOQ9lkD+KgwhjwRj7JVvIEYrSDVJeFtIuosGiNDzM2KFrcHPER5QE8W18/Q== X-Google-Smtp-Source: AGHT+IGBssxe6sRGfoq+JhfRJMyUdkt2U2ZEe2CgMiDIgPJJwdqib+7PLByMk3/UhppCqZzu1xuL X-Received: by 2002:a17:90b:4c44:b0:2a5:badb:2f6b with SMTP id np4-20020a17090b4c4400b002a5badb2f6bmr1873775pjb.26.1712735235496; Wed, 10 Apr 2024 00:47:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712735235; cv=pass; d=google.com; s=arc-20160816; b=V7PMlF8DY2RFQGo6NR3fkAGuai7yZ4ZaCoa7/moUpSRhQZuTA5RBaD0BVv3CMGH71M KqMRUhs7Zw2lp2GZ2sWfnVHl9czi90sTtvA5pB0962aaySAznipHo3XzWbcK3gu44obC VcEWICrgsQL9QcpLqEgQzDOJcOBuynXrlQe+RZssRdgbqA6BgbQB4flPqMxe8x+U0xm4 wldHdzdZOOGuutVhxpRTtpjPcYRgvOiJ7LMqfk+kKtAQXfzhqxY5LmObRozkUGAijaXN j3TvStaAuqzm62rX0l4upKKeMuNCZgVGXyiHjvb2YQ9pmYGS1vYdD7L14i9DWJDu72jc qxmQ== 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=Z9M1UbKE36+z7xOWYjagkpRogH1CoIvvPaYBqZlOmSQ=; fh=a84aJ7wGV7i8lW51pGyJvRoT4YsTs6703qz3m4vuOmA=; b=zE5MR/Ot+Mt0n8oZuBTLLCdBNzG/wDKD3fnzM81ijyu6Ke6mTt1zTl2h5eBScDiwJV Ym4VOe5Zjzrqp2pmZ6Ff4JwPXP2G69J7LqO4AvCsl4tRmbnC8YLF+KP8SmzXriAZzcrL osushz0CXEApLIQsyHYFVamol+DWMd/BiBTgAp2j2HHmnlaPqWscg0n1fhgL/VuxBycA zYZuVTM97LGE6G/80BTvGvNB44FHpkDRWAtQ8MPxrmbOZNCgJr7iEQKLOya1ukAZWnMA ewz/aYYyuxZqyqI3evmZEqon8flTt0Ai5iIxalWzrDmgf6Ck2tXyd2jqqFw0FwWBi0CW qKXg==; 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-138094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138094-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h6-20020a17090aea8600b002a090d525acsi1048047pjz.90.2024.04.10.00.47.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 00:47:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-138094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138094-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 2F580283167 for ; Wed, 10 Apr 2024 07:47:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE83F13D28A; Wed, 10 Apr 2024 07:46:28 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 5975B13D299 for ; Wed, 10 Apr 2024 07:46:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712735188; cv=none; b=m0dJaSoCZmq+IBqhlRzAkCLQe5f/xyR0uzd38R2igCVqBz3VceSIk8sTu9hr4mrVSmCikFLsFs+fBvvWwee42XOq39omkfuwVNOZXTSZpq0muzDuQCj5XAnQ026YrbdKw4i6cmdHkOTf76aNHpfvkh1myF0G4eI49NOt9YjL59Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712735188; c=relaxed/simple; bh=6enRpkCtRRhSMRNuro77x5hwv78gHH59C5x6cX07ujA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pWYYScdF0/ll7luBjMkwko1Gsf0nM0l8Ybje3yH08c4s/EdoaYcINgLTcsmRuz41xedM4gplP++2GV8qUk/yPHc1GNouBAiZIe7RZV9BUsoqxKUZ0/bFN5ATt8qSCTWNtoaHiHFaTFQ7ML5kWprbg7PP9fHQcpJFQSEAcO947nk= 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.190 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.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4VDvvm6Jn4z29lMv; Wed, 10 Apr 2024 15:43:32 +0800 (CST) Received: from kwepemm600013.china.huawei.com (unknown [7.193.23.68]) by mail.maildlp.com (Postfix) with ESMTPS id A876218001A; Wed, 10 Apr 2024 15:46:24 +0800 (CST) Received: from huawei.com (10.175.104.67) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 10 Apr 2024 15:46:21 +0800 From: Zhihao Cheng To: CC: , , Subject: [PATCH 6/9] ubifs: Move ui->data initialization after initializing security Date: Wed, 10 Apr 2024 15:37:48 +0800 Message-ID: <20240410073751.2522830-7-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410073751.2522830-1-chengzhihao1@huawei.com> References: <20240410073751.2522830-1-chengzhihao1@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: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600013.china.huawei.com (7.193.23.68) Host inode and its' xattr will be written on disk after initializing security when creating symlink or dev, then the host inode and its dentry will be written again in ubifs_jnl_update. There is no need to write inode data in the security initialization pass, just move the ui->data initialization after initializing security. Signed-off-by: Zhihao Cheng --- fs/ubifs/dir.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 551148de66cd..848988f2b7dc 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -1102,16 +1102,18 @@ static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir, goto out_fname; } + err = ubifs_init_security(dir, inode, &dentry->d_name); + if (err) { + kfree(dev); + goto out_inode; + } + init_special_inode(inode, inode->i_mode, rdev); inode->i_size = ubifs_inode(inode)->ui_size = devlen; ui = ubifs_inode(inode); ui->data = dev; ui->data_len = devlen; - err = ubifs_init_security(dir, inode, &dentry->d_name); - if (err) - goto out_inode; - mutex_lock(&dir_ui->ui_mutex); dir->i_size += sz_change; dir_ui->ui_size = dir->i_size; @@ -1184,6 +1186,10 @@ static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir, goto out_fname; } + err = ubifs_init_security(dir, inode, &dentry->d_name); + if (err) + goto out_inode; + ui = ubifs_inode(inode); ui->data = kmalloc(disk_link.len, GFP_NOFS); if (!ui->data) { @@ -1209,10 +1215,6 @@ static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir, ui->data_len = disk_link.len - 1; inode->i_size = ubifs_inode(inode)->ui_size = disk_link.len - 1; - err = ubifs_init_security(dir, inode, &dentry->d_name); - if (err) - goto out_inode; - mutex_lock(&dir_ui->ui_mutex); dir->i_size += sz_change; dir_ui->ui_size = dir->i_size; -- 2.39.2