Skip to contentSkip to conversation

x86/ldt: Initialize the context lock for init_mm

PATCH In review Sebastian Andrzej Siewior 3 participants 4 messages Jul 1, 2019 – Jul 9, 2019 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/ldt: Initialize the context lock for init_mm

The mutex mm->context->lock for init_mm is not initialized for init_mm. This wasn't a problem because it remained unused. This changed however since commit
4fc19708b165c ("x86/alternatives: Initialize temporary mm for patching")

Initialize the mutex for init_mm.

Fixes 4fc19708b165c ("x86/alternatives: Initialize temporary mm for patching")

---

The rwsem `ldt_usr_sem' is also not initialized for init_mm. No idea if we want this.

 arch/x86/include/asm/mmu.h | 1 +
 1 file changed, 1 insertion(+)
arch/x86/include/asm/mmu.h +1 -0
index 5ff3e8af2c205..e78c7db878018 100644
@@ -59,6 +59,7 @@ typedef struct {
 #define INIT_MM_CONTEXT(mm)						\
 	.context = {							\
 		.ctx_id = 1,						\
+		.lock = __MUTEX_INITIALIZER(mm.context.lock),		\
 	}
 
 void leave_mm(int cpu);
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Sebastian Andrzej Siewior

The mutex mm->context->lock for init_mm is not initialized for init_mm. This wasn't a problem because it remained unused. This changed however since commit
4fc19708b165c ("x86/alternatives: Initialize temporary mm for patching")

Quoted 8 lines

Initialize the mutex for init_mm.

Fixes 4fc19708b165c ("x86/alternatives: Initialize temporary mm for patching")

---

The rwsem `ldt_usr_sem' is also not initialized for init_mm. No idea if we want this.

I cannot see why not (but it would need to depend on CONFIG_MODIFY_LDT_SYSCALL)

arch/x86/include/asm/mmu.h typedef struct { · line 62

Quoted 13 lines

arch/x86/include/asm/mmu.h | 1 +

1 file changed, 1 insertion(+)
arch/x86/include/asm/mmu.h +1 -0
index 5ff3e8af2c205..e78c7db878018 100644
@@ -59,6 +59,7 @@ typedef struct {
 #define INIT_MM_CONTEXT(mm)						\
 	.context = {							\
 		.ctx_id = 1,						\
+		.lock = __MUTEX_INITIALIZER(mm.context.lock),		\

Sorry for my mistake. Thanks for fixing it up. I find it useful to know how the problem was found or what the impact was - helps me sometimes to avoid causing similar bugs in the future.

#2 lore raw
In reply to Sebastian Andrzej Siewior
x86/ldt: Initialize the context lock for init_mm
Commit-ID:  32232b350d7cd93cdc65fe5a453e6a40b539e9f9
Gitweb:     https://git.kernel.org/tip/32232b350d7cd93cdc65fe5a453e6a40b539e9f9
Author:     Sebastian Andrzej Siewior <[email protected]>
AuthorDate: Mon, 1 Jul 2019 19:33:54 +0200
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Wed, 3 Jul 2019 10:25:04 +0200

x86/ldt: Initialize the context lock for init_mm

The mutex mm->context->lock for init_mm is not initialized for init_mm. This wasn't a problem because it remained unused. This changed however since commit
4fc19708b165c ("x86/alternatives: Initialize temporary mm for patching")

Initialize the mutex for init_mm.

Fixes 4fc19708b165c ("x86/alternatives: Initialize temporary mm for patching")
Cc Peter Zijlstra <[email protected]>
Cc Andy Lutomirski <[email protected]>
---
 arch/x86/include/asm/mmu.h | 1 +
 1 file changed, 1 insertion(+)
arch/x86/include/asm/mmu.h +1 -0
index 5ff3e8af2c20..e78c7db87801 100644
@@ -59,6 +59,7 @@ typedef struct {
 #define INIT_MM_CONTEXT(mm)						\
 	.context = {							\
 		.ctx_id = 1,						\
+		.lock = __MUTEX_INITIALIZER(mm.context.lock),		\
 	}
 
 void leave_mm(int cpu);
#3 lore raw
In reply to Sebastian Andrzej Siewior
x86/ldt: Initialize the context lock for init_mm
Commit-ID:  39ca5fb4920a96eeab478be2cfa6a2369fef6b02
Gitweb:     https://git.kernel.org/tip/39ca5fb4920a96eeab478be2cfa6a2369fef6b02
Author:     Sebastian Andrzej Siewior <[email protected]>
AuthorDate: Mon, 1 Jul 2019 19:33:54 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 9 Jul 2019 13:57:27 +0200

x86/ldt: Initialize the context lock for init_mm

The mutex mm->context->lock for init_mm is not initialized for init_mm. This wasn't a problem because it remained unused. This changed however since commit
4fc19708b165c ("x86/alternatives: Initialize temporary mm for patching")

Initialize the mutex for init_mm.

Fixes 4fc19708b165c ("x86/alternatives: Initialize temporary mm for patching")
Cc Peter Zijlstra <[email protected]>
Cc Andy Lutomirski <[email protected]>
---
 arch/x86/include/asm/mmu.h | 1 +
 1 file changed, 1 insertion(+)
arch/x86/include/asm/mmu.h +1 -0
index 5ff3e8af2c20..e78c7db87801 100644
@@ -59,6 +59,7 @@ typedef struct {
 #define INIT_MM_CONTEXT(mm)						\
 	.context = {							\
 		.ctx_id = 1,						\
+		.lock = __MUTEX_INITIALIZER(mm.context.lock),		\
 	}
 
 void leave_mm(int cpu);