fs/ntfs3: Fix attr_punch_hole() null pointer derenference
authorAlon Zahavi <zahavi.alon@gmail.com>
Mon, 15 Aug 2022 11:07:12 +0000 (14:07 +0300)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Fri, 30 Sep 2022 14:39:50 +0000 (17:39 +0300)
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>
fs/ntfs3/attrib.c

index 578c2bcfb1d9385e63edebe45ef47206a0691811..63169529b52c499dbbc3d2144e794935ca6b3194 100644 (file)
@@ -2038,7 +2038,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)