Linux bcachefs list
 help / color / mirror / Atom feed
* [PATCH] bcachefs: Fix invalid shift in member_to_text()
@ 2024-10-12  2:09 Kent Overstreet
  2024-10-12  3:37 ` Hongbo Li
  0 siblings, 1 reply; 3+ messages in thread
From: Kent Overstreet @ 2024-10-12  2:09 UTC (permalink / raw)
  To: linux-bcachefs; +Cc: Kent Overstreet, syzbot+064ce437a1ad63d3f6ef

Reported-by: syzbot+064ce437a1ad63d3f6ef@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
 fs/bcachefs/sb-members.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/bcachefs/sb-members.c b/fs/bcachefs/sb-members.c
index 02bcde3c1b02..b06ba1d0d037 100644
--- a/fs/bcachefs/sb-members.c
+++ b/fs/bcachefs/sb-members.c
@@ -247,7 +247,10 @@ static void member_to_text(struct printbuf *out,
 	prt_newline(out);
 
 	prt_printf(out, "Btree allocated bitmap blocksize:\t");
-	prt_units_u64(out, 1ULL << m.btree_bitmap_shift);
+	if (m.btree_bitmap_shift < 64)
+		prt_units_u64(out, 1ULL << m.btree_bitmap_shift);
+	else
+		prt_printf(out, "(invalid shift %u)", m.btree_bitmap_shift);
 	prt_newline(out);
 
 	prt_printf(out, "Btree allocated bitmap:\t");
-- 
2.45.2


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

* Re: [PATCH] bcachefs: Fix invalid shift in member_to_text()
  2024-10-12  2:09 [PATCH] bcachefs: Fix invalid shift in member_to_text() Kent Overstreet
@ 2024-10-12  3:37 ` Hongbo Li
  2024-10-12  4:25   ` Kent Overstreet
  0 siblings, 1 reply; 3+ messages in thread
From: Hongbo Li @ 2024-10-12  3:37 UTC (permalink / raw)
  To: Kent Overstreet, linux-bcachefs; +Cc: syzbot+064ce437a1ad63d3f6ef



On 2024/10/12 10:09, Kent Overstreet wrote:
> Reported-by: syzbot+064ce437a1ad63d3f6ef@syzkaller.appspotmail.com
> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
> ---
>   fs/bcachefs/sb-members.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/bcachefs/sb-members.c b/fs/bcachefs/sb-members.c
> index 02bcde3c1b02..b06ba1d0d037 100644
> --- a/fs/bcachefs/sb-members.c
> +++ b/fs/bcachefs/sb-members.c
> @@ -247,7 +247,10 @@ static void member_to_text(struct printbuf *out,
>   	prt_newline(out);
>   
>   	prt_printf(out, "Btree allocated bitmap blocksize:\t");
> -	prt_units_u64(out, 1ULL << m.btree_bitmap_shift);
> +	if (m.btree_bitmap_shift < 64)
> +		prt_units_u64(out, 1ULL << m.btree_bitmap_shift);
> +	else
> +		prt_printf(out, "(invalid shift %u)", m.btree_bitmap_shift);

I wonder why we don't check in .validate, like the former 
csum_granularity_bits does.

Thanks,
Hongbo

>   	prt_newline(out);
>   
>   	prt_printf(out, "Btree allocated bitmap:\t");

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

* Re: [PATCH] bcachefs: Fix invalid shift in member_to_text()
  2024-10-12  3:37 ` Hongbo Li
@ 2024-10-12  4:25   ` Kent Overstreet
  0 siblings, 0 replies; 3+ messages in thread
From: Kent Overstreet @ 2024-10-12  4:25 UTC (permalink / raw)
  To: Hongbo Li; +Cc: linux-bcachefs, syzbot+064ce437a1ad63d3f6ef

On Sat, Oct 12, 2024 at 11:37:27AM GMT, Hongbo Li wrote:
> 
> 
> On 2024/10/12 10:09, Kent Overstreet wrote:
> > Reported-by: syzbot+064ce437a1ad63d3f6ef@syzkaller.appspotmail.com
> > Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
> > ---
> >   fs/bcachefs/sb-members.c | 5 ++++-
> >   1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/bcachefs/sb-members.c b/fs/bcachefs/sb-members.c
> > index 02bcde3c1b02..b06ba1d0d037 100644
> > --- a/fs/bcachefs/sb-members.c
> > +++ b/fs/bcachefs/sb-members.c
> > @@ -247,7 +247,10 @@ static void member_to_text(struct printbuf *out,
> >   	prt_newline(out);
> >   	prt_printf(out, "Btree allocated bitmap blocksize:\t");
> > -	prt_units_u64(out, 1ULL << m.btree_bitmap_shift);
> > +	if (m.btree_bitmap_shift < 64)
> > +		prt_units_u64(out, 1ULL << m.btree_bitmap_shift);
> > +	else
> > +		prt_printf(out, "(invalid shift %u)", m.btree_bitmap_shift);
> 
> I wonder why we don't check in .validate, like the former
> csum_granularity_bits does.

actually we need to do both; we want to be able to print things that
don't validate so that we can debug. I'll make that change, thanks

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

end of thread, other threads:[~2024-10-12  4:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-12  2:09 [PATCH] bcachefs: Fix invalid shift in member_to_text() Kent Overstreet
2024-10-12  3:37 ` Hongbo Li
2024-10-12  4:25   ` Kent Overstreet

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