Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: raid56: fix a out-of-boundary access for sub-page systems
Date: Fri, 14 Nov 2025 10:22:31 +0530	[thread overview]
Message-ID: <9c0261dc-e838-42f0-9a70-5b351e7a90ce@linux.ibm.com> (raw)
In-Reply-To: <bbd1a41c70c0f37da9e3e82aa89784e831b0e889.1763069997.git.wqu@suse.com>


On 14/11/25 3:09 am, Qu Wenruo wrote:
> [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>


Tested this patch, by applying on top of next-20251113 and this fixes 
the reported issue. Hence,

Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>


Regards,

Venkat.

> ---
> 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);
>   	}
>   }
>   

      parent reply	other threads:[~2025-11-14  4:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=9c0261dc-e838-42f0-9a70-5b351e7a90ce@linux.ibm.com \
    --to=venkat88@linux.ibm.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.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