Message ID | 20201004180428.14494-7-willy@infradead.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix a pile of 4GB file problems on 32-bit | expand |
On 10/4/20 2:04 PM, Matthew Wilcox (Oracle) wrote: > On 32-bit systems, this shift will overflow for files larger than 4GB. > > Cc: stable@vger.kernel.org > Fixes: 53b381b3abeb ("Btrfs: RAID5 and RAID6") > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Thanks, Josef
On Sun, Oct 04, 2020 at 07:04:27PM +0100, Matthew Wilcox (Oracle) wrote: > On 32-bit systems, this shift will overflow for files larger than 4GB. > > Cc: stable@vger.kernel.org > Fixes: 53b381b3abeb ("Btrfs: RAID5 and RAID6") > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> > --- > fs/btrfs/raid56.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c > index 255490f42b5d..5ee0a53301bd 100644 > --- a/fs/btrfs/raid56.c > +++ b/fs/btrfs/raid56.c > @@ -1089,7 +1089,7 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio, > u64 disk_start; > > stripe = &rbio->bbio->stripes[stripe_nr]; > - disk_start = stripe->physical + (page_index << PAGE_SHIFT); > + disk_start = stripe->physical + ((loff_t)page_index << PAGE_SHIFT); It seems that this patch is mechanical replacement. If you check the callers, the page_index is passed from an int that iterates over bits set in an unsigned long (bitmap). The result won't overflow.
On Mon, Oct 26, 2020 at 05:35:46PM +0100, David Sterba wrote: > On Sun, Oct 04, 2020 at 07:04:27PM +0100, Matthew Wilcox (Oracle) wrote: > > On 32-bit systems, this shift will overflow for files larger than 4GB. > > > > Cc: stable@vger.kernel.org > > Fixes: 53b381b3abeb ("Btrfs: RAID5 and RAID6") > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> > > --- > > fs/btrfs/raid56.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c > > index 255490f42b5d..5ee0a53301bd 100644 > > --- a/fs/btrfs/raid56.c > > +++ b/fs/btrfs/raid56.c > > @@ -1089,7 +1089,7 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio, > > u64 disk_start; > > > > stripe = &rbio->bbio->stripes[stripe_nr]; > > - disk_start = stripe->physical + (page_index << PAGE_SHIFT); > > + disk_start = stripe->physical + ((loff_t)page_index << PAGE_SHIFT); > > It seems that this patch is mechanical replacement. If you check the > callers, the page_index is passed from an int that iterates over bits > set in an unsigned long (bitmap). The result won't overflow. Not mechanical, but I clearly made mistakes. Will you pick up the patches which actually fix bugs?
On Mon, Oct 26, 2020 at 04:44:42PM +0000, Matthew Wilcox wrote: > On Mon, Oct 26, 2020 at 05:35:46PM +0100, David Sterba wrote: > > On Sun, Oct 04, 2020 at 07:04:27PM +0100, Matthew Wilcox (Oracle) wrote: > > > On 32-bit systems, this shift will overflow for files larger than 4GB. > > > > > > Cc: stable@vger.kernel.org > > > Fixes: 53b381b3abeb ("Btrfs: RAID5 and RAID6") > > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> > > > --- > > > fs/btrfs/raid56.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c > > > index 255490f42b5d..5ee0a53301bd 100644 > > > --- a/fs/btrfs/raid56.c > > > +++ b/fs/btrfs/raid56.c > > > @@ -1089,7 +1089,7 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio, > > > u64 disk_start; > > > > > > stripe = &rbio->bbio->stripes[stripe_nr]; > > > - disk_start = stripe->physical + (page_index << PAGE_SHIFT); > > > + disk_start = stripe->physical + ((loff_t)page_index << PAGE_SHIFT); > > > > It seems that this patch is mechanical replacement. If you check the > > callers, the page_index is passed from an int that iterates over bits > > set in an unsigned long (bitmap). The result won't overflow. > > Not mechanical, but I clearly made mistakes. Will you pick up the > patches which actually fix bugs? Yes, I just replied to the first patch, that does fix an overflow.
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 255490f42b5d..5ee0a53301bd 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -1089,7 +1089,7 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio, u64 disk_start; stripe = &rbio->bbio->stripes[stripe_nr]; - disk_start = stripe->physical + (page_index << PAGE_SHIFT); + disk_start = stripe->physical + ((loff_t)page_index << PAGE_SHIFT); /* if the device is missing, just fail this stripe */ if (!stripe->dev->bdev)
On 32-bit systems, this shift will overflow for files larger than 4GB. Cc: stable@vger.kernel.org Fixes: 53b381b3abeb ("Btrfs: RAID5 and RAID6") Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- fs/btrfs/raid56.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)