Revert "bcachefs: Annotate struct bch_xattr with __counted_by()"
PATCH 1/1 Revert "bcachefs: Annotate struct bch_xattr with __counted_by()"
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
--- fs/bcachefs/xattr_format.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/bcachefs/xattr_format.h +1 -1
@@ -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 */
Signature · 1 line
2.48.1
Quoted 6 lines · Alan Huang
This reverts commit
86e92eeeb23741a072fe7532db663250ff2e726a.After the
x_name, there is a value. According to the disscussion[1],__counted_byassumes 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_byhere[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.
Quoted 25 lines
[1] https://lore.kernel.org/lkml/Zv8VDKWN1GzLRT-_@archlinux/T/#m0ce9541c5070146320efd4f928cc1ff8de69e9b2
[2] https://privatebin.net/?a0d4e97d590d71e1#9bLmp2Kb5NU6X6cZEucchDcu88HzUQwHUah8okKPReEtSigned-off-by Alan Huang <[email protected]>--- fs/bcachefs/xattr_format.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/bcachefs/xattr_format.h +1
-1@@ -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 */ Signature · 1 line
2.48.1
Quoted 20 lines · Alan Huang
This reverts commit
86e92eeeb23741a072fe7532db663250ff2e726a.After the
x_name, there is a value. According to the disscussion[1],__counted_byassumes 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_byhere[2], so revert that.[1] https://lore.kernel.org/lkml/Zv8VDKWN1GzLRT-_@archlinux/T/#m0ce9541c5070146320efd4f928cc1ff8de69e9b2
[2] https://privatebin.net/?a0d4e97d590d71e1#9bLmp2Kb5NU6X6cZEucchDcu88HzUQwHUah8okKPReEtSigned-off-by Alan Huang <[email protected]>--- fs/bcachefs/xattr_format.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/bcachefs/xattr_format.h +0
-0
fs/bcachefs/xattr_format.h struct bch_xattr { · line 16
Quoted 5 lines
fs/bcachefs/xattr_format.h +1
-1@@ -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
Quoted 6 lines
fs/bcachefs/xattr_format.h +0
-0} __packed __aligned(8);#endif /* _BCACHEFS_XATTR_FORMAT_H */ Signature · 1 line
2.48.1
Quoted 16 lines · Kent Overstreet
Quoted 15 lines · Alan Huang
This reverts commit
86e92eeeb23741a072fe7532db663250ff2e726a.After the
x_name, there is a value. According to the disscussion[1],__counted_byassumes 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_byhere[2], so revert that.[1] https://lore.kernel.org/lkml/Zv8VDKWN1GzLRT-_@archlinux/T/#m0ce9541c5070146320efd4f928cc1ff8de69e9b2
[2] https://privatebin.net/?a0d4e97d590d71e1#9bLmp2Kb5NU6X6cZEucchDcu88HzUQwHUah8okKPReEtSigned-off-by Alan Huang <[email protected]>--- fs/bcachefs/xattr_format.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines
fs/bcachefs/xattr_format.h struct bch_xattr { · line 16
Quoted 10 lines
fs/bcachefs/xattr_format.h +1
-1@@ -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
Quoted 7 lines
Quoted 7 lines
fs/bcachefs/xattr_format.h +0
-0} __packed __aligned(8);#endif /* _BCACHEFS_XATTR_FORMAT_H */ Signature · 1 line
2.48.1