[Devel] [PATCH 01/13] fs: exec_mmap() arg corrected

Konstantin Khorenko khorenko at virtuozzo.com
Thu Apr 15 14:51:41 MSK 2021


The following patch dropped:

[PATCH 01/13] fs: exec_mmap() arg corrected
It does not change the logic, it's aim is unclear.

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 04/14/2021 10:57 AM, Alexander Mikhalitsyn wrote:
> From: Konstantin Khorenko <khorenko at virtuozzo.com>
>
> ---
>
> VZ 8 rebase part https://jira.sw.ru/browse/PSBM-127782
>
> Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
> Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
> ---
>  fs/exec.c | 17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/fs/exec.c b/fs/exec.c
> index c036db0323e0..dfaedb7323bb 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -1003,10 +1003,10 @@ ssize_t read_code(struct file *file, unsigned long addr, loff_t pos, size_t len)
>  }
>  EXPORT_SYMBOL(read_code);
>
> -static int exec_mmap(struct mm_struct *mm)
> +static int exec_mmap(struct linux_binprm *bprm)
>  {
>  	struct task_struct *tsk;
> -	struct mm_struct *old_mm, *active_mm;
> +	struct mm_struct *old_mm, *active_mm, *mm;
>
>  	/* Notify parent that we're no longer interested in the old VM */
>  	tsk = current;
> @@ -1028,6 +1028,7 @@ static int exec_mmap(struct mm_struct *mm)
>  		}
>  	}
>
> +	mm = bprm->mm;
>  	mm->vps_dumpable = VD_PTRACE_COREDUMP;
>  	task_lock(tsk);
>  	active_mm = tsk->active_mm;
> @@ -1038,6 +1039,8 @@ static int exec_mmap(struct mm_struct *mm)
>  	tsk->mm->vmacache_seqnum = 0;
>  	vmacache_flush(tsk);
>  	task_unlock(tsk);
> +	bprm->mm = NULL;		/* We're using it now */
> +
>  	if (old_mm) {
>  		up_read(&old_mm->mmap_sem);
>  		BUG_ON(active_mm != old_mm);
> @@ -1276,18 +1279,10 @@ int flush_old_exec(struct linux_binprm * bprm)
>  	 * Release all of the old mmap stuff
>  	 */
>  	acct_arg_size(bprm, 0);
> -	retval = exec_mmap(bprm->mm);
> +	retval = exec_mmap(bprm);
>  	if (retval)
>  		goto out;
>
> -	/*
> -	 * After clearing bprm->mm (to mark that current is using the
> -	 * prepared mm now), we have nothing left of the original
> -	 * process. If anything from here on returns an error, the check
> -	 * in search_binary_handler() will SEGV current.
> -	 */
> -	bprm->mm = NULL;
> -
>  	set_fs(USER_DS);
>  	current->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD |
>  					PF_NOFREEZE | PF_NO_SETAFFINITY);
>


More information about the Devel mailing list