]> git.baikalelectronics.ru Git - kernel.git/commit
x86/ptrace: Prevent ptrace from clearing the FS/GS selector
authorChang S. Bae <chang.seok.bae@intel.com>
Sun, 16 Jun 2019 15:44:11 +0000 (15:44 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Sat, 22 Jun 2019 09:38:50 +0000 (11:38 +0200)
commit22b8cc999080ec4fafe0c4b64ad6311c7ea8630a
tree89ca5b55d3fb55517789e8d8bdec80727ee0e9fa
parent14244a27783389bc1fb4f58e24655aa3dd6faa79
x86/ptrace: Prevent ptrace from clearing the FS/GS selector

When a ptracer writes a ptracee's FS/GSBASE with a different value, the
selector is also cleared. This behavior is not correct as the selector
should be preserved.

Update only the base value and leave the selector intact. To simplify the
code further remove the conditional checking for the same value as this
code is not performance critical.

The only recognizable downside of this change is when the selector is
already nonzero on write. The base will be reloaded according to the
selector. But the case is highly unexpected in real usages.

[ tglx: Massage changelog ]

Suggested-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: "H . Peter Anvin" <hpa@zytor.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Link: https://lkml.kernel.org/r/9040CFCD-74BD-4C17-9A01-B9B713CF6B10@intel.com
arch/x86/kernel/ptrace.c