Skip to content

Commit 3e17308

Browse files
committed
x86/entry: Work around Clang __bdos() bug
Clang produces a false positive when building with CONFIG_FORTIFY_SOURCE=y and CONFIG_UBSAN_BOUNDS=y when operating on an array with a dynamic offset. Work around this by using a direct assignment of an empty instance. Avoids this warning: ../include/linux/fortify-string.h:309:4: warning: call to __write_overflow_field declared with 'warn ing' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wat tribute-warning] __write_overflow_field(p_size_field, size); ^ which was isolated to the memset() call in xen_load_idt(). Note that this looks very much like another bug that was worked around: ClangBuiltLinux#1592 Cc: Juergen Gross <[email protected]> Cc: Boris Ostrovsky <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: [email protected] Cc: "H. Peter Anvin" <[email protected]> Cc: [email protected] Reviewed-by: Boris Ostrovsky <[email protected]> Link: https://lore.kernel.org/lkml/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 1b64daf commit 3e17308

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/xen/enlighten_pv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,7 @@ static void xen_load_idt(const struct desc_ptr *desc)
765765
{
766766
static DEFINE_SPINLOCK(lock);
767767
static struct trap_info traps[257];
768+
static const struct trap_info zero = { };
768769
unsigned out;
769770

770771
trace_xen_cpu_load_idt(desc);
@@ -774,7 +775,7 @@ static void xen_load_idt(const struct desc_ptr *desc)
774775
memcpy(this_cpu_ptr(&idt_desc), desc, sizeof(idt_desc));
775776

776777
out = xen_convert_trap_info(desc, traps, false);
777-
memset(&traps[out], 0, sizeof(traps[0]));
778+
traps[out] = zero;
778779

779780
xen_mc_flush();
780781
if (HYPERVISOR_set_trap_table(traps))

0 commit comments

Comments
 (0)