Re: [PATCH 1/1] rpdfs: Fix memcpy() warnings about exceeding array boundaries

Zach Brown <[email protected]> Wed, 25 Feb 2026 13:27:49 -0800
Newsgroups dev.linux.lists.rpdfs-devel
Message-ID <[email protected]>
On Tue, Feb 24, 2026 at 12:32:06PM -0600, Chris Kirby wrote:
> Fix kernel memcpy() warnings about exceeding array boundaries when
> using flex arrays.
> 
> Remove the array size from the flex arrays in struct rpdfs_dirent
> and struct rpdfs_xattr.

Hmm.

> @@ -177,7 +177,7 @@ struct rpdfs_dirent {
>  	struct rpdfs_ino_gen ig; /* inode number and generation */
>  	__u8 pers_dtype; /* rpdfs persistent directory entry type */
>  	__u8 name_len; /* no null termination */
> -	__u8 name[6]; /* definition pads to alignment, stored can be smaller */
> +	__u8 name[];
>  };

The padding is load-bearing.  Well, sort of.

While we don't yet, the intent is to use -Wpadded to make sure that
we're not accidentally introducing internal padding in these structs
that make it out over the wire and onto persistence.  (That can then be
a vector for uninitialized stack data to leak out.. that whole thing.)

I kind of remember running into this and getting around it without
changing the struct definition.  Is it fixable by doing things like
(ptr->foo + x) intead of (&ptr->foo[x])?  My memory's failing me.

In any case, if we do have to change the struct, we want padding to be
explicit.  At worst, something like a union that includes the flex array
and then padding.  That sounds pretty gross, so hopefully we don't have
to.

- z