aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@kernel.org>2016-05-10 12:18:46 -0400
committerIngo Molnar <mingo@kernel.org>2016-05-20 03:10:03 -0400
commitd696ca016d579d43fc043f28ba656d9305fba651 (patch)
tree8ad4ce52e4aaa359b08784126b66f6ea2190b834
parent06cd3d8c14bdd06f49f1c6a06acf219749c5598e (diff)
x86/fsgsbase/64: Use TASK_SIZE_MAX for FSBASE/GSBASE upper limits
The GSBASE upper limit exists to prevent user code from confusing the paranoid idtentry path. The FSBASE upper limit is just for consistency. There's no need to enforce a smaller limit for 32-bit tasks. Just use TASK_SIZE_MAX. This simplifies the logic and will save a few bytes of code. Signed-off-by: Andy Lutomirski <luto@kernel.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/5357f2fe0f103eabf005773b70722451eab09a89.1462897104.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/kernel/process_64.c4
-rw-r--r--arch/x86/kernel/ptrace.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 6b16c36f0939..6e789ca1f841 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -532,7 +532,7 @@ long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
532 532
533 switch (code) { 533 switch (code) {
534 case ARCH_SET_GS: 534 case ARCH_SET_GS:
535 if (addr >= TASK_SIZE_OF(task)) 535 if (addr >= TASK_SIZE_MAX)
536 return -EPERM; 536 return -EPERM;
537 cpu = get_cpu(); 537 cpu = get_cpu();
538 task->thread.gsindex = 0; 538 task->thread.gsindex = 0;
@@ -546,7 +546,7 @@ long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
546 case ARCH_SET_FS: 546 case ARCH_SET_FS:
547 /* Not strictly needed for fs, but do it for symmetry 547 /* Not strictly needed for fs, but do it for symmetry
548 with gs */ 548 with gs */
549 if (addr >= TASK_SIZE_OF(task)) 549 if (addr >= TASK_SIZE_MAX)
550 return -EPERM; 550 return -EPERM;
551 cpu = get_cpu(); 551 cpu = get_cpu();
552 task->thread.fsindex = 0; 552 task->thread.fsindex = 0;
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index e60ef918f53d..600edd225e81 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -392,7 +392,7 @@ static int putreg(struct task_struct *child,
392 392
393#ifdef CONFIG_X86_64 393#ifdef CONFIG_X86_64
394 case offsetof(struct user_regs_struct,fs_base): 394 case offsetof(struct user_regs_struct,fs_base):
395 if (value >= TASK_SIZE_OF(child)) 395 if (value >= TASK_SIZE_MAX)
396 return -EIO; 396 return -EIO;
397 /* 397 /*
398 * When changing the segment base, use do_arch_prctl 398 * When changing the segment base, use do_arch_prctl
@@ -406,7 +406,7 @@ static int putreg(struct task_struct *child,
406 /* 406 /*
407 * Exactly the same here as the %fs handling above. 407 * Exactly the same here as the %fs handling above.
408 */ 408 */
409 if (value >= TASK_SIZE_OF(child)) 409 if (value >= TASK_SIZE_MAX)
410 return -EIO; 410 return -EIO;
411 if (child->thread.gsbase != value) 411 if (child->thread.gsbase != value)
412 return do_arch_prctl(child, ARCH_SET_GS, value); 412 return do_arch_prctl(child, ARCH_SET_GS, value);