From: Greg Ungerer <gerg@linux-m68k.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-m68k <linux-m68k@lists.linux-m68k.org>
Subject: Re: Build regressions/improvements in v5.5-rc2
Date: Tue, 17 Dec 2019 10:56:39 +1000 [thread overview]
Message-ID: <cfc86b96-9d28-eebc-c7f7-1ed9a1e28458@linux-m68k.org> (raw)
In-Reply-To: <CAMuHMdUaRdyRigwS+fdju1_PQCahONVFPKu0DbX6hhb7=JXmLA@mail.gmail.com>
Hi Geert,
On 16/12/19 6:49 pm, Geert Uytterhoeven wrote:
> Hi Greg,
>
> On Mon, Dec 16, 2019 at 9:38 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>> Below is the list of build error/warning regressions/improvements in
>> v5.5-rc2[1] compared to v5.4[2].
>
>> [1] http://kisskb.ellerman.id.au/kisskb/branch/linus/head/d1eef1c619749b2a57e514a3fa67d9a516ffa919/ (all 232 configs)
>> [2] http://kisskb.ellerman.id.au/kisskb/branch/linus/head/219d54332a09e8d8741c1e1982f5eae56099de85/ (all 232 configs)
>
>> + /kisskb/src/arch/m68k/include/asm/string.h: warning: '__builtin_memcpy' forming offset [3, 4] is out of the bounds [0, 2] of object '__gu_val' with type 'short unsigned int' [-Warray-bounds]: => 72:25
>
> The upgrade from gcc 4.6.3 to 81.0 seems to have revealed a potential
> issue in get_user() in arch/m68k/include/asm/uaccess_no.h.
>
> #define get_user(x, ptr) \
> ({ \
> int __gu_err = 0; \
> typeof(x) __gu_val = 0; \
> ^^^^^^^^^
> This is the type of the destination
>
> switch (sizeof(*(ptr))) { \
> case 1: \
> __get_user_asm(__gu_err, __gu_val, ptr, b, "=d"); \
> break; \
> case 2: \
> __get_user_asm(__gu_err, __gu_val, ptr, w, "=r"); \
> break; \
> case 4: \
> __get_user_asm(__gu_err, __gu_val, ptr, l, "=r"); \
> break; \
> case 8: \
> memcpy((void *) &__gu_val, ptr, sizeof (*(ptr))); \
> break; \
> default: \
> __gu_val = 0; \
> __gu_err = __get_user_bad(); \
> break; \
> } \
> (x) = (typeof(*(ptr))) __gu_val; \
> __gu_err; \
> })
>
> ext2_ioctl() calls this like
>
> unsigned short rsv_window_size;
> if (get_user(rsv_window_size, (int __user *)arg)) { ... }
>
> So a 32-bit value is being copied to an unsigned short value, leading
> to the warning (for the memcpy() in the non-taken "case 8" branch).
>
> Fortunately the compiler emits a register move for this, so no real harm
> is done:
>
> | fs/ext2/ioctl.c:123: if (get_user(rsv_window_size,
> (int __user *)arg))
> move.l 48(%sp),%a0 | arg,
> #APP
> | 123 "fs/ext2/ioctl.c" 1
> movel (%a0),%d2 | *arg.32_43, __gu_val
>
> The corresponding code in arch/m68k/include/asm/uaccess_mm.h
> uses a temporary __gu_val of the right sized type based on the source
> type to avoid this.
Yeah, your right. I will put a change together to fix.
Regards
Greg
prev parent reply other threads:[~2019-12-17 0:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-16 8:36 Geert Uytterhoeven
2019-12-16 8:49 ` Geert Uytterhoeven
2019-12-17 0:56 ` Greg Ungerer [this message]
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=cfc86b96-9d28-eebc-c7f7-1ed9a1e28458@linux-m68k.org \
--to=gerg@linux-m68k.org \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.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®