exec.c (0b30191b277a13f75700b495dcd75a661b4f70a6) exec.c (0f2122045b946241a9e549c2a76cea54fa58a7ff)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * linux/fs/exec.c
4 *
5 * Copyright (C) 1991, 1992 Linus Torvalds
6 */
7
8/*

--- 48 unchanged lines hidden (view full) ---

57#include <linux/audit.h>
58#include <linux/tracehook.h>
59#include <linux/kmod.h>
60#include <linux/fsnotify.h>
61#include <linux/fs_struct.h>
62#include <linux/oom.h>
63#include <linux/compat.h>
64#include <linux/vmalloc.h>
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * linux/fs/exec.c
4 *
5 * Copyright (C) 1991, 1992 Linus Torvalds
6 */
7
8/*

--- 48 unchanged lines hidden (view full) ---

57#include <linux/audit.h>
58#include <linux/tracehook.h>
59#include <linux/kmod.h>
60#include <linux/fsnotify.h>
61#include <linux/fs_struct.h>
62#include <linux/oom.h>
63#include <linux/compat.h>
64#include <linux/vmalloc.h>
65#include <linux/io_uring.h>
65
66#include <linux/uaccess.h>
67#include <asm/mmu_context.h>
68#include <asm/tlb.h>
69
70#include <trace/events/task.h>
71#include "internal.h"
72

--- 1052 unchanged lines hidden (view full) ---

1125 if (unlikely(old_mm->core_state)) {
1126 mmap_read_unlock(old_mm);
1127 mutex_unlock(&tsk->signal->exec_update_mutex);
1128 return -EINTR;
1129 }
1130 }
1131
1132 task_lock(tsk);
66
67#include <linux/uaccess.h>
68#include <asm/mmu_context.h>
69#include <asm/tlb.h>
70
71#include <trace/events/task.h>
72#include "internal.h"
73

--- 1052 unchanged lines hidden (view full) ---

1126 if (unlikely(old_mm->core_state)) {
1127 mmap_read_unlock(old_mm);
1128 mutex_unlock(&tsk->signal->exec_update_mutex);
1129 return -EINTR;
1130 }
1131 }
1132
1133 task_lock(tsk);
1133 membarrier_exec_mmap(mm);
1134
1135 local_irq_disable();
1136 active_mm = tsk->active_mm;
1134 active_mm = tsk->active_mm;
1137 tsk->active_mm = mm;
1135 membarrier_exec_mmap(mm);
1138 tsk->mm = mm;
1136 tsk->mm = mm;
1139 /*
1140 * This prevents preemption while active_mm is being loaded and
1141 * it and mm are being updated, which could cause problems for
1142 * lazy tlb mm refcounting when these are updated by context
1143 * switches. Not all architectures can handle irqs off over
1144 * activate_mm yet.
1145 */
1146 if (!IS_ENABLED(CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM))
1147 local_irq_enable();
1137 tsk->active_mm = mm;
1148 activate_mm(active_mm, mm);
1138 activate_mm(active_mm, mm);
1149 if (IS_ENABLED(CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM))
1150 local_irq_enable();
1151 tsk->mm->vmacache_seqnum = 0;
1152 vmacache_flush(tsk);
1153 task_unlock(tsk);
1154 if (old_mm) {
1155 mmap_read_unlock(old_mm);
1156 BUG_ON(active_mm != old_mm);
1157 setmax_mm_hiwater_rss(&tsk->signal->maxrss, old_mm);
1158 mm_update_next_owner(old_mm);

--- 744 unchanged lines hidden (view full) ---

1903 */
1904static int bprm_execve(struct linux_binprm *bprm,
1905 int fd, struct filename *filename, int flags)
1906{
1907 struct file *file;
1908 struct files_struct *displaced;
1909 int retval;
1910
1139 tsk->mm->vmacache_seqnum = 0;
1140 vmacache_flush(tsk);
1141 task_unlock(tsk);
1142 if (old_mm) {
1143 mmap_read_unlock(old_mm);
1144 BUG_ON(active_mm != old_mm);
1145 setmax_mm_hiwater_rss(&tsk->signal->maxrss, old_mm);
1146 mm_update_next_owner(old_mm);

--- 744 unchanged lines hidden (view full) ---

1891 */
1892static int bprm_execve(struct linux_binprm *bprm,
1893 int fd, struct filename *filename, int flags)
1894{
1895 struct file *file;
1896 struct files_struct *displaced;
1897 int retval;
1898
1899 /*
1900 * Cancel any io_uring activity across execve
1901 */
1902 io_uring_task_cancel();
1903
1911 retval = unshare_files(&displaced);
1912 if (retval)
1913 return retval;
1914
1915 retval = prepare_bprm_creds(bprm);
1916 if (retval)
1917 goto out_files;
1918

--- 301 unchanged lines hidden ---
1904 retval = unshare_files(&displaced);
1905 if (retval)
1906 return retval;
1907
1908 retval = prepare_bprm_creds(bprm);
1909 if (retval)
1910 goto out_files;
1911

--- 301 unchanged lines hidden ---