From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Lizhi Xu <lizhi.xu@windriver.com>,
syzbot+5d0bdc98770e6c55a0fd@syzkaller.appspotmail.com,
Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
Sasha Levin <sashal@kernel.org>,
ntfs3@lists.linux.dev
Subject: [PATCH AUTOSEL 6.13 04/28] fs/ntfs3: Keep write operations atomic
Date: Mon, 7 Apr 2025 14:11:54 -0400 [thread overview]
Message-ID: <20250407181224.3180941-4-sashal@kernel.org> (raw)
In-Reply-To: <20250407181224.3180941-1-sashal@kernel.org>
From: Lizhi Xu <lizhi.xu@windriver.com>
[ Upstream commit 285cec318bf5a7a6c8ba999b2b6ec96f9a20590f ]
syzbot reported a NULL pointer dereference in __generic_file_write_iter. [1]
Before the write operation is completed, the user executes ioctl[2] to clear
the compress flag of the file, which causes the is_compressed() judgment to
return 0, further causing the program to enter the wrong process and call the
wrong ops ntfs_aops_cmpr, which triggers the null pointer dereference of
write_begin.
Use inode lock to synchronize ioctl and write to avoid this case.
[1]
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
Mem abort info:
ESR = 0x0000000086000006
EC = 0x21: IABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x06: level 2 translation fault
user pgtable: 4k pages, 48-bit VAs, pgdp=000000011896d000
[0000000000000000] pgd=0800000118b44403, p4d=0800000118b44403, pud=0800000117517403, pmd=0000000000000000
Internal error: Oops: 0000000086000006 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 UID: 0 PID: 6427 Comm: syz-executor347 Not tainted 6.13.0-rc3-syzkaller-g573067a5a685 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : 0x0
lr : generic_perform_write+0x29c/0x868 mm/filemap.c:4055
sp : ffff80009d4978a0
x29: ffff80009d4979c0 x28: dfff800000000000 x27: ffff80009d497bc8
x26: 0000000000000000 x25: ffff80009d497960 x24: ffff80008ba71c68
x23: 0000000000000000 x22: ffff0000c655dac0 x21: 0000000000001000
x20: 000000000000000c x19: 1ffff00013a92f2c x18: ffff0000e183aa1c
x17: 0004060000000014 x16: ffff800083275834 x15: 0000000000000001
x14: 0000000000000000 x13: 0000000000000001 x12: ffff0000c655dac0
x11: 0000000000ff0100 x10: 0000000000ff0100 x9 : 0000000000000000
x8 : 0000000000000000 x7 : 0000000000000000 x6 : 0000000000000000
x5 : ffff80009d497980 x4 : ffff80009d497960 x3 : 0000000000001000
x2 : 0000000000000000 x1 : ffff0000e183a928 x0 : ffff0000d60b0fc0
Call trace:
0x0 (P)
__generic_file_write_iter+0xfc/0x204 mm/filemap.c:4156
ntfs_file_write_iter+0x54c/0x630 fs/ntfs3/file.c:1267
new_sync_write fs/read_write.c:586 [inline]
vfs_write+0x920/0xcf4 fs/read_write.c:679
ksys_write+0x15c/0x26c fs/read_write.c:731
__do_sys_write fs/read_write.c:742 [inline]
__se_sys_write fs/read_write.c:739 [inline]
__arm64_sys_write+0x7c/0x90 fs/read_write.c:739
__invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:49
el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132
do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151
el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:744
el0t_64_sync_handler+0x84/0x108 arch/arm64/kernel/entry-common.c:762
[2]
ioctl$FS_IOC_SETFLAGS(r0, 0x40086602, &(0x7f00000000c0)=0x20)
Reported-by: syzbot+5d0bdc98770e6c55a0fd@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=5d0bdc98770e6c55a0fd
Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/ntfs3/file.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index 3f96a11804c90..d3a31bad21f9d 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -1228,21 +1228,22 @@ static ssize_t ntfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
ssize_t ret;
int err;
- err = check_write_restriction(inode);
- if (err)
- return err;
-
- if (is_compressed(ni) && (iocb->ki_flags & IOCB_DIRECT)) {
- ntfs_inode_warn(inode, "direct i/o + compressed not supported");
- return -EOPNOTSUPP;
- }
-
if (!inode_trylock(inode)) {
if (iocb->ki_flags & IOCB_NOWAIT)
return -EAGAIN;
inode_lock(inode);
}
+ ret = check_write_restriction(inode);
+ if (ret)
+ goto out;
+
+ if (is_compressed(ni) && (iocb->ki_flags & IOCB_DIRECT)) {
+ ntfs_inode_warn(inode, "direct i/o + compressed not supported");
+ ret = -EOPNOTSUPP;
+ goto out;
+ }
+
ret = generic_write_checks(iocb, from);
if (ret <= 0)
goto out;
--
2.39.5
next prev parent reply other threads:[~2025-04-07 18:12 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 18:11 [PATCH AUTOSEL 6.13 01/28] staging: gpib: Use min for calculating transfer length Sasha Levin
2025-04-07 18:11 ` [PATCH AUTOSEL 6.13 02/28] usb: host: max3421-hcd: Add missing spi_device_id table Sasha Levin
2025-04-07 18:11 ` [PATCH AUTOSEL 6.13 03/28] iio: adc: ad4695: make ad4695_exit_conversion_mode() more robust Sasha Levin
2025-04-07 18:11 ` Sasha Levin [this message]
2025-04-07 18:11 ` [PATCH AUTOSEL 6.13 05/28] fs/ntfs3: Fix WARNING in ntfs_extend_initialized_size Sasha Levin
2025-04-07 18:11 ` [PATCH AUTOSEL 6.13 06/28] phy: qcom: qmp-pcie: Add X1P42100 Gen4x4 PHY Sasha Levin
2025-04-07 18:11 ` [PATCH AUTOSEL 6.13 07/28] usb: dwc3: gadget: Refactor loop to avoid NULL endpoints Sasha Levin
2025-04-07 18:11 ` [PATCH AUTOSEL 6.13 08/28] usb: dwc3: gadget: Avoid using reserved endpoints on Intel Merrifield Sasha Levin
2025-04-07 18:11 ` [PATCH AUTOSEL 6.13 09/28] sound/virtio: Fix cancel_sync warnings on uninitialized work_structs Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 10/28] usb: xhci: Complete 'error mid TD' transfers when handling Missed Service Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 11/28] usb: xhci: Fix isochronous Ring Underrun/Overrun event handling Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 12/28] xhci: Handle spurious events on Etron host isoc enpoints Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 13/28] i3c: master: svc: Add support for Nuvoton npcm845 i3c Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 14/28] dmaengine: dmatest: Fix dmatest waiting less when interrupted Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 15/28] usb: xhci: Avoid Stop Endpoint retry loop if the endpoint seems Running Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 16/28] phy: rockchip: usbdp: Avoid call hpd_event_trigger in dp_phy_init Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 17/28] usb: gadget: aspeed: Add NULL pointer check in ast_vhub_init_dev() Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 18/28] usb: host: xhci-plat: mvebu: use ->quirks instead of ->init_quirk() func Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 19/28] thunderbolt: Scan retimers after device router has been enumerated Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 20/28] um: work around sched_yield not yielding in time-travel mode Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 21/28] iommu/arm-smmu-v3: Set MEV bit in nested STE for DoS mitigations Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 22/28] um: Switch to the pthread-based helper in sigio workaround Sasha Levin
2025-04-08 4:37 ` Tiwei Bie
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 23/28] um: Rewrite the sigio workaround based on epoll and tgkill Sasha Levin
2025-04-08 4:38 ` Tiwei Bie
2025-04-28 0:00 ` Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 24/28] objtool: Silence more KCOV warnings Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 25/28] objtool, panic: Disable SMAP in __stack_chk_fail() Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 26/28] objtool, ASoC: codecs: wcd934x: Remove potential undefined behavior in wcd934x_slim_irq_handler() Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 27/28] objtool, regulator: rk808: Remove potential undefined behavior in rk806_set_mode_dcdc() Sasha Levin
2025-04-07 18:12 ` [PATCH AUTOSEL 6.13 28/28] objtool, lkdtm: Obfuscate the do_nothing() pointer Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250407181224.3180941-4-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhi.xu@windriver.com \
--cc=ntfs3@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=syzbot+5d0bdc98770e6c55a0fd@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox