* [PATCH] vboxsf: Add __nonstring annotations for unterminated strings
@ 2025-03-10 22:25 Kees Cook
2025-03-11 10:09 ` Hans de Goede
2025-03-11 12:07 ` Christian Brauner
0 siblings, 2 replies; 3+ messages in thread
From: Kees Cook @ 2025-03-10 22:25 UTC (permalink / raw)
To: Hans de Goede
Cc: Kees Cook, Brahmajit Das, Christian Brauner, linux-fsdevel,
linux-kernel, linux-hardening
When a character array without a terminating NUL character has a static
initializer, GCC 15's -Wunterminated-string-initialization will only
warn if the array lacks the "nonstring" attribute[1]. Mark the arrays
with __nonstring to and correctly identify the char array as "not a C
string" and thereby eliminate the warning.
This effectively reverts the change in 4e7487245abc ("vboxsf: fix building
with GCC 15"), to add the annotation that has other uses (i.e. warning
if the string is ever used with C string APIs).
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178 [1]
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Brahmajit Das <brahmajit.xyz@gmail.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
---
fs/vboxsf/super.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/vboxsf/super.c b/fs/vboxsf/super.c
index 1d94bb784108..0bc96ab6580b 100644
--- a/fs/vboxsf/super.c
+++ b/fs/vboxsf/super.c
@@ -21,8 +21,7 @@
#define VBOXSF_SUPER_MAGIC 0x786f4256 /* 'VBox' little endian */
-static const unsigned char VBSF_MOUNT_SIGNATURE[4] = { '\000', '\377', '\376',
- '\375' };
+static const unsigned char VBSF_MOUNT_SIGNATURE[4] __nonstring = "\000\377\376\375";
static int follow_symlinks;
module_param(follow_symlinks, int, 0444);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] vboxsf: Add __nonstring annotations for unterminated strings
2025-03-10 22:25 [PATCH] vboxsf: Add __nonstring annotations for unterminated strings Kees Cook
@ 2025-03-11 10:09 ` Hans de Goede
2025-03-11 12:07 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2025-03-11 10:09 UTC (permalink / raw)
To: Kees Cook
Cc: Brahmajit Das, Christian Brauner, linux-fsdevel, linux-kernel,
linux-hardening
Hi,
On 10-Mar-25 11:25 PM, Kees Cook wrote:
> When a character array without a terminating NUL character has a static
> initializer, GCC 15's -Wunterminated-string-initialization will only
> warn if the array lacks the "nonstring" attribute[1]. Mark the arrays
> with __nonstring to and correctly identify the char array as "not a C
> string" and thereby eliminate the warning.
>
> This effectively reverts the change in 4e7487245abc ("vboxsf: fix building
> with GCC 15"), to add the annotation that has other uses (i.e. warning
> if the string is ever used with C string APIs).
>
> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178 [1]
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Brahmajit Das <brahmajit.xyz@gmail.com>
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: linux-fsdevel@vger.kernel.org
> Signed-off-by: Kees Cook <kees@kernel.org>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
> ---
> fs/vboxsf/super.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/vboxsf/super.c b/fs/vboxsf/super.c
> index 1d94bb784108..0bc96ab6580b 100644
> --- a/fs/vboxsf/super.c
> +++ b/fs/vboxsf/super.c
> @@ -21,8 +21,7 @@
>
> #define VBOXSF_SUPER_MAGIC 0x786f4256 /* 'VBox' little endian */
>
> -static const unsigned char VBSF_MOUNT_SIGNATURE[4] = { '\000', '\377', '\376',
> - '\375' };
> +static const unsigned char VBSF_MOUNT_SIGNATURE[4] __nonstring = "\000\377\376\375";
>
> static int follow_symlinks;
> module_param(follow_symlinks, int, 0444);
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] vboxsf: Add __nonstring annotations for unterminated strings
2025-03-10 22:25 [PATCH] vboxsf: Add __nonstring annotations for unterminated strings Kees Cook
2025-03-11 10:09 ` Hans de Goede
@ 2025-03-11 12:07 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2025-03-11 12:07 UTC (permalink / raw)
To: Hans de Goede, Kees Cook
Cc: Christian Brauner, Brahmajit Das, linux-fsdevel, linux-kernel,
linux-hardening
On Mon, 10 Mar 2025 15:25:31 -0700, Kees Cook wrote:
> When a character array without a terminating NUL character has a static
> initializer, GCC 15's -Wunterminated-string-initialization will only
> warn if the array lacks the "nonstring" attribute[1]. Mark the arrays
> with __nonstring to and correctly identify the char array as "not a C
> string" and thereby eliminate the warning.
>
> This effectively reverts the change in 4e7487245abc ("vboxsf: fix building
> with GCC 15"), to add the annotation that has other uses (i.e. warning
> if the string is ever used with C string APIs).
>
> [...]
Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes
[1/1] vboxsf: Add __nonstring annotations for unterminated strings
https://git.kernel.org/vfs/vfs/c/986a6f5eacb9
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-11 12:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-10 22:25 [PATCH] vboxsf: Add __nonstring annotations for unterminated strings Kees Cook
2025-03-11 10:09 ` Hans de Goede
2025-03-11 12:07 ` Christian Brauner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.