* [PATCH] Revert "bcachefs: Annotate struct bch_xattr with __counted_by()"
@ 2025-05-01 18:41 Alan Huang
2025-05-01 19:09 ` Jan Hendrik Farr
2025-05-01 19:16 ` Kent Overstreet
0 siblings, 2 replies; 4+ messages in thread
From: Alan Huang @ 2025-05-01 18:41 UTC (permalink / raw)
To: kent.overstreet, kees, gustavoars, thorsten.blum
Cc: linux-bcachefs, linux-hardening, Alan Huang
This reverts commit 86e92eeeb23741a072fe7532db663250ff2e726a.
After the x_name, there is a value. According to the disscussion[1],
__counted_by assumes that the flexible array member contains exactly
the amount of elements that are specified. Now there are users came across
buffer overflow caused by the __counted_by here[2], so revert that.
[1] https://lore.kernel.org/lkml/Zv8VDKWN1GzLRT-_@archlinux/T/#m0ce9541c5070146320efd4f928cc1ff8de69e9b2
[2] https://privatebin.net/?a0d4e97d590d71e1#9bLmp2Kb5NU6X6cZEucchDcu88HzUQwHUah8okKPReEt
Signed-off-by: Alan Huang <mmpgouride@gmail.com>
---
fs/bcachefs/xattr_format.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/bcachefs/xattr_format.h b/fs/bcachefs/xattr_format.h
index c7916011ef34..e9f810539552 100644
--- a/fs/bcachefs/xattr_format.h
+++ b/fs/bcachefs/xattr_format.h
@@ -13,7 +13,7 @@ struct bch_xattr {
__u8 x_type;
__u8 x_name_len;
__le16 x_val_len;
- __u8 x_name[] __counted_by(x_name_len);
+ __u8 x_name[];
} __packed __aligned(8);
#endif /* _BCACHEFS_XATTR_FORMAT_H */
--
2.48.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Revert "bcachefs: Annotate struct bch_xattr with __counted_by()"
2025-05-01 18:41 [PATCH] Revert "bcachefs: Annotate struct bch_xattr with __counted_by()" Alan Huang
@ 2025-05-01 19:09 ` Jan Hendrik Farr
2025-05-01 19:16 ` Kent Overstreet
1 sibling, 0 replies; 4+ messages in thread
From: Jan Hendrik Farr @ 2025-05-01 19:09 UTC (permalink / raw)
To: Alan Huang
Cc: kent.overstreet, kees, gustavoars, thorsten.blum, linux-bcachefs,
linux-hardening
On 02 02:41:50, Alan Huang wrote:
> This reverts commit 86e92eeeb23741a072fe7532db663250ff2e726a.
>
> After the x_name, there is a value. According to the disscussion[1],
> __counted_by assumes that the flexible array member contains exactly
> the amount of elements that are specified. Now there are users came across
> buffer overflow caused by the __counted_by here[2], so revert that.
Nit: It's not causing a buffer overflow. It's causing a false positive
detection of an out of bounds write.
>
> [1] https://lore.kernel.org/lkml/Zv8VDKWN1GzLRT-_@archlinux/T/#m0ce9541c5070146320efd4f928cc1ff8de69e9b2
> [2] https://privatebin.net/?a0d4e97d590d71e1#9bLmp2Kb5NU6X6cZEucchDcu88HzUQwHUah8okKPReEt
>
> Signed-off-by: Alan Huang <mmpgouride@gmail.com>
> ---
> fs/bcachefs/xattr_format.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/bcachefs/xattr_format.h b/fs/bcachefs/xattr_format.h
> index c7916011ef34..e9f810539552 100644
> --- a/fs/bcachefs/xattr_format.h
> +++ b/fs/bcachefs/xattr_format.h
> @@ -13,7 +13,7 @@ struct bch_xattr {
> __u8 x_type;
> __u8 x_name_len;
> __le16 x_val_len;
> - __u8 x_name[] __counted_by(x_name_len);
> + __u8 x_name[];
> } __packed __aligned(8);
>
> #endif /* _BCACHEFS_XATTR_FORMAT_H */
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Revert "bcachefs: Annotate struct bch_xattr with __counted_by()"
2025-05-01 18:41 [PATCH] Revert "bcachefs: Annotate struct bch_xattr with __counted_by()" Alan Huang
2025-05-01 19:09 ` Jan Hendrik Farr
@ 2025-05-01 19:16 ` Kent Overstreet
2025-05-01 19:22 ` Jan Hendrik Farr
1 sibling, 1 reply; 4+ messages in thread
From: Kent Overstreet @ 2025-05-01 19:16 UTC (permalink / raw)
To: Alan Huang
Cc: kees, gustavoars, thorsten.blum, linux-bcachefs, linux-hardening
On Fri, May 02, 2025 at 02:41:50AM +0800, Alan Huang wrote:
> This reverts commit 86e92eeeb23741a072fe7532db663250ff2e726a.
>
> After the x_name, there is a value. According to the disscussion[1],
> __counted_by assumes that the flexible array member contains exactly
> the amount of elements that are specified. Now there are users came across
> buffer overflow caused by the __counted_by here[2], so revert that.
>
> [1] https://lore.kernel.org/lkml/Zv8VDKWN1GzLRT-_@archlinux/T/#m0ce9541c5070146320efd4f928cc1ff8de69e9b2
> [2] https://privatebin.net/?a0d4e97d590d71e1#9bLmp2Kb5NU6X6cZEucchDcu88HzUQwHUah8okKPReEt
>
> Signed-off-by: Alan Huang <mmpgouride@gmail.com>
> ---
> fs/bcachefs/xattr_format.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/bcachefs/xattr_format.h b/fs/bcachefs/xattr_format.h
> index c7916011ef34..e9f810539552 100644
> --- a/fs/bcachefs/xattr_format.h
> +++ b/fs/bcachefs/xattr_format.h
> @@ -13,7 +13,7 @@ struct bch_xattr {
> __u8 x_type;
> __u8 x_name_len;
> __le16 x_val_len;
> - __u8 x_name[] __counted_by(x_name_len);
> + __u8 x_name[];
this needs a comment, so we don't make the same mistake again
> } __packed __aligned(8);
>
> #endif /* _BCACHEFS_XATTR_FORMAT_H */
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Revert "bcachefs: Annotate struct bch_xattr with __counted_by()"
2025-05-01 19:16 ` Kent Overstreet
@ 2025-05-01 19:22 ` Jan Hendrik Farr
0 siblings, 0 replies; 4+ messages in thread
From: Jan Hendrik Farr @ 2025-05-01 19:22 UTC (permalink / raw)
To: Kent Overstreet
Cc: Alan Huang, kees, gustavoars, thorsten.blum, linux-bcachefs,
linux-hardening
On 01 15:16:55, Kent Overstreet wrote:
> On Fri, May 02, 2025 at 02:41:50AM +0800, Alan Huang wrote:
> > This reverts commit 86e92eeeb23741a072fe7532db663250ff2e726a.
> >
> > After the x_name, there is a value. According to the disscussion[1],
> > __counted_by assumes that the flexible array member contains exactly
> > the amount of elements that are specified. Now there are users came across
> > buffer overflow caused by the __counted_by here[2], so revert that.
> >
> > [1] https://lore.kernel.org/lkml/Zv8VDKWN1GzLRT-_@archlinux/T/#m0ce9541c5070146320efd4f928cc1ff8de69e9b2
> > [2] https://privatebin.net/?a0d4e97d590d71e1#9bLmp2Kb5NU6X6cZEucchDcu88HzUQwHUah8okKPReEt
> >
> > Signed-off-by: Alan Huang <mmpgouride@gmail.com>
> > ---
> > fs/bcachefs/xattr_format.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/bcachefs/xattr_format.h b/fs/bcachefs/xattr_format.h
> > index c7916011ef34..e9f810539552 100644
> > --- a/fs/bcachefs/xattr_format.h
> > +++ b/fs/bcachefs/xattr_format.h
> > @@ -13,7 +13,7 @@ struct bch_xattr {
> > __u8 x_type;
> > __u8 x_name_len;
> > __le16 x_val_len;
> > - __u8 x_name[] __counted_by(x_name_len);
> > + __u8 x_name[];
>
> this needs a comment, so we don't make the same mistake again
Better yet: change x_name to x_name_and_value
>
> > } __packed __aligned(8);
> >
> > #endif /* _BCACHEFS_XATTR_FORMAT_H */
> > --
> > 2.48.1
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-01 19:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-01 18:41 [PATCH] Revert "bcachefs: Annotate struct bch_xattr with __counted_by()" Alan Huang
2025-05-01 19:09 ` Jan Hendrik Farr
2025-05-01 19:16 ` Kent Overstreet
2025-05-01 19:22 ` Jan Hendrik Farr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox