Skip to content

Commit 573f45a

Browse files
david-laighttorvalds
authored andcommitted
x86: fix off-by-one in access_ok()
When the size isn't a small constant, __access_ok() will call valid_user_address() with the address after the last byte of the user buffer. It is valid for a buffer to end with the last valid user address so valid_user_address() must allow accesses to the base of the guard page. [ This introduces an off-by-one in the other direction for the plain non-sized accesses, but since we have that guard region that is a whole page, those checks "allowing" accesses to that guard region don't really matter. The access will fault anyway, whether to the guard page or if the address has been masked to all ones - Linus ] Fixes: 86e6b15 ("x86: fix user address masking non-canonical speculation issue") Signed-off-by: David Laight <david.laight@aculab.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 43a43fa commit 573f45a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/kernel/cpu/common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,12 +2389,12 @@ void __init arch_cpu_finalize_init(void)
23892389
alternative_instructions();
23902390

23912391
if (IS_ENABLED(CONFIG_X86_64)) {
2392-
unsigned long USER_PTR_MAX = TASK_SIZE_MAX-1;
2392+
unsigned long USER_PTR_MAX = TASK_SIZE_MAX;
23932393

23942394
/*
23952395
* Enable this when LAM is gated on LASS support
23962396
if (cpu_feature_enabled(X86_FEATURE_LAM))
2397-
USER_PTR_MAX = (1ul << 63) - PAGE_SIZE - 1;
2397+
USER_PTR_MAX = (1ul << 63) - PAGE_SIZE;
23982398
*/
23992399
runtime_const_init(ptr, USER_PTR_MAX);
24002400

0 commit comments

Comments
 (0)