From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796196292; b=EbCvHA0I1pqU9zQ9p9yS9BUKBScBF6+ILTg7Ti5GVqiOglkdKgGAOY6KtBzu+7PQQv7O lqPbmyTQ/YL2osuaJXESplI22jd50rGpi6bj8EfAsMlUtu5gr/GfHgsGZhlPBm8d0tlhk zzL7n4ZoROvgkXs1JxeCBP9CrrRdAnOeM8DcJilcpnp4vZz9vPwvsRjZk9hiAfCU6SqvQ wrFqVyoO3yRrmPgkgYJ1ofD8ztenqvv8SvnBDO8F+5nhuQLsSHPQb6NTKzvXiOCCAuK9J q65CvP//RmaK2DlGaAkFKfO/ap4LKkvV1RdMjpTyVmT8oEWHrQS2KKqCLUFMB+xgg+g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796196292; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=XlM3yYUEGkgzIdcvRCkjsu8EAe1ks6nIspB62+s7HL0=; b=3MC0XCMMwcxKtq+B0AXRvxZM8xu4v+78kDFpU8wiePAyk2p98xhWHulLfRHRcp7vQjr7 24tuzo495ydihkBSrj0iXb6GsFW+y7hItXXG8XN2op5HhwDZMOcr3lurajYf/Cm1LgrFl pNQw9tRpv6tE2y2AfNUmfKaFo3ePlQMrYdU5um05QbZcU7dnbH+qe8FxosZv9SznCY54r S6e+qbXHbraqwj/3awZDjWMZ1nDpkPzjO7q5WlApSxPSmQ011DIr24J6sdoicVdyyHpDH tZyngXpv8asutA0sm+m9HDmois6PTZ0IKiWNcOWv8kthd41U5e7BsH/3jma43ThW86Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=QZmwwtN5; arc=none smtp.remote-ip=209.85.210.173 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B85C9606A322 for ; Wed, 2 Dec 2026 07:24:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B85C9606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=QZmwwtN5 Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-8a052aff9e9so9099850b3a.0 for ; Tue, 01 Dec 2026 23:24:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796196291; x=1796801091; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=XlM3yYUEGkgzIdcvRCkjsu8EAe1ks6nIspB62+s7HL0=; b=QZmwwtN5oYMEb7gLjoY57UAyF0eL7jXuMvG2zUURhTgPWtdU6fprDrrZrj4pRv04EE Mm/OrKxNsNNWlpjIykqPshQ/mOHP0mXmndM6QQp6N5W1znw7deoX8gAkXnNZVNcVtKMQ ER0CtUmaIZA6A3iC7UYwZ3Eb010jUFHQ3vVA8c3L2D9bPdT7vCn1WQhXZpCMPdICtLs9 3VtvAoCQxcW4kTAe5hU6sGkhNN6b7EUFtGzyNWsNuhlNemWpi//YSMbtEkG6GvJIfxex JmuRDTh5c2eCWhppKChrWKcWcY5chUT9ewtRD4bAwH1NpIM+TM7ZuJnERki8cyo4K96m FqsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796196291; x=1796801091; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XlM3yYUEGkgzIdcvRCkjsu8EAe1ks6nIspB62+s7HL0=; b=x0XI9AWEdBKecT5PfMpISoS7VMOqP6fdTs379a9pzq0Lj/jCVKpYl1VFnqAqUaC2WX DNq7Z7kMOcLW4Y+SDFqcnVsoRDBXSfNxl5iuliOIXmlLTL52d1W4o6rliM7V+ddIAfJm 1VeJH0llsWNip4aibj2MMBNok/J7+7IXMLTBXSyGRdHU+OkmBNHqiNfRjqVJpROjjkbI zzo33QXtRlohWk0ijhkRxY6aT3FyLZofRMDkn4EPyk6Ncq3S/yChk8/9vXpnvvf3asFm tC09evCZ5eKmYjeTGGw/PXB2K+7nadoYgI1sgnxLf03VUB7GojDLufs1wmcAPpbBQ3Cb AsoQ== X-Forwarded-Encrypted: i=1; AL+hErGkyslTAAM7yoG9VQueLgswwr5zVeI+QwYd74VnarkQ8I99r0w4OeeysTvzNffbz6kHNN9wnahCls7BDO8=@vger.kernel.org X-Gm-Message-State: APuU4Z9EvI/V2j1sOTexPO010x+tcCripqmSMZ7cqX1IbBOfr4ExcYeN cJBRHxJrGEtxqS7Oc8eTih/HVxsCyImexdMTH9SFys2rvBzrlbfozfZe X-Gm-Gg: AZFdTZft1MhClavsn6KvCGln/19NDDYQZrrbyxDm6NE3P0vRWPRtZG7sq/vyWGfN1tQ S/nICM4/WrGHSK4gl7s0KJSXZDxeLHVY+oPmPvIocNwunVjaDHKtz9HhBnSRmDC/nOMfgh4Nbdc gT2ktrS9gvwMrXYrWnB5IO7HlPxSPS14hlF6w9XaSK/hgWhjLDCjtx5A4GSCHsq/w+ig8uG881D 6bu0UHYqO2dfE0xAqxPZJ2BS9/PBKRpjrpbLUxk5graEJy+AHWByXppDmWeMhggfo79LCR6/6Wy o4FYThHcUbz3DScf9MG1ch8XPwwl2An49CDYz+4uoJc1i7NLKkv8bA/1KmHgxVi18/9aSPsZXx5 G2dhoctcPriCwGd5QCOkAhscr5JY8vG9cW83LfTvsHjfJHyjurQKfhq5Fgbu0dq9cPnyxIuEZGp HmIXptOtZl/WHtLLjZ9qBYkQNoYEoVoG0tXxmVtt5JpJx/7F49r27gtQc/pugQM/A08OTFzq8sU oBlNmc9xrzPWMkSzMRUlaNYeaF1iTGMcMDSHjFIA7Lve0I/F3793e+lWF4er6JhRr2exi9PlwU7 8ePd193c8u9P1mFzWm1FBF1fVpTGNJ606gEE7wGi5o6qqUwVPuZnco+DFb0OdWK8Qvs= X-Received: by 2002:a05:6a00:a01:b0:886:ac28:3bd0 with SMTP id d2e1a72fcca58-8c87ce3298bmr38220244b3a.40.1796196290873; Tue, 01 Dec 2026 23:24:50 -0800 (PST) Received: from osman.mioffice.cn ([43.224.245.178]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c8707792e8sm21706602b3a.7.2026.12.01.23.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 23:24:50 -0800 (PST) From: Zhan Xusheng To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: liubaolin12138@163.com, ernest.borowski.git@proton.me, ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, zhanxusheng@xiaomi.com, syzbot@syzkaller.appspotmail.com, stable@vger.kernel.org Subject: [PATCH] ntfs: map a read past the end of the runlist as a hole Date: Wed, 2 Dec 2026 15:24:45 +0800 Message-ID: <20261202072445.1975205-1-zhanxusheng1024@gmail.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Zhan Xusheng ntfs_read_iomap_begin_non_resident() maps at most the rest of the run holding the offset. At or past the allocated size, ntfs_attr_vcn_to_rl() returns the end of the runlist, whose length is 0, so the rest of the run comes out negative and is returned as the length of the mapping: WARNING: fs/iomap/iter.c:39 at iomap_iter iomap_readahead ntfs_readahead read_pages page_cache_ra_unbounded do_page_cache_ra page_cache_ra_order filemap_fault Readahead gets there when the file shrinks after the readahead window was sized from i_size. "ntfs: trim the sizes after a short write" makes that easy to hit: a write that runs out of space is rolled back to what it wrote while a MAP_POPULATE mmap() of the file faults it in. Map the range past the end of the runlist as a hole. Fixes: b041ca562526 ("ntfs: update iomap and address space operations") Tested-by: syzbot@syzkaller.appspotmail.com Cc: stable@vger.kernel.org Signed-off-by: Zhan Xusheng --- Found by syzbot ci on "ntfs: trim the sizes after a short write": https://ci.syzbot.org/series/9c5fb049-3646-4d3b-8f57-43553c5c1bb0 Tested in a VM on ntfs-next 329758f9d73b with the reproducer's image, the reproducer's mmap() and write() in a loop of 30 runs: the WARNING fires within 12 runs without the patch, in 5 of 5 boots, and not in 4 boots of 30 runs with it. The read mapping of 19cc08c1a6a6, the base syzbot ci tested, has the same code. fsx (buffered and O_DIRECT), mmap, partial O_DIRECT, insert/collapse range and the short write cases give the same results with and without the patch. No lockdep or KASAN reports. fs/ntfs/iomap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/ntfs/iomap.c b/fs/ntfs/iomap.c index ce916707f69b..8124c5f62700 100644 --- a/fs/ntfs/iomap.c +++ b/fs/ntfs/iomap.c @@ -248,7 +248,12 @@ static int ntfs_read_iomap_begin_non_resident(struct inode *inode, loff_t offset return -EIO; } - if (rl_length && length > rl_length - vcn_ofs) + /* + * At or past the allocated size, ntfs_attr_vcn_to_rl() returns the + * end of the runlist and rl_length is not positive: map the rest as a + * hole. + */ + if (rl_length > 0 && length > rl_length - vcn_ofs) iomap->length = rl_length - vcn_ofs; else iomap->length = length; -- 2.43.0