lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=whiL-ieTm19zuPqC9HLHh_-L_3pSMRUwsaN4Czp0PW6iA@mail.gmail.com>
Date: Fri, 18 Jul 2025 15:58:19 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: "H. Peter Anvin" <hpa@...or.com>
Cc: Eugenio Pérez <eperezma@...hat.com>, 
	Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>, 
	"Michael S. Tsirkin" <mst@...hat.com>, Al Viro <viro@...iv.linux.org.uk>, 
	Alexei Starovoitov <ast@...nel.org>, Alexey Dobriyan <adobriyan@...il.com>, 
	Andrew Morton <akpm@...ux-foundation.org>, Andrii Nakryiko <andrii@...nel.org>, 
	Arnd Bergmann <arnd@...nel.org>, Borislav Petkov <bp@...en8.de>, Cong Wang <cong.wang@...edance.com>, 
	Dan Williams <dan.j.williams@...el.com>, Daniel Borkmann <daniel@...earbox.net>, 
	Dave Hansen <dave.hansen@...ux.intel.com>, David Laight <David.Laight@...lab.com>, 
	David Lechner <dlechner@...libre.com>, Dinh Nguyen <dinguyen@...nel.org>, 
	Eduard Zingerman <eddyz87@...il.com>, Gatlin Newhouse <gatlin.newhouse@...il.com>, 
	Hao Luo <haoluo@...gle.com>, Ingo Molnar <mingo@...hat.com>, 
	Jakub Sitnicki <jakub@...udflare.com>, Jan Hendrik Farr <kernel@...rr.cc>, Jason Wang <jasowang@...hat.com>, 
	Jiri Olsa <jolsa@...nel.org>, John Fastabend <john.fastabend@...il.com>, 
	Jonathan Cameron <Jonathan.Cameron@...wei.com>, Josh Poimboeuf <jpoimboe@...nel.org>, 
	KP Singh <kpsingh@...nel.org>, Kees Cook <kees@...nel.org>, 
	Luc Van Oostenryck <luc.vanoostenryck@...il.com>, Marc Herbert <Marc.Herbert@...ux.intel.com>, 
	Martin KaFai Lau <martin.lau@...ux.dev>, Mateusz Guzik <mjguzik@...il.com>, Michal Luczaj <mhal@...x.co>, 
	Miguel Ojeda <ojeda@...nel.org>, Mykola Lysenko <mykolal@...com>, NeilBrown <neil@...wn.name>, 
	Peter Zijlstra <peterz@...radead.org>, Przemek Kitszel <przemyslaw.kitszel@...el.com>, 
	Sami Tolvanen <samitolvanen@...gle.com>, Shuah Khan <shuah@...nel.org>, Song Liu <song@...nel.org>, 
	Stanislav Fomichev <sdf@...ichev.me>, Thomas Gleixner <tglx@...utronix.de>, 
	Thorsten Blum <thorsten.blum@...ux.dev>, Uros Bizjak <ubizjak@...il.com>, 
	Xuan Zhuo <xuanzhuo@...ux.alibaba.com>, Yafang Shao <laoar.shao@...il.com>, 
	Ye Bin <yebin10@...wei.com>, Yonghong Song <yonghong.song@...ux.dev>, 
	Yufeng Wang <wangyufeng@...inos.cn>, bpf@...r.kernel.org, linux-fsdevel@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org, 
	linux-sparse@...r.kernel.org, virtualization@...ts.linux.dev, x86@...nel.org
Subject: Re: [PATCH 4/7] arch/nios: replace "__auto_type" with "auto"

On Fri, 18 Jul 2025 at 15:48, Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> And while looking at this, I think we have a similar mis-feature / bug
> on x86 too: the unsafe_put_user() macro does exactly that cast:
>
>   #define unsafe_put_user(x, ptr, label)  \
>         __put_user_size((__typeof__(*(ptr)))(x), ..
>
> and I think that cast is wrong.
>
> I wonder if it's actively hiding some issue with unsafe_put_user(), or
> if I'm just missing something.

... and I decided to try to look into it by just removing the cast.

And yes indeed, there's a reason for the cast - or at least it's
hiding problems:

arch/x86/kernel/signal_64.c:128:
        unsafe_put_user(fpstate, (unsigned long __user *)&sc->fpstate, Efault);

arch/x86/kernel/signal_64.c:188:
        unsafe_put_user(ksig->ka.sa.sa_restorer, &frame->pretcode, Efault);

arch/x86/kernel/signal_64.c:332:
        unsafe_put_user(restorer, (unsigned long __user
*)&frame->pretcode, Efault);

The one on line 188 at least makes some sense. The other ones are
literally hiding the fact that we explicitly cast things to the wrong
pointer.

I suspect it's just very old historical "we have been lazy and mixing
'unsigned long' and 'pointer value'" issues.

Oh well. None of these are actual *bugs*, they are more just ugly. And
the cast that is hiding this ugliness might be hiding other things.

Not worth the churn at least late in the release cycle, but one of
those "this might be worth cleaning up some day" issues.

              Linus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ