[<prev] [next>] [day] [month] [year] [list]
Message-ID: <c4L1q6uye90TLiBKe-p6Y7JDbmIdFz5c11Ys5bC8q81J03L-pkXax2Mm43NuMML2WA4eXhOUFeA48YKF7mLg_TfEccxt5hEoKTxmRrg7Zas=@protonmail.com>
Date: Sun, 29 Jun 2025 12:51:11 +0000
From: andreasx0 <andreasx0@...tonmail.com>
To: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH] x86/dmi: Fix misaligned dmi_alloc use on dmi_scan.c by using struct alignment On x86, dmi_alloc() uses extend_brk() with only 4-byte alignment, which can cause UBSAN warnings when accessing struct dmi_device, whose members require 8-byte alignment. Fix this by aligning allocations to the maximum of sizeof(int) and __alignof__(struct dmi_device).
>From b31d085855f6ff0db5f465ed936cbce1b69d366c Mon Sep 17 00:00:00 2001From: Andrew <andreasx0@...tonmail.com>
Date: Sun, 29 Jun 2025 15:33:26 +0300
Subject: [PATCH] x86/dmi: Fix misaligned dmi_alloc use on dmi_scan.c by using struct alignment
On x86, dmi_alloc() uses extend_brk() with only 4-byte alignment,
which can cause UBSAN warnings when accessing struct dmi_device,
whose members require 8-byte alignment.
Fix this by aligning allocations to the maximum of sizeof(int) and
__alignof__(struct dmi_device).
Signed-off-by: Andrew <andreasx0@...tonmail.com>
---
arch/x86/include/asm/dmi.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/dmi.h b/arch/x86/include/asm/dmi.h
index b825cb201251..2d6c3bea718c 100644
--- a/arch/x86/include/asm/dmi.h
+++ b/arch/x86/include/asm/dmi.h
@@ -10,7 +10,7 @@
static __always_inline __init void *dmi_alloc(unsigned len)
{
- return extend_brk(len, sizeof(int));
+ return extend_brk(len, max_t(size_t, sizeof(int), __alignof__(struct dmi_device)));
}
/* Use early IO mappings for DMI because it's initialized early */
--
2.50.0
/* SPDX-License-Identifier: GPL-2.0 */#ifndef _ASM_X86_DMI_H
#define _ASM_X86_DMI_H
#include <linux/compiler.h>
#include <linux/init.h>
#include <linux/io.h>
#include <asm/setup.h>
static __always_inline __init void *dmi_alloc(unsigned len)
{
return extend_brk(len, max_t(size_t, sizeof(int), __alignof__(struct dmi_device)));
}
/* Use early IO mappings for DMI because it's initialized early */
#define dmi_early_remap early_memremap
#define dmi_early_unmap early_memunmap
#define dmi_remap(_x, _l) memremap(_x, _l, MEMREMAP_WB)
#define dmi_unmap(_x) memunmap(_x)
#endif /* _ASM_X86_DMI_H */
Content of type "text/html" skipped
Download attachment "publickey - andreasx0@...tonmail.com - 0xF61BB148.asc" of type "application/pgp-keys" (661 bytes)
Download attachment "signature.asc" of type "application/pgp-signature" (344 bytes)
Powered by blists - more mailing lists