From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH][next] hpfs: Replace one-element array with flexible-array member
Date: Thu, 15 Apr 2021 14:54:31 -0500 [thread overview]
Message-ID: <d204fcb3-d8d0-34ad-1f22-79104ac32ac7@embeddedor.com> (raw)
In-Reply-To: <20210326173510.GA81212@embeddedor>
Hi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
On 3/26/21 12:35, Gustavo A. R. Silva wrote:
> There is a regular need in the kernel to provide a way to declare having
> a dynamically sized set of trailing elements in a structure. Kernel code
> should always use “flexible array members”[1] for these cases. The older
> style of one-element or zero-length arrays should no longer be used[2].
>
> Also, this helps with the ongoing efforts to enable -Warray-bounds by
> fixing the following warning:
>
> CC [M] fs/hpfs/dir.o
> fs/hpfs/dir.c: In function ‘hpfs_readdir’:
> fs/hpfs/dir.c:163:41: warning: array subscript 1 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} [-Warray-bounds]
> 163 | || de ->name[0] != 1 || de->name[1] != 1))
> | ~~~~~~~~^~~
>
> [1] https://en.wikipedia.org/wiki/Flexible_array_member
> [2] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays
>
> Link: https://github.com/KSPP/linux/issues/79
> Link: https://github.com/KSPP/linux/issues/109
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
> fs/hpfs/hpfs.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/hpfs/hpfs.h b/fs/hpfs/hpfs.h
> index 302f45101a96..d92c4af3e1b4 100644
> --- a/fs/hpfs/hpfs.h
> +++ b/fs/hpfs/hpfs.h
> @@ -356,7 +356,8 @@ struct hpfs_dirent {
> u8 no_of_acls; /* number of ACL's (low 3 bits) */
> u8 ix; /* code page index (of filename), see
> struct code_page_data */
> - u8 namelen, name[1]; /* file name */
> + u8 namelen; /* file name length */
> + u8 name[]; /* file name */
> /* dnode_secno down; btree down pointer, if present,
> follows name on next word boundary, or maybe it
> precedes next dirent, which is on a word boundary. */
>
prev parent reply other threads:[~2021-04-15 20:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-26 17:35 [PATCH][next] hpfs: Replace one-element array with flexible-array member Gustavo A. R. Silva
2021-04-15 19:54 ` Gustavo A. R. Silva [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d204fcb3-d8d0-34ad-1f22-79104ac32ac7@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=akpm@linux-foundation.org \
--cc=gustavoars@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikulas@artax.karlin.mff.cuni.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox