[PATCH] fs/affs: struct slink_front: Replace 1-element array with flexible array

Kees Cook posted 1 patch 1 year, 5 months ago
fs/affs/amigaffs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] fs/affs: struct slink_front: Replace 1-element array with flexible array
Posted by Kees Cook 1 year, 5 months ago
Replace the deprecated[1] use of a 1-element array in
struct slink_front with a modern flexible array.

No binary differences are present after this conversion.

Link: https://github.com/KSPP/linux/issues/79 [1]
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: David Sterba <dsterba@suse.com>
Cc: linux-fsdevel@vger.kernel.org
---
 fs/affs/amigaffs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/affs/amigaffs.h b/fs/affs/amigaffs.h
index 81fb396d4dfa..5509fbc98bc0 100644
--- a/fs/affs/amigaffs.h
+++ b/fs/affs/amigaffs.h
@@ -108,7 +108,7 @@ struct slink_front
 	__be32 key;
 	__be32 spare1[3];
 	__be32 checksum;
-	u8 symname[1];	/* depends on block size */
+	u8 symname[];	/* depends on block size */
 };
 
 struct affs_data_head
-- 
2.34.1
Re: [PATCH] fs/affs: struct slink_front: Replace 1-element array with flexible array
Posted by David Sterba 1 year, 5 months ago
On Wed, Jul 10, 2024 at 03:57:34PM -0700, Kees Cook wrote:
> Replace the deprecated[1] use of a 1-element array in
> struct slink_front with a modern flexible array.
> 
> No binary differences are present after this conversion.
> 
> Link: https://github.com/KSPP/linux/issues/79 [1]
> Signed-off-by: Kees Cook <kees@kernel.org>

Thanks, I've added the 3 patches to my tree. I've noticed there's one
more 1-element array in struct affs_root_head (hashtable):

https://elixir.bootlin.com/linux/latest/source/fs/affs/amigaffs.h#L50

The struct is used only partially by AFFS_ROOT_HEAD from affs_fill_super
and not accessing the hashtable. This could have been missed by the
tools you use or was the conversion intentionally skipped?
Re: [PATCH] fs/affs: struct slink_front: Replace 1-element array with flexible array
Posted by Kees Cook 1 year, 5 months ago
On Thu, Jul 11, 2024 at 04:29:28PM +0200, David Sterba wrote:
> On Wed, Jul 10, 2024 at 03:57:34PM -0700, Kees Cook wrote:
> > Replace the deprecated[1] use of a 1-element array in
> > struct slink_front with a modern flexible array.
> > 
> > No binary differences are present after this conversion.
> > 
> > Link: https://github.com/KSPP/linux/issues/79 [1]
> > Signed-off-by: Kees Cook <kees@kernel.org>
> 
> Thanks, I've added the 3 patches to my tree.

Thanks!

> I've noticed there's one
> more 1-element array in struct affs_root_head (hashtable):
> 
> https://elixir.bootlin.com/linux/latest/source/fs/affs/amigaffs.h#L50
> 
> The struct is used only partially by AFFS_ROOT_HEAD from affs_fill_super
> and not accessing the hashtable. This could have been missed by the
> tools you use or was the conversion intentionally skipped?

Yeah -- this was intentional. We wanted to finish conversion of members
that were actually being used by the kernel. There is a lot of UAPI and
"all possible data structures" structs declared in the kernel that we
were wading through only to find they weren't actually being used.

That said, I'm happy to send a patch to convert hashtable -- it's not
used so it can't break anything. ;)

-- 
Kees Cook
Re: [PATCH] fs/affs: struct slink_front: Replace 1-element array with flexible array
Posted by Gustavo A. R. Silva 1 year, 5 months ago

On 10/07/24 16:57, Kees Cook wrote:
> Replace the deprecated[1] use of a 1-element array in
> struct slink_front with a modern flexible array.
> 
> No binary differences are present after this conversion.
> 
> Link: https://github.com/KSPP/linux/issues/79 [1]
> Signed-off-by: Kees Cook <kees@kernel.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
> Cc: David Sterba <dsterba@suse.com>
> Cc: linux-fsdevel@vger.kernel.org

> ---
>   fs/affs/amigaffs.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/affs/amigaffs.h b/fs/affs/amigaffs.h
> index 81fb396d4dfa..5509fbc98bc0 100644
> --- a/fs/affs/amigaffs.h
> +++ b/fs/affs/amigaffs.h
> @@ -108,7 +108,7 @@ struct slink_front
>   	__be32 key;
>   	__be32 spare1[3];
>   	__be32 checksum;
> -	u8 symname[1];	/* depends on block size */
> +	u8 symname[];	/* depends on block size */
>   };
>   
>   struct affs_data_head