From nobody Mon Sep 28 13:59:38 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) (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 A83D84052B9 for ; Fri, 21 Aug 2026 05:33:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.2 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290394; cv=none; b=cIoa40n39EfJ1CL2iMbSmrtwaT4kdwy9D4aVX/WJVzjoyAp24vyObCJnZSlHfmfEpajsaJAi+ICQ65p6o9l20n3NuvWPimL7f6c3rnrvli3O5hsHd7+D1dTsSZjeaS3JoDBDgQxSHK/EmvvWEWVlLi9yUO2bq2Vzm1J2RO1UmSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290394; c=relaxed/simple; bh=2mLYyqLFMIwzeXQBfFgm+G71LdtYzTnFxEfui/ZcBfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h0Wo1kqdS0hWH7YRAZhHBbqywZ6siKERtXkJ+4pUulK46V6pFH82o0SasUDUE4H2e/G1GNrQVKWZDEjfN4iQH8OMXeT0TBSw3T32Ak1fRxm1Ya/c7al3+lKVfx7lM3q8ybE6ztn3c+SDu4QuD2Lp+qbGEQbQejqEjiiRYgY++ZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=YmTR8D1z; arc=none smtp.client-ip=117.135.210.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="YmTR8D1z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=zr 1AaFjT/F5Yyyq/ldc7qcfTWLX1MLOt+Y6zjHnfMqg=; b=YmTR8D1zdBW0o8ri3G q7eMQ+E7mWa5EWxQvj23PkSIpXl1CuByR7g4r3cy1hWaCkcUOozEsVLWEHwmbc2L NDOVu1gjqgrdY6QZmIyejR0bOIxj3JCafffUVqus+A3eAS7WJgd565yX1jZZE90z gEflCxgeSg1DlUWKHPBF5xdcg= Received: from liubaolin-ThinkPad-E15-Gen-2 (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wDnzHn44odqtfQKPQ--.8742S3; Fri, 21 Aug 2026 13:32:44 +0800 (CST) From: Baolin Liu To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, liubaolin12138@163.com, liubaolin12138@gmail.com, Baolin Liu Subject: [PATCH v1 1/9] ntfs: return DT_UNKNOWN on inode lookup failure in readdir Date: Fri, 21 Aug 2026 13:32:30 +0800 Message-ID: <20260821053238.1281310-2-liubaolin12138@163.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260821053238.1281310-1-liubaolin12138@163.com> References: <20260821053238.1281310-1-liubaolin12138@163.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-CM-TRANSID: _____wDnzHn44odqtfQKPQ--.8742S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7GFyxtw1fGFWxXw43Wr15Jwb_yoWDtFc_W3 W3Aayv9FnxKFsFg3ZxGFW2vF9aqF40grs7urW3JFZIy398Ar1DGFsYyrs5XFWkurW5Jry5 X3yDWry7Cr1ayjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRgmiRJUUUUU== X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbC6hx0P2qH4vzWrwAA33 Content-Type: text/plain; charset="utf-8" From: Baolin Liu ntfs_reparse_tag_dt_types() returns PTR_ERR(vi) when ntfs_iget() fails, but its return type is unsigned int and the caller passes the value straight to dir_emit() as d_type. A stale or corrupt MFT reference in a directory index thus makes readdir report a garbage d_type value to userspace. Return DT_UNKNOWN on lookup failure instead. Fixes: fc053f05ca28 ("ntfs: add reparse and ea operations") Signed-off-by: Baolin Liu Reviewed-by: Hyunchul Lee --- fs/ntfs/reparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs/reparse.c b/fs/ntfs/reparse.c index 0d3988992119..a8e413c61353 100644 --- a/fs/ntfs/reparse.c +++ b/fs/ntfs/reparse.c @@ -331,7 +331,7 @@ unsigned int ntfs_reparse_tag_dt_types(struct ntfs_volu= me *vol, unsigned long mr =20 vi =3D ntfs_iget(vol->sb, mref); if (IS_ERR(vi)) - return PTR_ERR(vi); + return DT_UNKNOWN; =20 reparse_attr =3D (struct reparse_point *)ntfs_attr_readall(NTFS_I(vi), AT_REPARSE_POINT, NULL, 0, &attr_size); --=20 2.51.0 From nobody Mon Sep 28 13:59:38 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.4]) (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 DEA8C40682C for ; Fri, 21 Aug 2026 05:33:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290396; cv=none; b=ALv3+6iWpW7AR6cVToBwRI+IWYdQcbwRowGVqkEnXnphR3MF7ankfgghfKwmtGwbMS9Iri3lyU+QI4RSs+DQCWgxOdwaDdnq7o+cSHZBAwmW7KITJLd1hU/xmVwrx6cNLbCOaQ0IQKx/GYUcqxc0sH9WBhqc1zK7fr4JHdlAxaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290396; c=relaxed/simple; bh=PBpTp0PsaWchJZZ16pDrvCCQvsD9rrqXyUFIJajPSFs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fCCKtFHCL89LNPtvqQUM5d+dXu/r/745sVS28IYkwKNY3YQFPT0fMXmnVi6ULvARpHJco3toKdkb9o2/0G0UkEPOtQDGw4a4hKJwD+tNVVDdJApHQce96j81g9exrO1Oln5OcFSjbGjJngV7YM+6rbXwb0bdJoc9Bi5zioZi2lc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=BYC615oi; arc=none smtp.client-ip=220.197.31.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="BYC615oi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=jM UxUTOh7D6jKzuUn54ZoReOZbsAvOg31bl39zQnPd0=; b=BYC615oinchjKTUIVP FDc2tTUCsO6Zde5r5KDrV9135ME1bmb7FrTkVYK4IfqlVj/vHa7rScXPqsoQdOIK 9Jkx86t5HcHbHcnPkZw6/LkJ3l6c9fU0wskSUFaapiyYwrvJhUzS2eWIIDVA3t7b ejT+DVIPLLy3oIo6csXYYMMRg= Received: from liubaolin-ThinkPad-E15-Gen-2 (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wDnzHn44odqtfQKPQ--.8742S4; Fri, 21 Aug 2026 13:32:46 +0800 (CST) From: Baolin Liu To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, liubaolin12138@163.com, liubaolin12138@gmail.com, Baolin Liu Subject: [PATCH v1 2/9] ntfs: fail EA update when reading $EA_INFORMATION fails Date: Fri, 21 Aug 2026 13:32:31 +0800 Message-ID: <20260821053238.1281310-3-liubaolin12138@163.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260821053238.1281310-1-liubaolin12138@163.com> References: <20260821053238.1281310-1-liubaolin12138@163.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-CM-TRANSID: _____wDnzHn44odqtfQKPQ--.8742S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7CFyUuFWDtFW8Gw48tFy7Wrg_yoW8AFy5pr yfGa4UKw43Jr12kF97CFWvqay5ZrZ7GrWUtryxKw1S9wnYqr1Utw4jya4kuFWfKryrGw1F qFs0g39xZ3WjgaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pNiihbUUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbCwR50P2qH4v6VIgAA3S Content-Type: text/plain; charset="utf-8" From: Baolin Liu In ntfs_set_ea(), when the $EA_INFORMATION attribute exists but reading it fails or returns an unexpected size, the function jumps to the exit label with err still 0, so setxattr(2) reports success without writing anything. Worse, ea_info_qsize is still 0 at that point, so the exit path calls NInoClearHasEA() on an inode that does have EAs on disk, hiding all existing EAs until the inode is evicted. Return -EIO in this case and leave the HasEA flag untouched on failure. Fixes: fc053f05ca28 ("ntfs: add reparse and ea operations") Signed-off-by: Baolin Liu Reviewed-by: Hyunchul Lee --- fs/ntfs/ea.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c index 59e5e86e38e3..10d5b192f07e 100644 --- a/fs/ntfs/ea.c +++ b/fs/ntfs/ea.c @@ -208,8 +208,10 @@ static int ntfs_set_ea(struct inode *inode, const char= *name, size_t name_len, if (ntfs_attr_exist(ni, AT_EA_INFORMATION, AT_UNNAMED, 0)) { p_ea_info =3D ntfs_attr_readall(ni, AT_EA_INFORMATION, NULL, 0, &ea_info_size); - if (!p_ea_info || ea_info_size !=3D sizeof(struct ea_information)) + if (!p_ea_info || ea_info_size !=3D sizeof(struct ea_information)) { + err =3D -EIO; goto out; + } =20 ea_buf =3D ntfs_attr_readall(ni, AT_EA, NULL, 0, &all_ea_size); if (!ea_buf) { @@ -390,10 +392,12 @@ static int ntfs_set_ea(struct inode *inode, const cha= r *name, size_t name_len, *packed_ea_size =3D p_ea_info->ea_length; mark_mft_record_dirty(ni); out: - if (ea_info_qsize > 0) - NInoSetHasEA(ni); - else - NInoClearHasEA(ni); + if (!err) { + if (ea_info_qsize > 0) + NInoSetHasEA(ni); + else + NInoClearHasEA(ni); + } =20 kvfree(ea_buf); kvfree(old_ea_buf); --=20 2.51.0 From nobody Mon Sep 28 13:59:38 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) (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 A84754052DE for ; Fri, 21 Aug 2026 05:33:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.2 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290395; cv=none; b=kOzPb1ICZCjSKA5NSUDhV6ljW4jHer0PzZHlKN5T5KRmRDkm2tFQT04zzYo9n0iYSukRXhrPnG1EkNzYW7WJjG3ng54F/iad7evyObLQXYQnE5zvA/ZFwyqzWHIx9+6uaUQTb6jrp5p+Y7rUaJESmA1WQ0Mm+xqqimN4sr8tlMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290395; c=relaxed/simple; bh=rG9/5whMLFzxlYA0WBDa8QbuRpAiX1b6RqvS6zZKCq0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tBmvY+7H2AvvYzY6QIeKR/69rOHkX1/hM7HqTLx9eIC6YuZ16qh66m1ZO3zz1FKcGr0bb/p08rPD8hW07FrBwjxJOec6zqYN/qOjfVnhzYwl3KqehvlnGcHqcEd8jOuvUpeFw/4NTaNZ6y+XBqymZ3QV7ZtpevOu9JvfQ/gLGhg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=qK98Bvq/; arc=none smtp.client-ip=117.135.210.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="qK98Bvq/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=4j UovKIvcXbStcAehtc2/3r4Y3/x+PfHFNP/t6niMHo=; b=qK98Bvq/zx3Sldt96s rR0Scl0/NHmh7u7JDdtSf1usAlu9mFeZpKRuWUbSd4M207vZRTCiVIYHj31hbxCI 1LrVbTcSuP8p1t8LY1ELhubMn2Cp0Ts/XeMT6BV8cq72XHHZaT+YpYWwWx0Y13SM KSg6jBVRPjWq+b/t3MC3azrmA= Received: from liubaolin-ThinkPad-E15-Gen-2 (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wDnzHn44odqtfQKPQ--.8742S5; Fri, 21 Aug 2026 13:32:48 +0800 (CST) From: Baolin Liu To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, liubaolin12138@163.com, liubaolin12138@gmail.com, Baolin Liu Subject: [PATCH v1 3/9] ntfs: propagate reparse index insertion failure Date: Fri, 21 Aug 2026 13:32:32 +0800 Message-ID: <20260821053238.1281310-4-liubaolin12138@163.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260821053238.1281310-1-liubaolin12138@163.com> References: <20260821053238.1281310-1-liubaolin12138@163.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-CM-TRANSID: _____wDnzHn44odqtfQKPQ--.8742S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7ZrW7KryxJr1UJr1UCw13XFb_yoW8JF47pr Zxua1rKayxJr10ka1vyF4DZr10kw17G3yUta4rZ3WfK3WFqr1kt3yrKFsYgryrCa48JFWU Xr1rKr43ZF4DA3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRG9aPUUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbCwgB1QGqH4wCi9QAA3u Content-Type: text/plain; charset="utf-8" From: Baolin Liu update_reparse_data() ignores the return value of set_reparse_index(). When index insertion fails, the code removes the just-written reparse data as cleanup but still returns 0, so symlink(2) (and WSL special file creation) reports success while no reparse data exists on disk. When there was no previous reparse data (oldsize =3D=3D 0), the failure was likewise silently ignored. Propagate the error to the caller. Fixes: fc053f05ca28 ("ntfs: add reparse and ea operations") Signed-off-by: Baolin Liu Reviewed-by: Hyunchul Lee --- fs/ntfs/reparse.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ntfs/reparse.c b/fs/ntfs/reparse.c index a8e413c61353..905ee08422d4 100644 --- a/fs/ntfs/reparse.c +++ b/fs/ntfs/reparse.c @@ -618,8 +618,9 @@ static int update_reparse_data(struct ntfs_inode *ni, s= truct ntfs_index_context goto put_rp_inode; } =20 - if (set_reparse_index(ni, xr, ((const struct reparse_point *)value)->repa= rse_tag) && - oldsize > 0) { + err =3D set_reparse_index(ni, xr, + ((const struct reparse_point *)value)->reparse_tag); + if (err && oldsize > 0) { /* * If cannot index, try to remove the reparse * data and log the error. There will be an --=20 2.51.0 From nobody Mon Sep 28 13:59:38 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) (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 E81FA4052A2 for ; Fri, 21 Aug 2026 05:33:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290394; cv=none; b=j5R/P1Sd0xdWC82aBxxwF6xrcctzBOYAefrw6L/RJaBv3D+sPnaithaE2L/87yljtbwm0liD6l5rhJ0qVDZNPW4sl1ihFtzbi+/bPqq6NP29vVzeWHCaIZ/6gSX+w9IyIptsy1+gerbUdzUUlblzN8TrV7SfW6dH09HQOwVH4wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290394; c=relaxed/simple; bh=WOMgitPXnTyuSOQbnhbBYEnkEo2IesBN+n9T9cGpq6E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WgktAtWwKgNcyoW/2BKMiXSXfoTUghQ5YBRToBvSsfRuTkCCrX+ip9gcQQKswR7L3TyLTUg5FPDCNOPvXUFzExxfX8iOA/eM/2LcYjiUzNv382/pA6h24e9eMSg0WTjc1ByZLcjGvNVOUh6RGU/qodXthigYN6rafUvnQMfaC1g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=b4slQSlj; arc=none smtp.client-ip=117.135.210.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="b4slQSlj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Fg nC+JQL1LSAx/hPAuK2YYZ3/dkpmLcQq9L3IACv9Ts=; b=b4slQSlj6AZ283rr/f kSRkmIF92H5ZFBM3wMyj++/5945HIus5SYoV7N25Zbr3CEIMvveptB7lQfobU2Ba VPXOF3i96SOwhnx72vIpvrOTrdJaTzgZdMOdG34DAPcCna08R/u4nxWfIVTSlFsD eC0DuG/9XIBdqTJR/I3Koxwtc= Received: from liubaolin-ThinkPad-E15-Gen-2 (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wDnzHn44odqtfQKPQ--.8742S6; Fri, 21 Aug 2026 13:32:49 +0800 (CST) From: Baolin Liu To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, liubaolin12138@163.com, liubaolin12138@gmail.com, Baolin Liu Subject: [PATCH v1 4/9] ntfs: return -ERANGE for undersized xattr buffer Date: Fri, 21 Aug 2026 13:32:33 +0800 Message-ID: <20260821053238.1281310-5-liubaolin12138@163.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260821053238.1281310-1-liubaolin12138@163.com> References: <20260821053238.1281310-1-liubaolin12138@163.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-CM-TRANSID: _____wDnzHn44odqtfQKPQ--.8742S6 X-Coremail-Antispam: 1Uf129KBjvJXoW7Gr1rCr1DKw1rCr4fAw4Dtwb_yoW8JF1fpF ZakFy8Kan7tFyjyF4qkr4qvw4xur9rGFyjkr9xKwnay3Z8tw1I9as5K34Ikr1IqFyxAr1k Gr1DurW7X3s8Z3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0z_18BUUUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbCwgF1QGqH4wGjHAAA3G Content-Type: text/plain; charset="utf-8" From: Baolin Liu When the value buffer passed to getxattr(2) for system.dos_attrib, system.ntfs_attrib or system.ntfs_attrib_be is smaller than the attribute value, ntfs_getxattr() returns -ENODATA, which tells userspace the attribute does not exist. The xattr API expects -ERANGE in this case, and ntfs_get_ea() in the same file already returns -ERANGE for regular EAs. Fixes: fc053f05ca28 ("ntfs: add reparse and ea operations") Signed-off-by: Baolin Liu Reviewed-by: Hyunchul Lee --- fs/ntfs/ea.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c index 10d5b192f07e..616eb0d65ee3 100644 --- a/fs/ntfs/ea.c +++ b/fs/ntfs/ea.c @@ -595,7 +595,7 @@ static int ntfs_getxattr(const struct xattr_handler *ha= ndler, if (!buffer) { err =3D sizeof(u8); } else if (size < sizeof(u8)) { - err =3D -ENODATA; + err =3D -ERANGE; } else { err =3D sizeof(u8); *(u8 *)buffer =3D (u8)(le32_to_cpu(ni->flags) & 0x3F); @@ -608,7 +608,7 @@ static int ntfs_getxattr(const struct xattr_handler *ha= ndler, if (!buffer) { err =3D sizeof(u32); } else if (size < sizeof(u32)) { - err =3D -ENODATA; + err =3D -ERANGE; } else { err =3D sizeof(u32); *(u32 *)buffer =3D le32_to_cpu(ni->flags); --=20 2.51.0 From nobody Mon Sep 28 13:59:38 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.2]) (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 309E7403B10 for ; Fri, 21 Aug 2026 05:33:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.2 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290394; cv=none; b=aAxW6HwgVGbZ8YzxuxyO/R+9+IQQEZiJaXJ2bQFWLpmFBDBa5PWB2e1EeDJMAhNPcEVw9D+j50Zds4ouxhd6G1NcWK95DeM1cfbe4+qYCh3zNqiEgCrqPWm80l+JOjoZh9sKEOavbV5rR99romSgvMywsxnewKqBSz2CU5OCTYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290394; c=relaxed/simple; bh=TNJfgiaZ17tAwJ8i6L6P/6Wxfrx3nOdhnuOnH+u/BpI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NC+sCxwBlzzT0FjRSTLUolysv+pRmZraaJC8o364x0267qxx3Qr5qfsvjmiTFr6QjVDUZSCIO+96J3gkHR0RVczu5CspI91fz/wzuahlMEK9xm6E7gAwtVNBlDrrBpjum9j9hGQxFNo2BlczQJos4PlcC8QO4tlzNysCx8VUpuY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=cvFJAntp; arc=none smtp.client-ip=220.197.31.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="cvFJAntp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=gp V1L9g1DfafpIAWW3muAXKg2f0TnoM38dxC0AXtMUI=; b=cvFJAntpE4uSFElgbm QB6Q9MC+o2XeOv6Gktz44o+cvz4O5SDbMzIzGTBjFW+TKW/52vDHHsJQB9eIEGdo La81QyQzAq60GZXkhLUEN/jxK16bQE+5sMGBoNTOXMkAoGB65gIBGkStksp7L8rU U99WCbcBVcJ4WgaXuq4BaezV0= Received: from liubaolin-ThinkPad-E15-Gen-2 (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wDnzHn44odqtfQKPQ--.8742S7; Fri, 21 Aug 2026 13:32:51 +0800 (CST) From: Baolin Liu To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, liubaolin12138@163.com, liubaolin12138@gmail.com, Baolin Liu Subject: [PATCH v1 5/9] ntfs: preserve error code in ntfs_resident_attr_record_add() Date: Fri, 21 Aug 2026 13:32:34 +0800 Message-ID: <20260821053238.1281310-6-liubaolin12138@163.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260821053238.1281310-1-liubaolin12138@163.com> References: <20260821053238.1281310-1-liubaolin12138@163.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-CM-TRANSID: _____wDnzHn44odqtfQKPQ--.8742S7 X-Coremail-Antispam: 1Uf129KBjvdXoW7GFy3Ww43try7KFy7uryrXrb_yoWDXrc_ua 1xZF1kCF1jqFs3C3Z29w1a9a1aqayIgrn8WryrGFsrW34qyFn8XFWDArs0yFWDXr17K345 Wr1FgFy5uF1SyjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRJwIqPUUUUU== X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbCwgN1QGqH4wOjPAAA3m Content-Type: text/plain; charset="utf-8" From: Baolin Liu ntfs_resident_attr_record_add() collapses every failure to -EIO at its put_err_out label. This defeats the resident-to-non-resident fallback in ntfs_attr_add(), which relies on seeing -ENOSPC to convert the attribute when the MFT record has no room, and also hides -EEXIST and -ENOMEM from callers. Return the actual error code. Every path reaching the label has err set to a negative errno. Fixes: 495e90fa3348 ("ntfs: update attrib operations") Signed-off-by: Baolin Liu Reviewed-by: Hyunchul Lee --- fs/ntfs/attrib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index 990c3937a551..3d0b305703d3 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c @@ -2500,7 +2500,7 @@ int ntfs_resident_attr_record_add(struct ntfs_inode *= ni, __le32 type, return offset; put_err_out: ntfs_attr_put_search_ctx(ctx); - return -EIO; + return err; } =20 /* --=20 2.51.0 From nobody Mon Sep 28 13:59:38 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (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 B003E4078C0 for ; Fri, 21 Aug 2026 05:33:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290396; cv=none; b=L4S+HG/oQaQhAwY7moA1CFT484uE5hceYuu1Qm/LTduNFaTOUCJjdEnLIMYj+2zVAAenfFjuJFrHu5CX1VhdwC6aaEHm98kSIueruvyJB9TznDYs6MvZkelvMkBS/eauTX9tFdQci71SjZF2UVTCQIpv+FqVOK7NYxMdI75+AKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290396; c=relaxed/simple; bh=HBBuvzT4wS9YFsivgZ2CKY9EfvTvgWdjA/n4NsLezYA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BtmJanmN/JKYnhuGv791jlG7ekI88iy5quQB1esKnvuR8elXPu5Bw5U+MjyVV+LnE+1Azz/mB5cgbG0sWK2AsaidzhuKO6H48v95zikrXaEnQ0s1cj+nbSwcsPb9TTKzWyIEcUaui05F/1h91yrlMY+14DtqBqD1QNJfL+40Guw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=RlIxZE4D; arc=none smtp.client-ip=117.135.210.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="RlIxZE4D" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=yy ewxQpzTX4jMIjjHf6ILa7KbCm0j8w8sc+Bg4zybjY=; b=RlIxZE4DDq/QbWE264 9HRko/AuorbH0+bdH1YAbABzlId67xJ+ZMLK7RstDFM0Ix2RYtGqY9govNQpxwi2 hkvT9a8Ve+mfS/Ea135iUAjGC/KcQX0wUjgwOEj3/ghN9So0c+ZakzyuQLQ+dg1r PdVzBwq+k6CtX3PS5Zq9rOmtY= Received: from liubaolin-ThinkPad-E15-Gen-2 (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wDnzHn44odqtfQKPQ--.8742S8; Fri, 21 Aug 2026 13:32:53 +0800 (CST) From: Baolin Liu To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, liubaolin12138@163.com, liubaolin12138@gmail.com, Baolin Liu Subject: [PATCH v1 6/9] ntfs: return real error from ntfs_non_resident_attr_record_add() Date: Fri, 21 Aug 2026 13:32:35 +0800 Message-ID: <20260821053238.1281310-7-liubaolin12138@163.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260821053238.1281310-1-liubaolin12138@163.com> References: <20260821053238.1281310-1-liubaolin12138@163.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-CM-TRANSID: _____wDnzHn44odqtfQKPQ--.8742S8 X-Coremail-Antispam: 1Uf129KBjvdXoW7GFyfZw4fCw15tw4kJFWkZwb_yoW3uwb_Ca 1xX3WkCrn8JF95Ca1kC34aka13ta4rurs8K34rGFnrG34jyF15ZrWDArs8tFWDXr17K345 Gr1FgFyY9F1SyjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRJ8nYPUUUUU== X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbC6gV2QWqH4wXXcQAA31 Content-Type: text/plain; charset="utf-8" From: Baolin Liu ntfs_non_resident_attr_record_add() returns -1 at its put_err_out label, which callers propagate as -EPERM to userspace. Return the actual error code. Every path reaching the label has err set to a negative errno. Fixes: 495e90fa3348 ("ntfs: update attrib operations") Signed-off-by: Baolin Liu Reviewed-by: Hyunchul Lee --- fs/ntfs/attrib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index 3d0b305703d3..a2502eee717e 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c @@ -2639,7 +2639,7 @@ static int ntfs_non_resident_attr_record_add(struct n= tfs_inode *ni, __le32 type, return offset; put_err_out: ntfs_attr_put_search_ctx(ctx); - return -1; + return err; } =20 /* --=20 2.51.0 From nobody Mon Sep 28 13:59:38 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (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 D5EC34052DF for ; Fri, 21 Aug 2026 05:33:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290394; cv=none; b=WdNCOx2Xgn87AWMgulzWT3SW1ifPL5kBpMMGKq9aeIYgsIngS13qyhpPJdsZOJAQaPjHw0aP5RT3MbldYQKStFkG9jDVEktR/qviL29CJOiF3hBNF6G1YSoYimLW6DlDOcjDgXMVVn4q8WYiL8gG82tByvuLF/KyJpx2aHJOG2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290394; c=relaxed/simple; bh=vXZ82cIJl30J/lUUuNAiztPZPzHrSOIFtnVNeXs7Fic=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VFolgeDeBH9EV6dzjGbwv4v4k91IfeXH4qxRbavB4Ln/k5J2/Emfa0emQuddOrKwHLOEN09qyjuKzc1EpNekgLCvFwrm1CrRwxh/0wVQTEHtoqgShrO3FKUqevhRzmo45JdIo9lJIzfndXs1Y7/oIPTj4hibvigFCc9fCMnv1SE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=VcR1qGOB; arc=none smtp.client-ip=117.135.210.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="VcR1qGOB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=t9 QYEKYGLGk6E0NVSSKqtALxrXdnw0JG/Gs8KcVSN7M=; b=VcR1qGOBgHkpiYsEpH 7xe4QgJKMlmSCQNHW+L3nTdgowOIln4MnYTp49rBkSHUT3yoBvj1HRK3ksZBqXAo T5OvCkxZ0ydH9qyG0RAC/z42CZHua0JubiAfDX2Jd/9jRBkpensyR2FL4VvA7q6x Ne9IGt+F3Iwx9xisftD6fRgLU= Received: from liubaolin-ThinkPad-E15-Gen-2 (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wDnzHn44odqtfQKPQ--.8742S9; Fri, 21 Aug 2026 13:32:54 +0800 (CST) From: Baolin Liu To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, liubaolin12138@163.com, liubaolin12138@gmail.com, Baolin Liu Subject: [PATCH v1 7/9] ntfs: fix kmap_local leak in write_mft_record_nolock() error paths Date: Fri, 21 Aug 2026 13:32:36 +0800 Message-ID: <20260821053238.1281310-8-liubaolin12138@163.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260821053238.1281310-1-liubaolin12138@163.com> References: <20260821053238.1281310-1-liubaolin12138@163.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-CM-TRANSID: _____wDnzHn44odqtfQKPQ--.8742S9 X-Coremail-Antispam: 1Uf129KBjvJXoW7tw4xXFWxKrWxGr43Cw4UJwb_yoW8Gr45pF ZIkwn7Kw4ktr17KwsrKF4Yyay2k3s3GayUWw4kWw12krs5tw1qvanxta4kXryfKFW5Kw48 trZ293y3XFyUZw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0z_UUUnUUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbCwgZ2QWqH4wajjAAA3U Content-Type: text/plain; charset="utf-8" From: Baolin Liu write_mft_record_nolock() maps the MFT record folio with kmap_local_folio(), but the pre_write_mst_fixup() and bio_add_folio() failure paths jump to the error label without unmapping it. kmap_local mappings are stack-ordered per task, so leaking one corrupts the nesting for any outer mapping. Unmap the folio on those error paths too. Fixes: 115380f9a2f9 ("ntfs: update mft operations") Signed-off-by: Baolin Liu Reviewed-by: Hyunchul Lee --- fs/ntfs/mft.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index 984a0827f9ac..69b007e574fc 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c @@ -580,7 +580,7 @@ int write_mft_record_nolock(struct ntfs_inode *ni, stru= ct mft_record *m, int syn err =3D pre_write_mst_fixup((struct ntfs_record *)fixup_m, vol->mft_recor= d_size); if (err) { ntfs_error(vol->sb, "Failed to apply mst fixups!"); - goto err_out; + goto unmap_err_out; } =20 folio_size =3D vol->mft_record_size / ni->mft_lcn_count; @@ -645,6 +645,8 @@ int write_mft_record_nolock(struct ntfs_inode *ni, stru= ct mft_record *m, int syn return 0; put_bio_out: bio_put(bio); +unmap_err_out: + kunmap_local(kaddr); err_out: /* * The caller should mark the base inode as bad so no more I/O --=20 2.51.0 From nobody Mon Sep 28 13:59:38 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) (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 8A0A6369D6E for ; Fri, 21 Aug 2026 05:33:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.2 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290395; cv=none; b=VXOqWN/Wo0X5wUfsolhOhkMA65IZznPHkp55m0gn8z5BSHfL6bQHipmgLOuQg85HNU8Bngkbm7zQouxDDemo4Aus4v65xgCl75K+QGVn+rV8+79igBsUQo+/Xxk87ttwm9w3qxjdfXpGQ9NN3BJj2e/beHeCOwFaYgf2ITb/YgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290395; c=relaxed/simple; bh=wI53v+3p26wqeenQxGl71xtWzrKwa3cfsO+AWGv2JNs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IIyxblOxa7JhKutQmCCoBnQrrG5SLSB5Nf9lGQUvtkTqDMcelWA+MJsmm1d5TWJPbUuTP85tZJhpqWdwMHD5cGfknbKp7r6RgrFyqBQXEMazZ9bV6NJpc/k+nXkvm/H7MPujFNNj1t/UgMnzvylvC+muNSCx99xXkNJk8vAZakw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=GvgN/JPu; arc=none smtp.client-ip=117.135.210.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="GvgN/JPu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=UR EznlCsnI2DQmSzouDGoibN2V21UlSs73INLAV9RsI=; b=GvgN/JPuA8Vwy8hkOx 0nWWyCP1WfEy9p9pwyAMBrZ913yAfhW82cz1eTWNPCQWvnc7wlSxEHMrdaPJBk3s dnStoS1dmVxpkuTg7D6mG4CJk69ncfOjB7nsXM6A0x3tb7eFGwHvsFkP0KW2Ijvs /YDaG+uqelWgkqKS5XH4Ltt2o= Received: from liubaolin-ThinkPad-E15-Gen-2 (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wDnzHn44odqtfQKPQ--.8742S10; Fri, 21 Aug 2026 13:32:56 +0800 (CST) From: Baolin Liu To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, liubaolin12138@163.com, liubaolin12138@gmail.com, Baolin Liu Subject: [PATCH v1 8/9] ntfs: only count successfully cleared runs when freeing clusters Date: Fri, 21 Aug 2026 13:32:37 +0800 Message-ID: <20260821053238.1281310-9-liubaolin12138@163.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260821053238.1281310-1-liubaolin12138@163.com> References: <20260821053238.1281310-1-liubaolin12138@163.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-CM-TRANSID: _____wDnzHn44odqtfQKPQ--.8742S10 X-Coremail-Antispam: 1Uf129KBjvJXoW7KFyfKFWrAr15XFyDCFWfXwb_yoW8Xr1fpw sakw1fGr4rGa409r4DK3y0v3yrX397GaykJrykWw1Sgwnav3ZrtF4rKa1Fq3Wvk39xJ3Z5 XryUW3y3uF1jvaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0z_UUUnUUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbC6Qh3QmqH4wgHowAA32 Content-Type: text/plain; charset="utf-8" From: Baolin Liu ntfs_cluster_free_from_rl_nolock() adds a run's length to nr_freed whenever the error bookkeeping condition is false, which includes cases where ntfs_bitmap_clear_run() actually failed - e.g. a second run failing with the same errno as an earlier one, or any failure after a non-ENOMEM error was already recorded. Since a failed ntfs_bitmap_clear_run() rolls back its partial modifications, no bits were cleared for that run, yet its length still inflates vol->free_clusters, corrupting statfs output and the allocator's free space gate. Only count runs whose bitmap clear succeeded. Fixes: 11ccc9107dc4 ("ntfs: update runlist handling and cluster allocator") Signed-off-by: Baolin Liu Reviewed-by: Hyunchul Lee --- fs/ntfs/lcnalloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ntfs/lcnalloc.c b/fs/ntfs/lcnalloc.c index aa2e017a4384..795f71d26895 100644 --- a/fs/ntfs/lcnalloc.c +++ b/fs/ntfs/lcnalloc.c @@ -53,10 +53,10 @@ int ntfs_cluster_free_from_rl_nolock(struct ntfs_volume= *vol, if (rl->lcn < 0) continue; err =3D ntfs_bitmap_clear_run(lcnbmp_vi, rl->lcn, rl->length); - if (unlikely(err && (!ret || ret =3D=3D -ENOMEM) && ret !=3D err)) - ret =3D err; - else + if (likely(!err)) nr_freed +=3D rl->length; + else if (!ret || ret =3D=3D -ENOMEM) + ret =3D err; } ntfs_inc_free_clusters(vol, nr_freed); ntfs_debug("Done."); --=20 2.51.0 From nobody Mon Sep 28 13:59:38 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) (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 D6559409295 for ; Fri, 21 Aug 2026 05:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290417; cv=none; b=H2W7dhiiG+2RiuaPsxQMulp2fKMyqDle4GC1ZrtfwKGvL36cQeFfhA0wsO9SxJupH9tY4qCukmmIP/pmpJRdHPhAGZJgg62//IkaVKSwjfpDT7oQJ9UGm4xKKYe59u1NhSBOyWAjhUSUlL8Cl0uhSzpakWzBAZxDctaybUqFYy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787290417; c=relaxed/simple; bh=Jg1anYCcLfSpOVEs8Qq4zxReVpkLqMbbUzyxB/Zl8/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K+roAHqmjY1SaFFXDv9dTTDytW6AGXB6E+kxcLsAx9NJIBMA5C97Nb0xKe3G/3jfkF6E5oT1PFu0wC0wqsVy1goEc43T4xnAaqEL4np2WqNDrL9Xnw66gmUIUo4UhebGncE8h6YLyLEH9P+k0/QfLE4x8BPxNcIRfBbniL3T1Ao= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=Le1GA0Li; arc=none smtp.client-ip=220.197.31.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="Le1GA0Li" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=L3 r+pw+SkSw77dGpHhU+FrNHZM9TPC0TXs+iZt1rokY=; b=Le1GA0LigKtvEYoc96 wAhtyNQ+C4WECkNXzWquYtYLpqZHDGPJWeQ9XTeqt/otXRPGPhphDHv7M0s/4svN cPvqHpQP+M2OtMLUexsh816D8DpH3BfAYDKm/NUrn1LV4LLfIe3if+1jimQBPQiI BtFH6BKYz83eGsTJYRMnPGXiM= Received: from liubaolin-ThinkPad-E15-Gen-2 (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wDnzHn44odqtfQKPQ--.8742S11; Fri, 21 Aug 2026 13:32:58 +0800 (CST) From: Baolin Liu To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, liubaolin12138@163.com, liubaolin12138@gmail.com, Baolin Liu Subject: [PATCH v1 9/9] ntfs: skip free cluster decrement when rollback fails Date: Fri, 21 Aug 2026 13:32:38 +0800 Message-ID: <20260821053238.1281310-10-liubaolin12138@163.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260821053238.1281310-1-liubaolin12138@163.com> References: <20260821053238.1281310-1-liubaolin12138@163.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-CM-TRANSID: _____wDnzHn44odqtfQKPQ--.8742S11 X-Coremail-Antispam: 1Uf129KBjvdXoWrKF15AF4fCr47WF15KrW5Awb_yoWkKrcEga yUJFZrG34UtF1rGa4vg39FgrWIv3WkK3s2g3y5tFZ8A3yfCa1rZa4DArZ5Aw4Igr4jkw45 JwnY9FyrAF1SqjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRJUUU3UUUUU== X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbC6Qp3QmqH4woHyQAA3c Content-Type: text/plain; charset="utf-8" From: Baolin Liu When the rollback in __ntfs_cluster_free() fails, the recursive call returns a negative errno and the subsequent ntfs_dec_free_clusters(vol, delta) subtracts that negative value, adding bogus clusters to the counter on an already-failing volume. Skip the decrement when the rollback failed. Fixes: 11ccc9107dc4 ("ntfs: update runlist handling and cluster allocator") Signed-off-by: Baolin Liu Reviewed-by: Hyunchul Lee --- fs/ntfs/lcnalloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ntfs/lcnalloc.c b/fs/ntfs/lcnalloc.c index 795f71d26895..0d6cd08ee2e7 100644 --- a/fs/ntfs/lcnalloc.c +++ b/fs/ntfs/lcnalloc.c @@ -1045,8 +1045,9 @@ s64 __ntfs_cluster_free(struct ntfs_inode *ni, const = s64 start_vcn, s64 count, "Failed to rollback (error %i). Leaving inconsistent metadata! Unmoun= t and run chkdsk.", (int)delta); NVolSetErrors(vol); + } else { + ntfs_dec_free_clusters(vol, delta); } - ntfs_dec_free_clusters(vol, delta); up_write(&vol->lcnbmp_lock); memalloc_nofs_restore(memalloc_flags); ntfs_error(vol->sb, "Aborting (error %i).", err); --=20 2.51.0