[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202405131828.9CD8E5A@keescook>
Date: Mon, 13 May 2024 18:29:35 -0700
From: Kees Cook <keescook@...omium.org>
To: Bill Wendling <morbo@...gle.com>
Cc: Mikulas Patocka <mikulas@...ax.karlin.mff.cuni.cz>,
"Gustavo A . R . Silva" <gustavoars@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Justin Stitt <justinstitt@...gle.com>,
LKML <linux-kernel@...r.kernel.org>,
linux-hardening@...r.kernel.org,
clang-built-linux <llvm@...ts.linux.dev>
Subject: Re: [PATCH] hpfs: Annotate struct hpfs_dirent with __counted_by
On Mon, May 13, 2024 at 04:45:54PM -0700, Bill Wendling wrote:
> Prepare for the coming implementation by GCC and Clang of the
> __counted_by attribute. Flexible array members annotated with
> __counted_by can have their accesses bounds-checked at run-time checking
> via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
> (for strcpy/memcpy-family functions).
>
> Cc: Mikulas Patocka <mikulas@...ax.karlin.mff.cuni.cz>
> Cc: Kees Cook <keescook@...omium.org>
> Cc: "Gustavo A. R. Silva" <gustavoars@...nel.org>
> Cc: Nathan Chancellor <nathan@...nel.org>
> Cc: Nick Desaulniers <ndesaulniers@...gle.com>
> Cc: Justin Stitt <justinstitt@...gle.com>
> Cc: linux-kernel@...r.kernel.org
> Cc: linux-hardening@...r.kernel.org
> Cc: llvm@...ts.linux.dev
> Signed-off-by: Bill Wendling <morbo@...gle.com>
> ---
> fs/hpfs/hpfs.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/hpfs/hpfs.h b/fs/hpfs/hpfs.h
> index 281dec8f636b..ac137787f1f9 100644
> --- a/fs/hpfs/hpfs.h
> +++ b/fs/hpfs/hpfs.h
> @@ -357,7 +357,7 @@ struct hpfs_dirent {
> u8 ix; /* code page index (of filename), see
> struct code_page_data */
> u8 namelen; /* file name length */
> - u8 name[]; /* file name */
> + u8 name[] __counted_by(namelen); /* 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. */
Looking through struct hpfs_dirent::name uses, I think everything checks
out. I do see some confusing manipulations in hpfs_add_de(), though. I
*think* it'll be okay, though.
Reviewed-by: Kees Cook <keescook@...omium.org>
--
Kees Cook
Powered by blists - more mailing lists