From: Pavel Machek <pavel@denx.de>
To: Sasha Levin <sashal@kernel.org>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Kees Cook <keescook@chromium.org>,
Juergen Gross <jgross@suse.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
xen-devel@lists.xenproject.org, nathan@kernel.org,
ndesaulniers@google.com, llvm@lists.linux.dev
Subject: Re: [PATCH AUTOSEL 4.19 5/6] x86/entry: Work around Clang __bdos() bug
Date: Tue, 11 Oct 2022 13:42:15 +0200 [thread overview]
Message-ID: <20221011114215.GA12851@duo.ucw.cz> (raw)
In-Reply-To: <20221009205443.1203725-5-sashal@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 1837 bytes --]
Hi!
> From: Kees Cook <keescook@chromium.org>
>
> [ Upstream commit 3e1730842f142add55dc658929221521a9ea62b6 ]
>
> 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:
> https://github.com/ClangBuiltLinux/linux/issues/1592
At least in 4.19, there's no UBSAN_BOUNDS. Sounds like we don't need
it in old kernels?
Best regards,
Pavel
> +++ b/arch/x86/xen/enlighten_pv.c
> @@ -752,6 +752,7 @@ static void xen_load_idt(const struct desc_ptr *desc)
> {
> static DEFINE_SPINLOCK(lock);
> static struct trap_info traps[257];
> + static const struct trap_info zero = { };
> unsigned out;
>
> trace_xen_cpu_load_idt(desc);
> @@ -761,7 +762,7 @@ static void xen_load_idt(const struct desc_ptr *desc)
> memcpy(this_cpu_ptr(&idt_desc), desc, sizeof(idt_desc));
>
> out = xen_convert_trap_info(desc, traps, false);
> - memset(&traps[out], 0, sizeof(traps[0]));
> + traps[out] = zero;
>
> xen_mc_flush();
> if (HYPERVISOR_set_trap_table(traps))
> --
> 2.35.1
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2022-10-11 11:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-09 20:54 [PATCH AUTOSEL 4.19 1/6] ACPI: video: Add Toshiba Satellite/Portege Z830 quirk Sasha Levin
2022-10-09 20:54 ` [PATCH AUTOSEL 4.19 2/6] MIPS: BCM47XX: Cast memcmp() of function to (void *) Sasha Levin
2022-10-09 20:54 ` [PATCH AUTOSEL 4.19 3/6] powercap: intel_rapl: fix UBSAN shift-out-of-bounds issue Sasha Levin
2022-10-09 20:54 ` [PATCH AUTOSEL 4.19 4/6] thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash Sasha Levin
2022-10-09 20:54 ` [PATCH AUTOSEL 4.19 5/6] x86/entry: Work around Clang __bdos() bug Sasha Levin
2022-10-11 11:42 ` Pavel Machek [this message]
2022-10-09 20:54 ` [PATCH AUTOSEL 4.19 6/6] NFSD: Return nfserr_serverfault if splice_ok but buf->pages have data Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221011114215.GA12851@duo.ucw.cz \
--to=pavel@denx.de \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mingo@redhat.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®