diff mbox series

isofs: Annotate struct SL_component with __counted_by()

Message ID 20240830164902.112682-2-thorsten.blum@toblux.com (mailing list archive)
State Mainlined
Commit 116249b12939a8ec13eb50f36b6fffd1c719a9ed
Headers show
Series isofs: Annotate struct SL_component with __counted_by() | expand

Commit Message

Thorsten Blum Aug. 30, 2024, 4:49 p.m. UTC
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.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 fs/isofs/rock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Kara Sept. 2, 2024, 1:55 p.m. UTC | #1
On Fri 30-08-24 18:49:03, Thorsten Blum wrote:
> 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.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>

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

								Honza

> ---
>  fs/isofs/rock.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/isofs/rock.h b/fs/isofs/rock.h
> index ee9660e9671c..7755e587f778 100644
> --- a/fs/isofs/rock.h
> +++ b/fs/isofs/rock.h
> @@ -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 {
> -- 
> 2.46.0
>
diff mbox series

Patch

diff --git a/fs/isofs/rock.h b/fs/isofs/rock.h
index ee9660e9671c..7755e587f778 100644
--- a/fs/isofs/rock.h
+++ b/fs/isofs/rock.h
@@ -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 {