Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs: raid56: fix a out-of-boundary access for sub-page systems
@ 2025-11-13 21:39 Qu Wenruo
  2025-11-13 21:57 ` Qu Wenruo
  2025-11-14  4:52 ` Venkat Rao Bagalkote
  0 siblings, 2 replies; 3+ messages in thread
From: Qu Wenruo @ 2025-11-13 21:39 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Venkat Rao Bagalkote

[BUG]
There is a bug report from IBM that on Power11 the test case btrfs/023
crashed.

The call trace itself is not useful as this particular case is a wild
memory write, which corrupted the SLUB system.

[CAUSE]
Inside index_stripe_sectors() we will update rbio->stripe_paddrs[] array
to reflect the latest stripe_pages[].

We use the physical address of the corresponding page, add an offset
inside the page to represent the sector.

However in patch "btrfs: raid56: remove sector_ptr structure", the
offset is added to the stripe_pages[] array, not the result of
page_to_phys().

This makes the stripe_paddrs[] to be hugely incorrect for subpage
systems.

[FIX]
Fix the calculation by adding the offset after page_to_phys().

Reported-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
The fix will be folded into the offending patch.
---
 fs/btrfs/raid56.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index ad3d5e789158..7cb756ac19ba 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -331,8 +331,8 @@ static void index_stripe_sectors(struct btrfs_raid_bio *rbio)
 		if (!rbio->stripe_pages[page_index])
 			continue;
 
-		rbio->stripe_paddrs[i] = page_to_phys(rbio->stripe_pages[page_index] +
-						      offset_in_page(offset));
+		rbio->stripe_paddrs[i] = page_to_phys(rbio->stripe_pages[page_index]) +
+						      offset_in_page(offset);
 	}
 }
 
-- 
2.51.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-14  4:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-13 21:39 [PATCH] btrfs: raid56: fix a out-of-boundary access for sub-page systems Qu Wenruo
2025-11-13 21:57 ` Qu Wenruo
2025-11-14  4:52 ` Venkat Rao Bagalkote

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox