[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <db367563-e144-4a2f-8d67-d1b4e879397e@embeddedor.com>
Date: Mon, 29 Jul 2024 08:09:40 -0600
From: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To: Thorsten Blum <thorsten.blum@...lux.com>, tytso@....edu,
adilger.kernel@...ger.ca, kees@...nel.org, gustavoars@...nel.org
Cc: linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH] ext4: Annotate struct ext4_xattr_inode_array with
__counted_by()
On 29/07/24 05:04, Thorsten Blum wrote:
> Add the __counted_by compiler attribute to the flexible array member
> inodes to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> CONFIG_FORTIFY_SOURCE.
This change seems to be incomplete. The relationship between `count` and
accesses to `inodes` should be adjusted at least in `ext4_expand_inode_array()`
See this for more details:
https://embeddedor.com/blog/2024/06/18/how-to-use-the-new-counted_by-attribute-in-c-and-linux/
Thanks
--
Gustavo
>
> Remove the now obsolete comment on the count field.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@...lux.com>
> ---
> fs/ext4/xattr.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext4/xattr.h b/fs/ext4/xattr.h
> index bd97c4aa8177..e14fb19dc912 100644
> --- a/fs/ext4/xattr.h
> +++ b/fs/ext4/xattr.h
> @@ -130,8 +130,8 @@ struct ext4_xattr_ibody_find {
> };
>
> struct ext4_xattr_inode_array {
> - unsigned int count; /* # of used items in the array */
> - struct inode *inodes[];
> + unsigned int count;
> + struct inode *inodes[] __counted_by(count);
> };
>
> extern const struct xattr_handler ext4_xattr_user_handler;
Powered by blists - more mailing lists