mm-ksm-fix-ksm-exec-support-for-prctl.patch removed from -mm tree
The quilt patch titled
Subject: mm/ksm: fix ksm exec support for prctl
has been removed from the -mm tree. Its filename was
mm-ksm-fix-ksm-exec-support-for-prctl.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Jinjiang Tu <[email protected]>
Subject: mm/ksm: fix ksm exec support for prctl
Date: Thu, 28 Mar 2024 19:10:08 +0800
Patch series "mm/ksm: fix ksm exec support for prctl", v4.
commit 3c6f33b7273a ("mm/ksm: support fork/exec for prctl") inherits MMF_VM_MERGE_ANY flag when a task calls execve(). However, it doesn't create the mm_slot, so ksmd will not try to scan this task. The first patch fixes the issue.
The second patch refactors to prepare for the third patch. The third patch extends the selftests of ksm to verfity the deduplication really happens after fork/exec inherits ths KSM setting.
This patch (of 3):
commit 3c6f33b7273a ("mm/ksm: support fork/exec for prctl") inherits MMF_VM_MERGE_ANY flag when a task calls execve(). Howerver, it doesn't create the mm_slot, so ksmd will not try to scan this task.
To fix it, allocate and add the mm_slot to ksm_mm_head in __bprm_mm_init() when the mm has MMF_VM_MERGE_ANY flag.
---
fs/exec.c | 11 +++++++++++ include/linux/ksm.h | 13 +++++++++++++ 2 files changed, 24 insertions(+)
fs/exec.c renamed from fs/exec.c~mm-ksm-fix-ksm-exec-support-for-prctl +11 -0
@@ -67,6 +67,7 @@#include <linux/time_namespace.h> #include <linux/user_events.h> #include <linux/rseq.h> +#include <linux/ksm.h> #include <linux/uaccess.h> #include <asm/mmu_context.h>
@@ -268,6 +269,14 @@ static int __bprm_mm_init(struct linux_b }/* +* Need to be called with mmap write lock +* held, to avoid race with ksmd. +*/ + err =ksm_execve (mm); +if (err) + goto err_ksm; + +/* * Place the stack at the largest stack address the architecture * supports. Later, we'll move this to an appropriate place. We don't * use STACK_TOP because that can depend on attributes which aren't
@@ -288,6 +297,8 @@ static int __bprm_mm_init(struct linux_b bprm->p = vma->vm_end -sizeof (void *);return 0 ; err: +ksm_exit (mm); +err_ksm:mmap_write_unlock (mm); err_free: bprm->vma =NULL ;
include/linux/ksm.h renamed from include/linux/ksm.h~mm-ksm-fix-ksm-exec-support-for-prctl +13 -0
@@ -59,6 +59,14 @@ static inline int ksm_fork(struct mm_strreturn 0 ; } +static inline int ksm_execve (struct mm_struct *mm) +{ +if (test_bit (MMF_VM_MERGE_ANY , &mm->flags)) +return __ksm_enter (mm); + +return 0 ; +} +static inline void ksm_exit (struct mm_struct *mm) {if (test_bit (MMF_VM_MERGEABLE , &mm->flags))
@@ -106,6 +114,11 @@ static inline int ksm_fork(struct mm_str {return 0 ; } + +static inline int ksm_execve (struct mm_struct *mm) +{ +return 0 ; +}static inline void ksm_exit (struct mm_struct *mm) {
_
Patches currently in -mm which might be from [email protected] are