Skip to content

Commit 6ccdc91

Browse files
committed
x86: mm: remove architecture-specific 'access_ok()' define
There's already a generic definition of 'access_ok()' in the asm-generic/access_ok.h header file, and the only difference bwteen that and the x86-specific one is the added check for WARN_ON_IN_IRQ(). And it turns out that the reason for that check is long gone: it used to use a "user_addr_max()" inline function that depended on the current thread, and caused problems in non-thread contexts. For details, see commits 7c47889 ("x86/uaccess, sched/preempt: Verify access_ok() context") and in particular commit ae31fe5 ("perf/x86: Restore TASK_SIZE check on frame pointer") about how and why this came to be. But that "current task" issue was removed in the big set_fs() removal by Christoph Hellwig in commit 47058bb ("x86: remove address space overrides using set_fs()"). So the reason for the test and the architecture-specific access_ok() define no longer exists, and is actually harmful these days. For example, it led various 'copy_from_user_nmi()' games (eg using __range_not_ok() instead, and then later converted to __access_ok() when that became ok). And that in turn meant that LAM was broken for the frame following before this series, because __access_ok() used to not do the address untagging. Accessing user state still needs care in many contexts, but access_ok() is not the place for this test. Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Linus Torvalds torvalds@linux-foundation.org>
1 parent 6014bc2 commit 6ccdc91

1 file changed

Lines changed: 0 additions & 34 deletions

File tree

arch/x86/include/asm/uaccess.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616
#include <asm/extable.h>
1717
#include <asm/tlbflush.h>
1818

19-
#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
20-
static inline bool pagefault_disabled(void);
21-
# define WARN_ON_IN_IRQ() \
22-
WARN_ON_ONCE(!in_task() && !pagefault_disabled())
23-
#else
24-
# define WARN_ON_IN_IRQ()
25-
#endif
26-
2719
#ifdef CONFIG_ADDRESS_MASKING
2820
/*
2921
* Mask out tag bits from the address.
@@ -103,32 +95,6 @@ static inline bool __access_ok(const void __user *ptr, unsigned long size)
10395
#define __access_ok __access_ok
10496
#endif
10597

106-
/**
107-
* access_ok - Checks if a user space pointer is valid
108-
* @addr: User space pointer to start of block to check
109-
* @size: Size of block to check
110-
*
111-
* Context: User context only. This function may sleep if pagefaults are
112-
* enabled.
113-
*
114-
* Checks if a pointer to a block of memory in user space is valid.
115-
*
116-
* Note that, depending on architecture, this function probably just
117-
* checks that the pointer is in the user space range - after calling
118-
* this function, memory access functions may still return -EFAULT.
119-
*
120-
* Return: true (nonzero) if the memory block may be valid, false (zero)
121-
* if it is definitely invalid.
122-
*
123-
* This should not be x86-specific. The only odd things out here is
124-
* the WARN_ON_IN_IRQ(), which doesn't exist in the generic version.
125-
*/
126-
#define access_ok(addr, size) \
127-
({ \
128-
WARN_ON_IN_IRQ(); \
129-
likely(__access_ok(addr, size)); \
130-
})
131-
13298
#include <asm-generic/access_ok.h>
13399

134100
extern int __get_user_1(void);

0 commit comments

Comments
 (0)