From nobody Mon Feb 9 03:47:55 2026 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.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 B8D8023759; Tue, 23 Apr 2024 06:45:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854705; cv=none; b=mFgp0k8RI3qxnrrgJYDsHBR27AfeVVXkd5zJKT0iq1i2gltaoXybNMHyd3l7H0tw9eazwlhH7Rw33yliVgO7EhsVFABVEsNQPRNID4Zwha/TP6UM7NB6g5P6kTGlDLBV1UDOX/5Rps/I4OIK+vPV4aZw4YbhPAKjHOs8V1rCN6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854705; c=relaxed/simple; bh=IulC/ATCcoLSPdrAFZWg4ug+gueZGiT3MDCm8W28Vq4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nYWO049WV3v6Mn7ckYVKUXS5jGoiT/wxfl3/QBy1WT9uLGsuORTkjtnCetk69CwksusSgnI0dqvt3im5kYDbyqY4xF1cOCI40x56gQHUddJQFG4QmZenAnbJD5UqL2sEtd055Cli2jb1HUAgyUyak1CPm95hAbNWEbprPkvX2IU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=ICQGqULk; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=ruEYtP5K; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="ICQGqULk"; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="ruEYtP5K" Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id F0E1A1F9F; Tue, 23 Apr 2024 06:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854250; bh=/TmnypWkd4e3Jhx5tOr+iDQBILNtv2PoZ4t0EcJVSoU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ICQGqULkaNxoyW/vsSSM0bDRfeoBUrvhe1+0wFfTniVC/RD0kNFd/DVFXTTH5Q2Ak 1S+htBAhy5rYjEGbPhc3r4CppR0KHfGGipXJ4mO3EggWdsYFxTV9VP6BpJS9BCbRdJ K5wcnSqw/dfsHpqHw/F0s3zQ9gQqJwm4y80xLzhU= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 7D586214E; Tue, 23 Apr 2024 06:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854701; bh=/TmnypWkd4e3Jhx5tOr+iDQBILNtv2PoZ4t0EcJVSoU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ruEYtP5KTnM9ENk7pIrTbcCP1UEBEZtUYc18eQNB3NxxWncVAX8GMbmufjMFo3IcY TrEHwi/CFrRfoz93Z0ZeQ48RHDKC7ty3lC4nS3lqPgEKS4D7dmniDJIFftWOeCon1B jWgddj2W/WAW9P2MUxe6Uhb42EosgJfZ6JYU4ZlY= Received: from ntfs3vm.paragon-software.com (192.168.211.160) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Tue, 23 Apr 2024 09:45:00 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov , Subject: [PATCH 1/9] fs/ntfs3: Taking DOS names into account during link counting Date: Tue, 23 Apr 2024 09:44:20 +0300 Message-ID: <20240423064428.8289-2-almaz.alexandrovich@paragon-software.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> References: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Content-Type: text/plain; charset="utf-8" When counting and checking hard links in an ntfs file record, struct MFT_REC { struct NTFS_RECORD_HEADER rhdr; // 'FILE' __le16 seq; // 0x10: Sequence number for this record. >> __le16 hard_links; // 0x12: The number of hard links to record. __le16 attr_off; // 0x14: Offset to attributes. ... the ntfs3 driver ignored short names (DOS names), causing the link count to be reduced by 1 and messages to be output to dmesg. For Windows, such a situation is a minor error, meaning chkdsk does not rep= ort errors on such a volume, and in the case of using the /f switch, it silently corrects them, reporting that no errors were found. This does not affect the consistency of the file system. Nevertheless, the behavior in the ntfs3 driver is incorrect and changes the content of the file system. This patch should fix that. PS: most likely, there has been a confusion of concepts MFT_REC::hard_links and inode::__i_nlink. Fixes: 82cae269cfa95 ("fs/ntfs3: Add initialization of super block") Signed-off-by: Konstantin Komarov Cc: stable@vger.kernel.org --- fs/ntfs3/inode.c | 7 ++++--- fs/ntfs3/record.c | 11 ++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index eb7a8c9fba01..05f169018c4e 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -37,7 +37,7 @@ static struct inode *ntfs_read_mft(struct inode *inode, bool is_dir; unsigned long ino =3D inode->i_ino; u32 rp_fa =3D 0, asize, t32; - u16 roff, rsize, names =3D 0; + u16 roff, rsize, names =3D 0, links =3D 0; const struct ATTR_FILE_NAME *fname =3D NULL; const struct INDEX_ROOT *root; struct REPARSE_DATA_BUFFER rp; // 0x18 bytes @@ -200,11 +200,12 @@ static struct inode *ntfs_read_mft(struct inode *inod= e, rsize < SIZEOF_ATTRIBUTE_FILENAME) goto out; =20 + names +=3D 1; fname =3D Add2Ptr(attr, roff); if (fname->type =3D=3D FILE_NAME_DOS) goto next_attr; =20 - names +=3D 1; + links +=3D 1; if (name && name->len =3D=3D fname->name_len && !ntfs_cmp_names_cpu(name, (struct le_str *)&fname->name_len, NULL, false)) @@ -429,7 +430,7 @@ static struct inode *ntfs_read_mft(struct inode *inode, ni->mi.dirty =3D true; } =20 - set_nlink(inode, names); + set_nlink(inode, links); =20 if (S_ISDIR(mode)) { ni->std_fa |=3D FILE_ATTRIBUTE_DIRECTORY; diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index 6aa3a9d44df1..6c76503edc20 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -534,16 +534,9 @@ bool mi_remove_attr(struct ntfs_inode *ni, struct mft_= inode *mi, if (aoff + asize > used) return false; =20 - if (ni && is_attr_indexed(attr)) { + if (ni && is_attr_indexed(attr) && attr->type =3D=3D ATTR_NAME) { u16 links =3D le16_to_cpu(ni->mi.mrec->hard_links); - struct ATTR_FILE_NAME *fname =3D - attr->type !=3D ATTR_NAME ? - NULL : - resident_data_ex(attr, - SIZEOF_ATTRIBUTE_FILENAME); - if (fname && fname->type =3D=3D FILE_NAME_DOS) { - /* Do not decrease links count deleting DOS name. */ - } else if (!links) { + if (!links) { /* minor error. Not critical. */ } else { ni->mi.mrec->hard_links =3D cpu_to_le16(links - 1); --=20 2.34.1 From nobody Mon Feb 9 03:47:55 2026 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.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 5621523748; Tue, 23 Apr 2024 06:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854708; cv=none; b=aDqIRQZwYa6ZSifRnhYPYU3v2/yTwQJmevUa1NrvJYQOrRlIoS1YGSDgzS0p3MzquQRrxSj+gv3wasrv4LT4ayIt+qs7p3vC2n50miL/1up+KL4tt7bnVj5KdYpgezr8nQn6iwgey/Rn8ZNQE2xDbnopK0QpiyeWk5+VrOkUnNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854708; c=relaxed/simple; bh=nTn0zaTNrShbk3paxud+AkmRRpbMA7FsQQJ0oaxqvyg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YywkaQkRmp6RsLNB54STQ9WjVPHpoWq6BL3bAgP2DspyLhLshEHNqfOdpC8bMY1rtVAD8T7MAp78F5L4YgFdC3DqUl0fJNGy6VVziIdbPVU4dAijv+P4q2TQ6NsvvfbizAUT+kCrEWBjUExOAjz2o8irlfmFE9qjOgPnxccV+os= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=TvmV5wgd; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="TvmV5wgd" Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 92DE22001; Tue, 23 Apr 2024 06:37:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854253; bh=3cVk0H+rl0oBurqKEXVfmBKXIrjKBQMQ/qE3urFKI1g=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=TvmV5wgd+8JqVtFIywK227+EAgZrJEpNe57VElPf38rTtzMdeZ+YzgnUc+33b27A/ qJPsP6Cmj7XmTqNJJDN1uaugIwirtN2fwWdC30wcM4mi4EYBh+DoEekO6ogV2x9IHJ Smgj7jfCi4I0mRqKMw5ltDX4SSP0WR7ckRjF7LAk= Received: from ntfs3vm.paragon-software.com (192.168.211.160) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Tue, 23 Apr 2024 09:45:04 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov , Subject: [PATCH 2/9] fs/ntfs3: Remove max link count info display during driver init Date: Tue, 23 Apr 2024 09:44:21 +0300 Message-ID: <20240423064428.8289-3-almaz.alexandrovich@paragon-software.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> References: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Content-Type: text/plain; charset="utf-8" Removes the output of this purely informational message from the kernel buffer: "ntfs3: Max link count 4000" Signed-off-by: Konstantin Komarov Cc: stable@vger.kernel.org --- fs/ntfs3/super.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 9df7c20d066f..ac4722011140 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -1804,8 +1804,6 @@ static int __init init_ntfs_fs(void) { int err; =20 - pr_info("ntfs3: Max link count %u\n", NTFS_LINK_MAX); - if (IS_ENABLED(CONFIG_NTFS3_FS_POSIX_ACL)) pr_info("ntfs3: Enabled Linux POSIX ACLs support\n"); if (IS_ENABLED(CONFIG_NTFS3_64BIT_CLUSTER)) --=20 2.34.1 From nobody Mon Feb 9 03:47:55 2026 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.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 D59F241A94; Tue, 23 Apr 2024 06:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854714; cv=none; b=bqO5PuwcqRpmfb8YMyrwt+CJGMLHVY62EW4dCOyAna6h7ZsoxQz65B5IJtrymkwJRQk57OzUqc6as7ir7lqVMQhXqTZ4Veos/Y+z/lBjaAEgh+j9AoCCl+AyWOjewYzFuMSpfTONeExP+db4x6ZphOkOsu7otwMBCG6/uuaqX2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854714; c=relaxed/simple; bh=FEFl4Wn3CE2UFGs9JOKQSkukkncytot6qPwH1xm43u0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iSwC9b9sMccazTMRj0vgRGcBE7T1oizU61b9+b8XxJFuz82zASsElrmRSx1BLY/JFkr/ziH0nTRXLhqiGvU8Sduz46KAT4BrluhJPwpJrcDNbtBgCGs3W/59sZeewTCup1N1juBhQ95mVSH17myNpKUKMdEXPr+cyUldN56WGys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=hJX4aZUA; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=SvZZygVO; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="hJX4aZUA"; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="SvZZygVO" Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 2E15A1E80; Tue, 23 Apr 2024 06:37:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854259; bh=XNDdOBfydzO5hUu6PPstrbCwKxTzEdjYBc1BzGfVFsA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=hJX4aZUAamhX5HafEIE3qIXTnph+X3oTbwTEAIU4kVtqKv9qTIUhWwP6xPD9jOevL WwEr0H/RhPCPz+/0HsecmXvU7XQs/lA719P6l4le6M28Dgn3l7z/nUSeqdn5clqKN+ ZEQlx5HwTOn/zuG13A7L0IolqH9e1IUTw8wOxAy8= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id E73E1214E; Tue, 23 Apr 2024 06:45:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854710; bh=XNDdOBfydzO5hUu6PPstrbCwKxTzEdjYBc1BzGfVFsA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=SvZZygVOMyZ5cYwrFSW7qsBghW9MufpU1dho+8vK8MpZ9fuLo8LxWTbNXiswHrJEB xdwpfMWNkYn0l2bXfpHPvrP9tKDQ8rVm9GHCp8GOL7gcU+h9bgU/Ie6gKNCUq/CR7/ gW7QrOp2hl9le3/GFw10Kqmm/02nIzZR3mEwW+w0= Received: from ntfs3vm.paragon-software.com (192.168.211.160) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Tue, 23 Apr 2024 09:45:10 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov Subject: [PATCH 3/9] fs/ntfs3: Missed le32_to_cpu conversion Date: Tue, 23 Apr 2024 09:44:22 +0300 Message-ID: <20240423064428.8289-4-almaz.alexandrovich@paragon-software.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> References: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Content-Type: text/plain; charset="utf-8" NTFS data structure fields are stored in little-endian, it is necessary to take this into account when working on big-endian architectures. Fixes: 1b7dd28e14c47("fs/ntfs3: Correct function is_rst_area_valid") Signed-off-by: Konstantin Komarov --- fs/ntfs3/fslog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index 855519713bf7..d9d08823de62 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -517,7 +517,7 @@ static inline bool is_rst_area_valid(const struct RESTA= RT_HDR *rhdr) seq_bits -=3D 1; } =20 - if (seq_bits !=3D ra->seq_num_bits) + if (seq_bits !=3D le32_to_cpu(ra->seq_num_bits)) return false; =20 /* The log page data offset and record header length must be quad-aligned= . */ --=20 2.34.1 From nobody Mon Feb 9 03:47:55 2026 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.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 452AC24211; Tue, 23 Apr 2024 06:45:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854715; cv=none; b=F0R4TsgxT1FPJY7j6uCD1JvoDD9rl3kPLJN9a+CxGo01BCWFixycDTbClO8xwBxdK56JQqnwKafoF3/iv7W9pHSRJjCD/cwxbhZwwu2HRnpTNysUwvmk5Vbv7jfCm4Yp0DuUTt2jyxJYnqGfYJ3UJT23STTmeKFqbtTUx4Skzrw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854715; c=relaxed/simple; bh=1iM7oXzE1ltg9hNvhIPQzODPIU5RwsKJZsI0BBrzNYk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Nf3ewH9rvgTjP9nGbQ9vqn5GD+qIFxWvvX26pJgQVpNl0+Go/a8fPDrubSpcsrBIov8FG/t10mfrYWojX/A9yZfJngh0Nkc+7RSJEtO1O7NpXyjxJ97k6gafYC0fFMS4TeJnhGPKf+w8uv0yEi9rBtJXsvAVVnvui5+adP/UoDM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=BsQFDVPS; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="BsQFDVPS" Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id AD8291F9F; Tue, 23 Apr 2024 06:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854260; bh=MIif7cGFVX2FHQK2yktmsLp80cdQAVR8pZsch5VO5bw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BsQFDVPSbcFoi+a743GvnWSDWS8DkCf8ZJXzlwzcqCiBGz+c7NNbdb8oCmbwQwl8J PEzyemzfXamo/AhGxZzb5hBiQ9HDnkPgatK/QeFCIbTeyRdbJ0xkGTmAPTmAWvH9vG A+Ko+iTLMZj8DXbh168wZluaX0jUhX4Fkf85wIWk= Received: from ntfs3vm.paragon-software.com (192.168.211.160) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Tue, 23 Apr 2024 09:45:12 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov Subject: [PATCH 4/9] fs/ntfs3: Check 'folio' pointer for NULL Date: Tue, 23 Apr 2024 09:44:23 +0300 Message-ID: <20240423064428.8289-5-almaz.alexandrovich@paragon-software.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> References: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Content-Type: text/plain; charset="utf-8" It can be NULL if bmap is called. Fixes: 82cae269cfa95 ("fs/ntfs3: Add initialization of super block") Signed-off-by: Konstantin Komarov --- fs/ntfs3/inode.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 05f169018c4e..502a527e51cd 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -571,13 +571,18 @@ static noinline int ntfs_get_block_vbo(struct inode *= inode, u64 vbo, clear_buffer_uptodate(bh); =20 if (is_resident(ni)) { - ni_lock(ni); - err =3D attr_data_read_resident(ni, &folio->page); - ni_unlock(ni); - - if (!err) - set_buffer_uptodate(bh); + bh->b_blocknr =3D RESIDENT_LCN; bh->b_size =3D block_size; + if (!folio) { + err =3D 0; + } else { + ni_lock(ni); + err =3D attr_data_read_resident(ni, &folio->page); + ni_unlock(ni); + + if (!err) + set_buffer_uptodate(bh); + } return err; } =20 --=20 2.34.1 From nobody Mon Feb 9 03:47:55 2026 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.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 ABF2B4595D; Tue, 23 Apr 2024 06:45:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854718; cv=none; b=klo3PEUt2gtEsUZeGIMc9DNdxmgyXouljF3i7E+/9SKcLYIS8r7vTEe/r3juSikQViJbLI8TYHWBzvLivY2DbsGr1ej4KuOFwUClB5CGTPTlPMJ1RTBPuG94A/E66GTVODCLg+EcyDbeH5C7WyaCCJ0iz/sCXpuIsb8+iv3Hs6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854718; c=relaxed/simple; bh=PpNCeX2vIZbOq5pHOwaTjW24wzz7Yp+rH1lhM8h6+gk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s7mqhPfax672plxb7oTye85MtcTDxEMhnzqorHx5BsZ9T1wZTpcr6VBwMnUl9YepivT+liMUBibCKEDTTOGzBkn2/h6TDqKaI5y+svKlCETC0a7+JXlHHtmbtR9QsbnMd00DqSke022P8vK8U8TAmdMsujJIx3dkUzd+R5nuNm8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=bswXqhWj; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=MPPu7JOk; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="bswXqhWj"; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="MPPu7JOk" Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 2A6441E80; Tue, 23 Apr 2024 06:37:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854263; bh=XTKHZat80LdFM14j9Ei2s+Mcqpv92Rbg2DEI+Yn1jpM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=bswXqhWj1nD1rtJSCDQX/LnWM+Co7nxCPVdMYZJOTzg/XrsMALg5PexxgecsuDXN7 GbERE4t+a1kP+rnjTgCoaVi3PZXNnOFXAbiE3d0fZtHNpKI5YDUD9zBHg3dro0UbCL 9nWTlZEPYhFmIsINaEOgXJzoR8mSATAM0C4Jx3Lo= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id E35C5214E; Tue, 23 Apr 2024 06:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854714; bh=XTKHZat80LdFM14j9Ei2s+Mcqpv92Rbg2DEI+Yn1jpM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=MPPu7JOkahmadcrZKOd06cD0yPtyYdK2Ho5qFlbACjEDh0vYIuniNCqTo9AUChTh4 rDzqR/L5a3kPUB3ZEvFhcIr7MsffUbo0r6t1nBiopVEdgneRabi9uVaKvBxnY4Ix4z X2dPbqw6hzgRjs23FbnJ+zEy1QYI/QSnPLnTVKtA= Received: from ntfs3vm.paragon-software.com (192.168.211.160) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Tue, 23 Apr 2024 09:45:14 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov Subject: [PATCH 5/9] fs/ntfs3: Use 64 bit variable to avoid 32 bit overflow Date: Tue, 23 Apr 2024 09:44:24 +0300 Message-ID: <20240423064428.8289-6-almaz.alexandrovich@paragon-software.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> References: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Content-Type: text/plain; charset="utf-8" For example, in the expression: vbo =3D 2 * vbo + skip Fixes: b46acd6a6a627 ("fs/ntfs3: Add NTFS journal") Signed-off-by: Konstantin Komarov --- fs/ntfs3/fslog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index d9d08823de62..d7807d255dfe 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -1184,7 +1184,8 @@ static int read_log_page(struct ntfs_log *log, u32 vb= o, static int log_read_rst(struct ntfs_log *log, bool first, struct restart_info *info) { - u32 skip, vbo; + u32 skip; + u64 vbo; struct RESTART_HDR *r_page =3D NULL; =20 /* Determine which restart area we are looking for. */ --=20 2.34.1 From nobody Mon Feb 9 03:47:55 2026 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.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 9115E481B8; Tue, 23 Apr 2024 06:45:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854724; cv=none; b=X3XxUZFQhPEG9K3j2nTGzPfY3YD1cvNYgcM8k0f+LvAkK/FXh3VRoiZ/z4BDz0lhh/syL5y9wID94J+V8dQDrDrmb++TbSySssF7v/D7PAKn5Z5+LTXoNfzKF8MXr9wmAvtLGdpMa2hPkGd6qhTEEb4qHYsO+keeaKrVlUrpTA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854724; c=relaxed/simple; bh=xDey/bPDIETOzyCtWip2cVT9cVPRQ8dkx4VUAGlDI9I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BUpEudRwUF0WOp7V0g9THz0mziHRPdRYPWRJvAC/ocrtfeR1TF6Ooed16JHsmXRh8xxTusLZpVs036gPLg+MEOR22XouoR/8spg71UkljzvhxePTa3gneYOr9k6UOQo+j/9XH0w9nhd95QdOR9je3huUIdi7OIrRjofPyLTzVRQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=HOBFpW/J; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="HOBFpW/J" Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id C0E061E80; Tue, 23 Apr 2024 06:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854269; bh=8abgFsR/Ui2xo5ZXw2cy57yMyvZkyHIC4gHtv2Ld0QM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=HOBFpW/JtnMEXCelQPtYAct0c5gHYYXkLfw5GiGcTRJFo77gSQGlDQsubvBaxyXgi VPIw/DsCPNMUqmoOxBzKjFngrj5oUaQHI9c5D6KebJkabfYURDGX5k81CETUlpZZ8F OSPLQtsQV6ueiXWrlLVL+/0kpkF3E4+Y4NM2STlw= Received: from ntfs3vm.paragon-software.com (192.168.211.160) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Tue, 23 Apr 2024 09:45:21 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov , kernel test robot , Dan Carpenter Subject: [PATCH 6/9] fs/ntfs3: Use variable length array instead of fixed size Date: Tue, 23 Apr 2024 09:44:25 +0300 Message-ID: <20240423064428.8289-7-almaz.alexandrovich@paragon-software.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> References: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Content-Type: text/plain; charset="utf-8" Should fix smatch warning: ntfs_set_label() error: __builtin_memcpy() 'uni->name' too small (20 vs 25= 6) Fixes: 4534a70b7056f ("fs/ntfs3: Add headers and misc files") Reported-by: kernel test robot Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202401091421.3RJ24Mn3-lkp@intel.com/ Signed-off-by: Konstantin Komarov --- fs/ntfs3/ntfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h index 9c7478150a03..3d6143c7abc0 100644 --- a/fs/ntfs3/ntfs.h +++ b/fs/ntfs3/ntfs.h @@ -59,7 +59,7 @@ struct GUID { struct cpu_str { u8 len; u8 unused; - u16 name[10]; + u16 name[]; }; =20 struct le_str { --=20 2.34.1 From nobody Mon Feb 9 03:47:55 2026 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.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 E6EF451C52; Tue, 23 Apr 2024 06:45:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854728; cv=none; b=DYQ0XwuMm/Y85ogwDdv9odnxaeOGQ3HOoGK96j4ds+Y3tvlmSSsCvvzaglT2J/5ICekp7TnIalHm3Nsnqk8jQ/JDM/TxdQtGdQHW+S/GOArVZi2H65O8xM+8aO4zKWBh/sD5v6mczTrT2YcU8+/uTJjitrEvw2ZEb/nqvOvHGW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854728; c=relaxed/simple; bh=OEvsy72w2/oHIHyWTeUFOvZzoFVDn27729yVj2nfqE4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KLDb3gvuAKnZezxgs4qBgQMRFa2tGaBZTjXzHqLRGN4h7RwKKot7BKDoOZ+8FZxkYVTyy1HuUQy7I7wbhL94+RspiYjBWE2oaollosXdHotyaOpouuHth9IqIODkTPOQELq+pSgg13EP9gkYNp359fTlIH6g+ZchVrUrIr8cmrk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=BN6tKBhY; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=srybzOEg; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="BN6tKBhY"; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="srybzOEg" Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 5B2541F9F; Tue, 23 Apr 2024 06:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854272; bh=WYhMvnTLAQTUHZ0POkyI6ill1C+PyV1o7dPY2X+1+50=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BN6tKBhYFyRWc6HoWwY/eWu7rOZuExi9R29wC2U7P71BzzCZh1AIIDz7Sy4JbYG+C CMXQyihmcimUGfuf+lu1xrZS86LDI28I+3gdIGf6ipH6GjehPMDEODA3Vklr+7j/Kr vY5OJoTwMRsXPtpqgFn71drVDKECd5wN1FADT25U= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 1F54B214E; Tue, 23 Apr 2024 06:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854724; bh=WYhMvnTLAQTUHZ0POkyI6ill1C+PyV1o7dPY2X+1+50=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=srybzOEghBD/m1cvyaiYx8dKlYqVGsFAo3QVocISdPbpUab0s0OB6nFNx9fhAv1hn EJYleJJPFJ/q8VGjFvjX3zXCr57+Ejt7nxC6bXpLrfRhPfT9kBj5IMs/SA1NOnkxRz xeXLZDUS6QGK4zdCiuc/Pchs9ztliu+yJIiQZsGU= Received: from ntfs3vm.paragon-software.com (192.168.211.160) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Tue, 23 Apr 2024 09:45:23 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov , Al Viro Subject: [PATCH 7/9] fs/ntfs3: Redesign ntfs_create_inode to return error code instead of inode Date: Tue, 23 Apr 2024 09:44:26 +0300 Message-ID: <20240423064428.8289-8-almaz.alexandrovich@paragon-software.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> References: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Content-Type: text/plain; charset="utf-8" As Al Viro correctly pointed out, there is no need to return the whole structure to check the error. https://lore.kernel.org/ntfs3/20240322023515.GK538574@ZenIV/ Acked-by: Al Viro Signed-off-by: Konstantin Komarov --- fs/ntfs3/inode.c | 22 +++++++++++----------- fs/ntfs3/namei.c | 31 ++++++++----------------------- fs/ntfs3/ntfs_fs.h | 9 ++++----- 3 files changed, 23 insertions(+), 39 deletions(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 502a527e51cd..8fdcf37b3186 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -1216,11 +1216,10 @@ ntfs_create_reparse_buffer(struct ntfs_sb_info *sbi= , const char *symname, * * NOTE: if fnd !=3D NULL (ntfs_atomic_open) then @dir is locked */ -struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, - struct dentry *dentry, - const struct cpu_str *uni, umode_t mode, - dev_t dev, const char *symname, u32 size, - struct ntfs_fnd *fnd) +int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, + struct dentry *dentry, const struct cpu_str *uni, + umode_t mode, dev_t dev, const char *symname, u32 size, + struct ntfs_fnd *fnd) { int err; struct super_block *sb =3D dir->i_sb; @@ -1245,6 +1244,9 @@ struct inode *ntfs_create_inode(struct mnt_idmap *idm= ap, struct inode *dir, struct REPARSE_DATA_BUFFER *rp =3D NULL; bool rp_inserted =3D false; =20 + /* New file will be resident or non resident. */ + const bool new_file_resident =3D 1; + if (!fnd) ni_lock_dir(dir_ni); =20 @@ -1484,7 +1486,7 @@ struct inode *ntfs_create_inode(struct mnt_idmap *idm= ap, struct inode *dir, attr->size =3D cpu_to_le32(SIZEOF_RESIDENT); attr->name_off =3D SIZEOF_RESIDENT_LE; attr->res.data_off =3D SIZEOF_RESIDENT_LE; - } else if (S_ISREG(mode)) { + } else if (!new_file_resident && S_ISREG(mode)) { /* * Regular file. Create empty non resident data attribute. */ @@ -1721,12 +1723,10 @@ struct inode *ntfs_create_inode(struct mnt_idmap *i= dmap, struct inode *dir, if (!fnd) ni_unlock(dir_ni); =20 - if (err) - return ERR_PTR(err); - - unlock_new_inode(inode); + if (!err) + unlock_new_inode(inode); =20 - return inode; + return err; } =20 int ntfs_link_inode(struct inode *inode, struct dentry *dentry) diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c index edb6a7141246..71498421ce60 100644 --- a/fs/ntfs3/namei.c +++ b/fs/ntfs3/namei.c @@ -107,12 +107,8 @@ static struct dentry *ntfs_lookup(struct inode *dir, s= truct dentry *dentry, static int ntfs_create(struct mnt_idmap *idmap, struct inode *dir, struct dentry *dentry, umode_t mode, bool excl) { - struct inode *inode; - - inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S_IFREG | mode, 0, - NULL, 0, NULL); - - return IS_ERR(inode) ? PTR_ERR(inode) : 0; + return ntfs_create_inode(idmap, dir, dentry, NULL, S_IFREG | mode, 0, + NULL, 0, NULL); } =20 /* @@ -123,12 +119,8 @@ static int ntfs_create(struct mnt_idmap *idmap, struct= inode *dir, static int ntfs_mknod(struct mnt_idmap *idmap, struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) { - struct inode *inode; - - inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, mode, rdev, NULL, 0, - NULL); - - return IS_ERR(inode) ? PTR_ERR(inode) : 0; + return ntfs_create_inode(idmap, dir, dentry, NULL, mode, rdev, NULL, 0, + NULL); } =20 /* @@ -200,15 +192,12 @@ static int ntfs_symlink(struct mnt_idmap *idmap, stru= ct inode *dir, struct dentry *dentry, const char *symname) { u32 size =3D strlen(symname); - struct inode *inode; =20 if (unlikely(ntfs3_forced_shutdown(dir->i_sb))) return -EIO; =20 - inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S_IFLNK | 0777, 0, - symname, size, NULL); - - return IS_ERR(inode) ? PTR_ERR(inode) : 0; + return ntfs_create_inode(idmap, dir, dentry, NULL, S_IFLNK | 0777, 0, + symname, size, NULL); } =20 /* @@ -217,12 +206,8 @@ static int ntfs_symlink(struct mnt_idmap *idmap, struc= t inode *dir, static int ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, struct dentry *dentry, umode_t mode) { - struct inode *inode; - - inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S_IFDIR | mode, 0, - NULL, 0, NULL); - - return IS_ERR(inode) ? PTR_ERR(inode) : 0; + return ntfs_create_inode(idmap, dir, dentry, NULL, S_IFDIR | mode, 0, + NULL, 0, NULL); } =20 /* diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 79356fd29a14..3db6a61f61dc 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -714,11 +714,10 @@ int ntfs_sync_inode(struct inode *inode); int ntfs_flush_inodes(struct super_block *sb, struct inode *i1, struct inode *i2); int inode_write_data(struct inode *inode, const void *data, size_t bytes); -struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, - struct dentry *dentry, - const struct cpu_str *uni, umode_t mode, - dev_t dev, const char *symname, u32 size, - struct ntfs_fnd *fnd); +int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, + struct dentry *dentry, const struct cpu_str *uni, + umode_t mode, dev_t dev, const char *symname, u32 size, + struct ntfs_fnd *fnd); int ntfs_link_inode(struct inode *inode, struct dentry *dentry); int ntfs_unlink_inode(struct inode *dir, const struct dentry *dentry); void ntfs_evict_inode(struct inode *inode); --=20 2.34.1 From nobody Mon Feb 9 03:47:55 2026 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.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 B0A0C535AA; Tue, 23 Apr 2024 06:45:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854731; cv=none; b=PgxI4S+0xfBzGHl2PF7jcDR1o3lciNZzPWzspJAfDqPAcuwt7o8WNqcTF3LkW5uOyTT0hakXQ0DEYXcrDP40ODD7lam/5fl+hC8zmgdbUpdMC+NO6m0Q14WP1DUhb9qxegrUp38ue3t28kCNw2sTjV5qI/xATtBq9itUON/jjD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854731; c=relaxed/simple; bh=5V5mlWjgKEt2xggGHOJT9zfphZm259eruYClAAMeW0I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GZVsmaJ98dm6XGj33b74/S5XpU203TlH0v+hbNAy0fQgR4IqW7HjVjufVcTvCvceh9ZkO8D6jVxj97rJTAuF4hWiB7004a5+PXPHUQAFQVJg3D37zb0ovx59aQI1G1JOLq4CczdGVs2IHpiD+KJtGqonX573aKlOThR2YLo58bY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=sJGveCFJ; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="sJGveCFJ" Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 26DFA2001; Tue, 23 Apr 2024 06:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854276; bh=iXPcB3W86y8aVaYAB3RHoq4FWQk45RoZD6nKh0gQY00=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=sJGveCFJeKRoNE8pxoKdykAhBTWKSs+Z7TjGH0023pmO+IROMcScOOpEj1jWEC0Bm rzLShtvadAmLVEMICBvSKEy6/hGVdpEPKzEcxDyJyVqK7m4U/4yN7pghIcaVI0flrU TM+c5VYkMHBiUYnVLZMPtYeSDHsswtmhYSiOHC4M= Received: from ntfs3vm.paragon-software.com (192.168.211.160) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Tue, 23 Apr 2024 09:45:27 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov Subject: [PATCH 8/9] fs/ntfs3: Always make file nonresident on fallocate call Date: Tue, 23 Apr 2024 09:44:27 +0300 Message-ID: <20240423064428.8289-9-almaz.alexandrovich@paragon-software.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> References: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Content-Type: text/plain; charset="utf-8" xfstest 438 is starting to pass with this change. Signed-off-by: Konstantin Komarov --- fs/ntfs3/attrib.c | 32 ++++++++++++++++++++++++++++++++ fs/ntfs3/file.c | 9 +++++++++ fs/ntfs3/ntfs_fs.h | 1 + 3 files changed, 42 insertions(+) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 7aadf5010999..8e6bcdf99770 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -2558,3 +2558,35 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo= , u64 bytes) =20 goto out; } + +/* + * attr_force_nonresident + * + * Convert default data attribute into non resident form. + */ +int attr_force_nonresident(struct ntfs_inode *ni) +{ + int err; + struct ATTRIB *attr; + struct ATTR_LIST_ENTRY *le =3D NULL; + struct mft_inode *mi; + + attr =3D ni_find_attr(ni, NULL, &le, ATTR_DATA, NULL, 0, NULL, &mi); + if (!attr) { + ntfs_bad_inode(&ni->vfs_inode, "no data attribute"); + return -ENOENT; + } + + if (attr->non_res) { + /* Already non resident. */ + return 0; + } + + down_write(&ni->file.run_lock); + err =3D attr_make_nonresident(ni, attr, le, mi, + le32_to_cpu(attr->res.data_size), + &ni->file.run, &attr, NULL); + up_write(&ni->file.run_lock); + + return err; +} diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 5418662c80d8..fce8ea098d60 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -578,6 +578,15 @@ static long ntfs_fallocate(struct file *file, int mode= , loff_t vbo, loff_t len) /* Check new size. */ u8 cluster_bits =3D sbi->cluster_bits; =20 + /* Be sure file is non resident. */ + if (is_resident(ni)) { + ni_lock(ni); + err =3D attr_force_nonresident(ni); + ni_unlock(ni); + if (err) + goto out; + } + /* generic/213: expected -ENOSPC instead of -EFBIG. */ if (!is_supported_holes) { loff_t to_alloc =3D new_size - inode_get_bytes(inode); diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 3db6a61f61dc..00dec0ec5648 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -452,6 +452,7 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST fra= me, size_t compr_size, int attr_collapse_range(struct ntfs_inode *ni, u64 vbo, u64 bytes); int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes); int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32 *frame_= size); +int attr_force_nonresident(struct ntfs_inode *ni); =20 /* Functions from attrlist.c */ void al_destroy(struct ntfs_inode *ni); --=20 2.34.1 From nobody Mon Feb 9 03:47:55 2026 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.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 02EA653E0C; Tue, 23 Apr 2024 06:45:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854733; cv=none; b=kBqgtziA0WuSIc6cbTufOZGQS2A9y7UKczFQ7tesx2FElx9XYTQcY1phH/dO4MBEg4H0LJfDyoz9BEjWE+9TJ6d0u7r1JuxdQl4ZCuOn5MrmPQZ9ity+IE85IUPAukJmsuw2Mmm5CepGZZJX6IuTDU78oOk/gWgp/IsUp5ufxdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713854733; c=relaxed/simple; bh=zIXsydJ0OFAdAw7O+5l7FhA6iuyUaBpAfrhoIuPnWjw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J2Hf+1pQxehuu1yw1hMy3Ur2+kytkODa+Fq4SaG6ocaLnHC6LVDnjFmifOkQatLWdj5wU+xV0qeMmcp36EJkbOpCygVMAavsXXJsBvOXqoG7TVo+dm26BaIZ5SXHXeYKDZ6M1/+UTNejl2e+d6QjQXvM40PQKlnQ+fZBVq3fmrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=UoGh5+pK; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=EEYmEV2b; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="UoGh5+pK"; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="EEYmEV2b" Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 7787E1E80; Tue, 23 Apr 2024 06:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854278; bh=cm+UXusAdhDpHBRIxdmZISx0r6b6stnWsNu0gUCqeh4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=UoGh5+pK2M2QxcyXDG2zma+Rk1cSwbCNF0fSMgJmFhuD00RTRwSKjHB1Ls7xTWh98 b7fL1JM8cT07wR/sl8EIDSq3ksa2P8O6APDtDErdf5KfcmG0faajw2A2MaWgaMWraP c0rHyPnG1cLcCCk+bfV+KkENM+p3FXiUfoJE8k8A= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 3B680214E; Tue, 23 Apr 2024 06:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713854730; bh=cm+UXusAdhDpHBRIxdmZISx0r6b6stnWsNu0gUCqeh4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=EEYmEV2bcD9JxCZNwpZ+s8YgmMC49a8qdoEotQ//Hkw07Qf3hXcHKjyn1ukplIVub I2sWPqFYSkWLDNlEbxFIvwcCohoCAM7DpLFRZz0whDyg98ZV5Rfemuer+WLI/G7CN3 1aUBFhiD+CKVOUSBzPFXnGcQh+YJO90by6gUkkCA= Received: from ntfs3vm.paragon-software.com (192.168.211.160) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Tue, 23 Apr 2024 09:45:29 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov Subject: [PATCH 9/9] fs/ntfs3: Mark volume as dirty if xattr is broken Date: Tue, 23 Apr 2024 09:44:28 +0300 Message-ID: <20240423064428.8289-10-almaz.alexandrovich@paragon-software.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> References: <20240423064428.8289-1-almaz.alexandrovich@paragon-software.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Content-Type: text/plain; charset="utf-8" Mark a volume as corrupted if the name length exceeds the space occupied by ea. Signed-off-by: Konstantin Komarov --- fs/ntfs3/xattr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 53e7d1fa036a..73785dece7a7 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -219,8 +219,11 @@ static ssize_t ntfs_list_ea(struct ntfs_inode *ni, cha= r *buffer, if (!ea->name_len) break; =20 - if (ea->name_len > ea_size) + if (ea->name_len > ea_size) { + ntfs_set_state(ni->mi.sbi, NTFS_DIRTY_ERROR); + err =3D -EINVAL; /* corrupted fs */ break; + } =20 if (buffer) { /* Check if we can use field ea->name */ --=20 2.34.1