* [PATCH] parisc: uaccess: Avoid double evaluation of ptr in __get_user()
@ 2026-12-02 18:01 John David Anglin
0 siblings, 0 replies; only message in thread
From: John David Anglin @ 2026-12-02 18:01 UTC (permalink / raw)
To: Helge Deller, James E.J. Bottomley; +Cc: linux-parisc
[-- 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 --]
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-02 18:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 18:01 [PATCH] parisc: uaccess: Avoid double evaluation of ptr in __get_user() John David Anglin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox