From: "Paul E. McKenney" <paulmck@kernel.org>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
Joel Fernandes <joelagnelf@nvidia.com>,
Josh Triplett <josh@joshtriplett.org>,
Boqun Feng <boqun@kernel.org>,
Uladzislau Rezki <urezki@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang@linux.dev>, Thomas Gleixner <tglx@kernel.org>,
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>,
Chris Li <sparse@chrisli.org>, Dan Carpenter <error27@gmail.com>,
David Laight <david.laight.linux@gmail.com>,
rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-sparse@vger.kernel.org
Subject: Re: [PATCH v2 2/2] x86/uaccess: Drop the address space qualifier from put_user()
Date: Mon, 14 Sep 2026 07:58:23 -0700 [thread overview]
Message-ID: <a8390eb2-9cea-45cd-add0-b30c8d8e942d@paulmck-laptop> (raw)
In-Reply-To: <20260914-unqual-v2-2-60a1407a0cd4@chromium.org>
On Mon, Sep 14, 2026 at 01:53:32PM +0000, Ricardo Ribalda wrote:
> __typeof__() preserves every qualifier, the address space included.
>
> When we do __typeof(*__user *int), we are declaring a __user integer,
> which is pretty much meaningless. A value in a register or in the stack
> does not live in the user address space.
>
> This annotation did not trigger any error until a recent version of
> smatch[1] started caring. And as a result of that now we have tens of
> warnings like:
>
> drivers/media/usb/uvc/uvc_v4l2.c:1112:13: warning: incorrect type in argument 2 (different address spaces)
> drivers/media/usb/uvc/uvc_v4l2.c:1112:13: expected void const *from
> drivers/media/usb/uvc/uvc_v4l2.c:1112:13: got unsigned int __user *
>
> Instead of __typeof__() use TYPEOF_UNQUAL(). It maps to
> __typeof_unqual__() in recent compilers, so the address space annotation
> is gone.
>
> [1] https://github.com/error27/smatch/commit/e53027a4e816a772403baafa83c09e4a94c1cb8f
>
> Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
> Link: https://lore.kernel.org/r/20260825-unqual-v1-2-7024fb81b4f9@chromium.org
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Queued for testing and review, thank you both!
Thanx, Paul
> ---
> arch/x86/include/asm/uaccess.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
> index 3a0dd3c2b233..4e576c0b9131 100644
> --- a/arch/x86/include/asm/uaccess.h
> +++ b/arch/x86/include/asm/uaccess.h
> @@ -172,7 +172,7 @@ extern void __put_user_nocheck_8(void);
> int __ret_pu; \
> void __user *__ptr_pu; \
> register __typeof__(*(ptr)) __val_pu asm("%"_ASM_AX); \
> - __typeof__(*(ptr)) __x = (x); /* eval x once */ \
> + TYPEOF_UNQUAL(*(ptr)) __x = (x); /* eval x once */ \
> __typeof__(ptr) __ptr = (ptr); /* eval ptr once */ \
> __chk_user_ptr(__ptr); \
> __ptr_pu = __ptr; \
> @@ -231,7 +231,7 @@ extern void __put_user_nocheck_8(void);
>
> #define __put_user_size(x, ptr, size, label) \
> do { \
> - __typeof__(*(ptr)) __x = (x); /* eval x once */ \
> + TYPEOF_UNQUAL(*(ptr)) __x = (x); /* eval x once */ \
> __typeof__(ptr) __ptr = (ptr); /* eval ptr once */ \
> __chk_user_ptr(__ptr); \
> switch (size) { \
>
> --
> 2.55.0.1007.g17ff1f9808-goog
>
next prev parent reply other threads:[~2026-09-14 14:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 13:53 [PATCH v2 0/2] Fix warnings with recent smatch Ricardo Ribalda
2026-09-14 13:53 ` [PATCH v2 1/2] rcu: Drop the address space qualifier from the dereference macros Ricardo Ribalda
2026-09-14 13:53 ` [PATCH v2 2/2] x86/uaccess: Drop the address space qualifier from put_user() Ricardo Ribalda
2026-09-14 14:58 ` Paul E. McKenney [this message]
2026-09-14 15:13 ` Paul E. McKenney
2026-09-23 11:08 ` Ricardo Ribalda
2026-09-23 15:22 ` David Laight
2026-09-24 7:19 ` Ricardo Ribalda
2026-09-24 8:10 ` David Laight
2026-09-24 8:14 ` Ricardo Ribalda
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=a8390eb2-9cea-45cd-add0-b30c8d8e942d@paulmck-laptop \
--to=paulmck@kernel.org \
--cc=boqun@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=david.laight.linux@gmail.com \
--cc=error27@gmail.com \
--cc=frederic@kernel.org \
--cc=hpa@zytor.com \
--cc=jiangshanlai@gmail.com \
--cc=joelagnelf@nvidia.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@redhat.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=qiang.zhang@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=ribalda@chromium.org \
--cc=rostedt@goodmis.org \
--cc=sparse@chrisli.org \
--cc=tglx@kernel.org \
--cc=urezki@gmail.com \
--cc=x86@kernel.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®