Skip to contentSkip to conversation

x86/ldt: correct ldt access in single stepping logic

PATCH In review Juergen Gross 3 participants 3 messages Aug 6, 2015 – Aug 9, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/ldt: correct ldt access in single stepping logic

Commit 37868fe113ff ("x86/ldt: Make modify_ldt synchronous") introduced a new struct ldt_struct anchored at mm->context.ldt.

convert_ip_to_linear() was changed to reflect this, but indexing into the ldt has to be changed as the pointer is no longer void *.

Cc <[email protected]> # 37868fe113ff: x86/ldt: Make modify_ldt synchronous
---
 arch/x86/kernel/step.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/step.c +2 -2
index 6273324..0ccb53a 100644
@@ -28,11 +28,11 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
 		struct desc_struct *desc;
 		unsigned long base;
 
-		seg &= ~7UL;
+		seg >>= 3;
 
 		mutex_lock(&child->mm->context.lock);
 		if (unlikely(!child->mm->context.ldt ||
-			     (seg >> 3) >= child->mm->context.ldt->size))
+			     seg >= child->mm->context.ldt->size))
 			addr = -1L; /* bogus selector, access would fault */
 		else {
 			desc = &child->mm->context.ldt->entries[seg];
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Juergen Gross

Commit 37868fe113ff ("x86/ldt: Make modify_ldt synchronous") introduced a new struct ldt_struct anchored at mm->context.ldt.

convert_ip_to_linear() was changed to reflect this, but indexing into the ldt has to be changed as the pointer is no longer void *.

Good catch.

#2 lore raw

[tip:x86/urgent] x86/ldt: Correct LDT access in single stepping logic

In reply to Juergen Gross
x86/ldt: Correct LDT access in single stepping logic
Commit-ID:  136d9d83c07c5e30ac49fc83b27e8c4842f108fc
Gitweb:     http://git.kernel.org/tip/136d9d83c07c5e30ac49fc83b27e8c4842f108fc
Author:     Juergen Gross <[email protected]>
AuthorDate: Thu, 6 Aug 2015 10:04:38 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 8 Aug 2015 10:20:45 +0200

x86/ldt: Correct LDT access in single stepping logic

Commit 37868fe113ff ("x86/ldt: Make modify_ldt synchronous") introduced a new struct ldt_struct anchored at mm->context.ldt.

convert_ip_to_linear() was changed to reflect this, but indexing into the ldt has to be changed as the pointer is no longer void *.

Cc <[email protected]> # On top of: 37868fe113ff: x86/ldt: Make modify_ldt synchronous
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/kernel/step.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/step.c +2 -2
index 6273324..0ccb53a 100644
@@ -28,11 +28,11 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
 		struct desc_struct *desc;
 		unsigned long base;
 
-		seg &= ~7UL;
+		seg >>= 3;
 
 		mutex_lock(&child->mm->context.lock);
 		if (unlikely(!child->mm->context.ldt ||
-			     (seg >> 3) >= child->mm->context.ldt->size))
+			     seg >= child->mm->context.ldt->size))
 			addr = -1L; /* bogus selector, access would fault */
 		else {
 			desc = &child->mm->context.ldt->entries[seg];