Skip to contentSkip to conversation

isofs: Annotate struct SL_component with __counted_by()

PATCH In review Thorsten Blum 2 participants 2 messages Aug 30, 2024 – Sep 2, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 isofs: Annotate struct SL_component with __counted_by()

Add the __counted_by compiler attribute to the flexible array member text to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE.

---
 fs/isofs/rock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/isofs/rock.h +1 -1
index ee9660e9671c..7755e587f778 100644
@@ -44,7 +44,7 @@ struct RR_PN_s {
 struct SL_component {
 	__u8 flags;
 	__u8 len;
-	__u8 text[];
+	__u8 text[] __counted_by(len);
 } __attribute__ ((packed));
 
 struct RR_SL_s {
Signature · 1 line
2.46.0
maintainer
#1 lore raw
Quoted 5 lines · Thorsten Blum

Add the __counted_by compiler attribute to the flexible array member text to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE.

Thanks. I've added the patch to my tree.

Honza

Quoted 20 lines
---
 fs/isofs/rock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/isofs/rock.h +1 -1
index ee9660e9671c..7755e587f778 100644
@@ -44,7 +44,7 @@ struct RR_PN_s {
 struct SL_component {
 	__u8 flags;
 	__u8 len;
-	__u8 text[];
+	__u8 text[] __counted_by(len);
 } __attribute__ ((packed));
 
 struct RR_SL_s {
Signature · 1 line
2.46.0
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR