All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/platform/uv: Fix UBSAN array-index-out-of-bounds
@ 2025-07-09 19:26 Kyle Meyer
  2025-08-21 17:55 ` Kyle Meyer
  0 siblings, 1 reply; 2+ messages in thread
From: Kyle Meyer @ 2025-07-09 19:26 UTC (permalink / raw)
  To: steve.wahl, justin.ernst, kyle.meyer, dimitri.sivanich,
	russ.anderson, tglx, mingo, bp, dave.hansen, x86, hpa,
	linux-kernel

When UBSAN is enabled, multiple array-index-out-of-bounds messages are
written to the ring buffer:

[    0.000000] [     T0] UBSAN: array-index-out-of-bounds in arch/x86/kernel/apic/x2apic_uv_x.c:276:23
[    0.000000] [     T0] index 1 is out of range for type '<unknown> [1]'
...
[    0.000000] [     T0] UBSAN: array-index-out-of-bounds in arch/x86/kernel/apic/x2apic_uv_x.c:277:32
[    0.000000] [     T0] index 1 is out of range for type '<unknown> [1]'
...
[    0.000000] [     T0] UBSAN: array-index-out-of-bounds in arch/x86/kernel/apic/x2apic_uv_x.c:282:16
[    0.000000] [     T0] index 1 is out of range for type '<unknown> [1]'
...
[    0.515850] [     T1] UBSAN: array-index-out-of-bounds in arch/x86/kernel/apic/x2apic_uv_x.c:1344:23
[    0.519851] [     T1] index 1 is out of range for type '<unknown> [1]'
...
[    0.603850] [     T1] UBSAN: array-index-out-of-bounds in arch/x86/kernel/apic/x2apic_uv_x.c:1345:32
[    0.607850] [     T1] index 1 is out of range for type '<unknown> [1]'
...
[    0.691850] [     T1] UBSAN: array-index-out-of-bounds in arch/x86/kernel/apic/x2apic_uv_x.c:1353:20
[    0.695850] [     T1] index 1 is out of range for type '<unknown> [1]'

One-element arrays have been deprecated [1]. Switch entry
in struct uv_systab to a flexible array member to fix UBSAN
array-index-out-of-bounds messages.

[1] https://docs.kernel.org/process/deprecated.html#zero-length-and-one-element-arrays

Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
---

sizeof(struct uv_systab) is passed to early_memremap() and ioremap(). The
flexible array member is not referenced until the entire UV system table is
remapped, so this changes to sizeof(struct uv_systab) would have no impact
anyway.

 arch/x86/include/asm/uv/bios.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/uv/bios.h b/arch/x86/include/asm/uv/bios.h
index 6989b824fd32..d0b62e255290 100644
--- a/arch/x86/include/asm/uv/bios.h
+++ b/arch/x86/include/asm/uv/bios.h
@@ -122,7 +122,7 @@ struct uv_systab {
 	struct {
 		u32 type:8;	/* type of entry */
 		u32 offset:24;	/* byte offset from struct start to entry */
-	} entry[1];		/* additional entries follow */
+	} entry[];		/* additional entries follow */
 };
 extern struct uv_systab *uv_systab;
 
-- 
2.50.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/platform/uv: Fix UBSAN array-index-out-of-bounds
  2025-07-09 19:26 [PATCH] x86/platform/uv: Fix UBSAN array-index-out-of-bounds Kyle Meyer
@ 2025-08-21 17:55 ` Kyle Meyer
  0 siblings, 0 replies; 2+ messages in thread
From: Kyle Meyer @ 2025-08-21 17:55 UTC (permalink / raw)
  To: steve.wahl, justin.ernst, dimitri.sivanich, russ.anderson, tglx,
	mingo, bp, dave.hansen, x86, hpa, linux-kernel

On Wed, Jul 09, 2025 at 02:26:41PM -0500, Kyle Meyer wrote:
> When UBSAN is enabled, multiple array-index-out-of-bounds messages are
> written to the ring buffer:
> 
> [    0.000000] [     T0] UBSAN: array-index-out-of-bounds in arch/x86/kernel/apic/x2apic_uv_x.c:276:23
> [    0.000000] [     T0] index 1 is out of range for type '<unknown> [1]'
> ...
> [    0.000000] [     T0] UBSAN: array-index-out-of-bounds in arch/x86/kernel/apic/x2apic_uv_x.c:277:32
> [    0.000000] [     T0] index 1 is out of range for type '<unknown> [1]'
> ...
> [    0.000000] [     T0] UBSAN: array-index-out-of-bounds in arch/x86/kernel/apic/x2apic_uv_x.c:282:16
> [    0.000000] [     T0] index 1 is out of range for type '<unknown> [1]'
> ...
> [    0.515850] [     T1] UBSAN: array-index-out-of-bounds in arch/x86/kernel/apic/x2apic_uv_x.c:1344:23
> [    0.519851] [     T1] index 1 is out of range for type '<unknown> [1]'
> ...
> [    0.603850] [     T1] UBSAN: array-index-out-of-bounds in arch/x86/kernel/apic/x2apic_uv_x.c:1345:32
> [    0.607850] [     T1] index 1 is out of range for type '<unknown> [1]'
> ...
> [    0.691850] [     T1] UBSAN: array-index-out-of-bounds in arch/x86/kernel/apic/x2apic_uv_x.c:1353:20
> [    0.695850] [     T1] index 1 is out of range for type '<unknown> [1]'
> 
> One-element arrays have been deprecated [1]. Switch entry
> in struct uv_systab to a flexible array member to fix UBSAN
> array-index-out-of-bounds messages.
> 
> [1] https://docs.kernel.org/process/deprecated.html#zero-length-and-one-element-arrays
> 
> Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
> ---
> 
> sizeof(struct uv_systab) is passed to early_memremap() and ioremap(). The
> flexible array member is not referenced until the entire UV system table is
> remapped, so this changes to sizeof(struct uv_systab) would have no impact
> anyway.
> 
>  arch/x86/include/asm/uv/bios.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/include/asm/uv/bios.h b/arch/x86/include/asm/uv/bios.h
> index 6989b824fd32..d0b62e255290 100644
> --- a/arch/x86/include/asm/uv/bios.h
> +++ b/arch/x86/include/asm/uv/bios.h
> @@ -122,7 +122,7 @@ struct uv_systab {
>  	struct {
>  		u32 type:8;	/* type of entry */
>  		u32 offset:24;	/* byte offset from struct start to entry */
> -	} entry[1];		/* additional entries follow */
> +	} entry[];		/* additional entries follow */
>  };
>  extern struct uv_systab *uv_systab;
>  
> -- 
> 2.50.0
> 

Just a friendly ping.

Thanks,
Kyle Meyer

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-21 17:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-09 19:26 [PATCH] x86/platform/uv: Fix UBSAN array-index-out-of-bounds Kyle Meyer
2025-08-21 17:55 ` Kyle Meyer

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.