Linux PARISC architecture development
 help / color / mirror / Atom feed
From: John David Anglin <dave.anglin@bell.net>
To: Helge Deller <deller@gmx.de>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>
Cc: linux-parisc@vger.kernel.org
Subject: [PATCH] parisc: uaccess: Avoid double evaluation of ptr in __get_user()
Date: Wed, 2 Dec 2026 13:01:41 -0500	[thread overview]
Message-ID: <axBc-vYxkagk890Y@mx3210.local> (raw)

[-- Attachment #1: Type: text/plain, Size: 2032 bytes --]

parisc: uaccess: Avoid double evaluation of ptr in __get_user()

In __get_user(val, ptr), the pointer argument `ptr` is passed directly to
both __get_user_internal() and __probe_user_internal(). When callers pass
an expression with side effects (such as a post-increment), `ptr` is
evaluated twice: once during the load and a second time during the
subsequent `proberi` check.

This causes callers such as compat_get_bitmap()—which invokes
`unsafe_get_user(l1, umask++, Efault)` inside its loop when copying
bitmaps larger than 32 bits—to advance the source pointer by two words
per read and skip every other word. On 64-bit parisc kernels running a
32-bit userspace, this breaks select()/pselect6() whenever any monitored
file descriptor is >= 32, causing pselect6() to poll an empty fd_set and
hang until timeout (manifesting as cascading DejaGnu timeouts in the GCC
testsuite when Expect spawn_ids are not immediately closed).

Additionally, probing the incremented pointer can spuriously fail with
-EFAULT if the original read occurred at the end of a mapped page.

Cache `ptr` in a local `__ptr` variable in __get_user(), matching how
__put_user() is already implemented.

Fixes: 89f686a0fb6e ("parisc: Revise __get_user() to probe user read access")
Cc: stable@vger.kernel.org # v5.12+
Signed-off-by: John David Anglin <dave.anglin@bell.net>
---

diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
index 6c531d2c847e..0c823f70a546 100644
--- a/arch/parisc/include/asm/uaccess.h
+++ b/arch/parisc/include/asm/uaccess.h
@@ -55,10 +55,11 @@
 #define __get_user(val, ptr)					\
 ({								\
 	register long __gu_err;					\
+	__typeof__(&*(ptr)) __ptr = (ptr);			\
 								\
-	__gu_err = __get_user_internal(SR_USER, val, ptr);	\
+	__gu_err = __get_user_internal(SR_USER, val, __ptr);	\
 	if (likely(!__gu_err))					\
-		__probe_user_internal(SR_USER, __gu_err, ptr);	\
+		__probe_user_internal(SR_USER, __gu_err, __ptr);\
 	__gu_err;						\
 })
 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

                 reply	other threads:[~2026-12-02 18:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=axBc-vYxkagk890Y@mx3210.local \
    --to=dave.anglin@bell.net \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=deller@gmx.de \
    --cc=linux-parisc@vger.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