Skip to contentSkip to conversation

ntfs3: Fix attr_punch_hole() null pointer derenference

PATCH Applied Alon Zahavi 4 participants 5 messages Aug 15, 2022 – Jan 22, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ntfs3: Fix attr_punch_hole() null pointer derenference

From: Alon Zahavi <[email protected]>

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.

---
 fs/ntfs3/attrib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/attrib.c +1 -1
index e8c00dda42ad..4e74bc8f01ed 100644
@@ -1949,7 +1949,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)
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 21 lines · Alon Zahavi

From: Alon Zahavi <[email protected]>

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.

---
  fs/ntfs3/attrib.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/attrib.c +0 -0
index e8c00dda42ad..4e74bc8f01ed 100644

fs/ntfs3/attrib.c int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32 *frame_size) · line 1955

Quoted 8 lines
fs/ntfs3/attrib.c +1 -1
@@ -1949,7 +1949,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)

Applied, thanks!

#2 lore raw
In reply to Alon Zahavi

Hello,

Quoted 6 lines · On Mon, 15 Aug 2022 14:07:12 +0300 Alon Zahavi <[email protected]> wrote:

From: Alon Zahavi <[email protected]>

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.

Quoted 6 lines

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

This patch has now merged in mainline as 6d5c9e79b726cc473d40e9cb60976dbe8e669624. stable@, could you please merge this in stable kernels?

Fixes be71b5cba2e64 ("fs/ntfs3: Add attrib operations") # 5.14

Thanks,
SJ

Quoted 21 lines
---
 fs/ntfs3/attrib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/attrib.c +1 -1
index e8c00dda42ad..4e74bc8f01ed 100644
@@ -1949,7 +1949,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)
Signature · 1 line
2.25.1
maintainer
#3 lore raw
Quoted 17 lines · SeongJae Park

Hello,

Quoted 6 lines · On Mon, 15 Aug 2022 14:07:12 +0300 Alon Zahavi <[email protected]> wrote:

From: Alon Zahavi <[email protected]>

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.

Quoted 6 lines

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

Quoted 6 lines

This patch has now merged in mainline as 6d5c9e79b726cc473d40e9cb60976dbe8e669624. stable@, could you please merge this in stable kernels?

Fixes be71b5cba2e64 ("fs/ntfs3: Add attrib operations") # 5.14

Now queued up, thanks.

greg k-h

#4 lore raw
In reply to Alon Zahavi

Hello,

Quoted 6 lines · On Mon, 15 Aug 2022 14:07:12 +0300 Alon Zahavi <[email protected]> wrote:

From: Alon Zahavi <[email protected]>

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.

Quoted 6 lines

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

This patch has now merged in mainline as 6d5c9e79b726cc473d40e9cb60976dbe8e669624. stable@, could you please merge this in stable kernels?

Fixes be71b5cba2e64 ("fs/ntfs3: Add attrib operations") # 5.14

Thanks,
SJ

Quoted 21 lines
---
 fs/ntfs3/attrib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/attrib.c +1 -2
index e8c00dda42ad..4e74bc8f01ed 100644
@@ -1949,7 +1949,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)
--

2.25.1