Skip to contentSkip to conversation

mm: respect arch_dup_mmap() return value

PATCH Applied Nadav Amit 2 participants 2 messages Aug 23, 2018

Subsystems (5)
lore
Share & tools
lore

Nadav Amit

author
#0 lore raw

PATCH 1/1 mm: respect arch_dup_mmap() return value

Commit d70f2a14b72a4 ("include/linux/sched/mm.h: uninline mmdrop_async(), etc") ignored the return value of arch_dup_mmap(). As a result, on x86, a failure to duplicate the LDT (e.g., due to memory allocation error), would leave the duplicated memory mapping in an inconsistent state.

Fix by regarding the return value, as it was before the change.

Fixes d70f2a14b72a4 ("include/linux/sched/mm.h: uninline mmdrop_async(), etc")
Cc Andrew Morton <[email protected]>
---
 kernel/fork.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/fork.c +1 -2
index 1b27babc4c78..4527d1d331de 100644
@@ -549,8 +549,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
 			goto out;
 	}
 	/* a new mm has just been created */
-	arch_dup_mmap(oldmm, mm);
-	retval = 0;
+	retval = arch_dup_mmap(oldmm, mm);
 out:
 	up_write(&mm->mmap_sem);
 	flush_tlb_mm(oldmm);
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Nadav Amit

Commit d70f2a14b72a4 ("include/linux/sched/mm.h: uninline mmdrop_async(), etc") ignored the return value of arch_dup_mmap(). As a result, on x86, a failure to duplicate the LDT (e.g., due to memory allocation error), would leave the duplicated memory mapping in an inconsistent state.

Fix by regarding the return value, as it was before the change.

Ohh, well spotted! I have a vague recollection I didn't really like the patch. For other reasons. I didn't get to review it properly back then because I didn't have much time and I didn't have a high motivation because I simple disagreed with the patch.

Quoted 4 lines
Fixes d70f2a14b72a4 ("include/linux/sched/mm.h: uninline mmdrop_async(), etc")
Cc Andrew Morton <[email protected]>

Thanks!

Quoted 21 lines
---
 kernel/fork.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/fork.c +1 -2
index 1b27babc4c78..4527d1d331de 100644
@@ -549,8 +549,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
 			goto out;
 	}
 	/* a new mm has just been created */
-	arch_dup_mmap(oldmm, mm);
-	retval = 0;
+	retval = arch_dup_mmap(oldmm, mm);
 out:
 	up_write(&mm->mmap_sem);
 	flush_tlb_mm(oldmm);
Signature · 1 line
2.17.1
Signature · 2 lines
Michal Hocko
SUSE Labs