[patch V2 1/6] ARM: uaccess: Implement missing __get_user_asm_dword()
Russell King (Oracle)
linux at armlinux.org.uk
Wed Sep 17 08:17:38 PDT 2025
On Wed, Sep 17, 2025 at 03:55:10PM +0200, Thomas Gleixner wrote:
> On Wed, Sep 17 2025 at 10:41, Russell King wrote:
> > On Wed, Sep 17, 2025 at 07:48:00AM +0200, Thomas Gleixner wrote:
> >
> > Putting together a simple test case, where the only change is making
> > __gu_val an unsigned long long:
> >
> > t.c: In function ‘get_ptr’:
> > t.c:40:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> > 40 | (x) = (__typeof__(*(ptr)))__gu_val; \
> > | ^
> > t.c:21:9: note: in expansion of macro ‘__get_user_err’
> > 21 | __get_user_err((x), (ptr), __gu_err, TUSER()); \
> > | ^~~~~~~~~~~~~~
> > t.c:102:16: note: in expansion of macro ‘__get_user’
> > 102 | return __get_user(p, ptr);
> > | ^~~~~~~~~~
> >
> > In order for the code you are modifying to be reachable, you need to
> > build with CONFIG_CPU_SPECTRE disabled. This is produced by:
> >
> > int get_ptr(void **ptr)
> > {
> > void *p;
> >
> > return __get_user(p, ptr);
> > }
>
> Duh, yes. I hate get_user() and I did not notice, because the
> allmodconfig build breaks early due to frame size checks, so I was too
> lazy to find that config knob and built only a couple of things and an
> artificial test case for u64.
>
> But it actually can be solved solvable by switching the casting to:
>
> (x) = *(__force __typeof__(*(ptr)) *) &__gu_val;
>
> Not pretty, but after upping the frame size limit it builds an
> allmodconfig kernel.
For me, this produces:
get-user-test.c:41:16: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
41 | (x) = *(__force __typeof__(*(ptr)) *) &__gu_val; \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
with arm-linux-gnueabihf-gcc (Debian 14.2.0-19) 14.2.0
Maybe you're using a different compiler that doesn't issue that warning?
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
More information about the linux-arm-kernel
mailing list