diff mbox series

[SRU,Jammy-OEM-5.17/OEM-6.0,1/1] fs/ntfs3: Fix attr_punch_hole() null pointer derenference

Message ID 20230609180027.41969-2-yuxuan.luo@canonical.com
State New
Headers show
Series CVE-2022-4842 | expand

Commit Message

Yuxuan Luo June 9, 2023, 6 p.m. UTC
From: Alon Zahavi <zahavi.alon@gmail.com>

The bug occours due to a misuse of `attr` variable instead of `attr_b`.
`attr` is being initialized as NULL, then being derenfernced
as `attr->res.data_size`.

This bug causes a crash of the ntfs3 driver itself,
If compiled directly to the kernel, it crashes the whole system.

Signed-off-by: Alon Zahavi <zahavi.alon@gmail.com>
Co-developed-by: Tal Lossos <tallossos@gmail.com>
Signed-off-by: Tal Lossos <tallossos@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
(cherry picked from commit 6d5c9e79b726cc473d40e9cb60976dbe8e669624)
CVE-2022-4842
Signed-off-by: Yuxuan Luo <yuxuan.luo@canonical.com>
---
 fs/ntfs3/attrib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index 71f870d497ae..59b234046fd6 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -2020,7 +2020,7 @@  int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32 *frame_size)
 		return -ENOENT;
 
 	if (!attr_b->non_res) {
-		u32 data_size = le32_to_cpu(attr->res.data_size);
+		u32 data_size = le32_to_cpu(attr_b->res.data_size);
 		u32 from, to;
 
 		if (vbo > data_size)