exec.c (05e5bd0f3daddb0368a433af5b58be68c62dc365) exec.c (c415c3b47ea2754659d915cca387a20999044163)
1/*
2 * linux/fs/exec.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7/*
8 * #!-checking implemented by tytso.

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

1066 */
1067 memset(tsk->comm, 0, TASK_COMM_LEN);
1068 wmb();
1069 strlcpy(tsk->comm, buf, sizeof(tsk->comm));
1070 task_unlock(tsk);
1071 perf_event_comm(tsk);
1072}
1073
1/*
2 * linux/fs/exec.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7/*
8 * #!-checking implemented by tytso.

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

1066 */
1067 memset(tsk->comm, 0, TASK_COMM_LEN);
1068 wmb();
1069 strlcpy(tsk->comm, buf, sizeof(tsk->comm));
1070 task_unlock(tsk);
1071 perf_event_comm(tsk);
1072}
1073
1074static void filename_to_taskname(char *tcomm, const char *fn, unsigned int len)
1075{
1076 int i, ch;
1077
1078 /* Copies the binary name from after last slash */
1079 for (i = 0; (ch = *(fn++)) != '\0';) {
1080 if (ch == '/')
1081 i = 0; /* overwrite what we wrote */
1082 else
1083 if (i < len - 1)
1084 tcomm[i++] = ch;
1085 }
1086 tcomm[i] = '\0';
1087}
1088
1074int flush_old_exec(struct linux_binprm * bprm)
1075{
1076 int retval;
1077
1078 /*
1079 * Make sure we have a private signal table and that
1080 * we are unassociated from the previous thread group.
1081 */
1082 retval = de_thread(current);
1083 if (retval)
1084 goto out;
1085
1086 set_mm_exe_file(bprm->mm, bprm->file);
1087
1089int flush_old_exec(struct linux_binprm * bprm)
1090{
1091 int retval;
1092
1093 /*
1094 * Make sure we have a private signal table and that
1095 * we are unassociated from the previous thread group.
1096 */
1097 retval = de_thread(current);
1098 if (retval)
1099 goto out;
1100
1101 set_mm_exe_file(bprm->mm, bprm->file);
1102
1103 filename_to_taskname(bprm->tcomm, bprm->filename, sizeof(bprm->tcomm));
1088 /*
1089 * Release all of the old mmap stuff
1090 */
1091 acct_arg_size(bprm, 0);
1092 retval = exec_mmap(bprm->mm);
1093 if (retval)
1094 goto out;
1095

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

1111{
1112 if (inode_permission(file->f_path.dentry->d_inode, MAY_READ) < 0)
1113 bprm->interp_flags |= BINPRM_FLAGS_ENFORCE_NONDUMP;
1114}
1115EXPORT_SYMBOL(would_dump);
1116
1117void setup_new_exec(struct linux_binprm * bprm)
1118{
1104 /*
1105 * Release all of the old mmap stuff
1106 */
1107 acct_arg_size(bprm, 0);
1108 retval = exec_mmap(bprm->mm);
1109 if (retval)
1110 goto out;
1111

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

1127{
1128 if (inode_permission(file->f_path.dentry->d_inode, MAY_READ) < 0)
1129 bprm->interp_flags |= BINPRM_FLAGS_ENFORCE_NONDUMP;
1130}
1131EXPORT_SYMBOL(would_dump);
1132
1133void setup_new_exec(struct linux_binprm * bprm)
1134{
1119 int i, ch;
1120 const char *name;
1121 char tcomm[sizeof(current->comm)];
1122
1123 arch_pick_mmap_layout(current->mm);
1124
1125 /* This is the point of no return */
1126 current->sas_ss_sp = current->sas_ss_size = 0;
1127
1128 if (current_euid() == current_uid() && current_egid() == current_gid())
1129 set_dumpable(current->mm, 1);
1130 else
1131 set_dumpable(current->mm, suid_dumpable);
1132
1135 arch_pick_mmap_layout(current->mm);
1136
1137 /* This is the point of no return */
1138 current->sas_ss_sp = current->sas_ss_size = 0;
1139
1140 if (current_euid() == current_uid() && current_egid() == current_gid())
1141 set_dumpable(current->mm, 1);
1142 else
1143 set_dumpable(current->mm, suid_dumpable);
1144
1133 name = bprm->filename;
1145 set_task_comm(current, bprm->tcomm);
1134
1146
1135 /* Copies the binary name from after last slash */
1136 for (i=0; (ch = *(name++)) != '\0';) {
1137 if (ch == '/')
1138 i = 0; /* overwrite what we wrote */
1139 else
1140 if (i < (sizeof(tcomm) - 1))
1141 tcomm[i++] = ch;
1142 }
1143 tcomm[i] = '\0';
1144 set_task_comm(current, tcomm);
1145
1146 /* Set the new mm task size. We have to do that late because it may
1147 * depend on TIF_32BIT which is only updated in flush_thread() on
1148 * some architectures like powerpc
1149 */
1150 current->mm->task_size = TASK_SIZE;
1151
1152 /* install the new credentials */
1153 if (bprm->cred->uid != current_euid() ||

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

1909 atomic_set(&core_state->nr_threads, nr);
1910 return nr;
1911}
1912
1913static int coredump_wait(int exit_code, struct core_state *core_state)
1914{
1915 struct task_struct *tsk = current;
1916 struct mm_struct *mm = tsk->mm;
1147 /* Set the new mm task size. We have to do that late because it may
1148 * depend on TIF_32BIT which is only updated in flush_thread() on
1149 * some architectures like powerpc
1150 */
1151 current->mm->task_size = TASK_SIZE;
1152
1153 /* install the new credentials */
1154 if (bprm->cred->uid != current_euid() ||

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

1910 atomic_set(&core_state->nr_threads, nr);
1911 return nr;
1912}
1913
1914static int coredump_wait(int exit_code, struct core_state *core_state)
1915{
1916 struct task_struct *tsk = current;
1917 struct mm_struct *mm = tsk->mm;
1917 struct completion *vfork_done;
1918 int core_waiters = -EBUSY;
1919
1920 init_completion(&core_state->startup);
1921 core_state->dumper.task = tsk;
1922 core_state->dumper.next = NULL;
1923
1924 down_write(&mm->mmap_sem);
1925 if (!mm->core_state)
1926 core_waiters = zap_threads(tsk, mm, core_state, exit_code);
1927 up_write(&mm->mmap_sem);
1928
1929 if (unlikely(core_waiters < 0))
1930 goto fail;
1931
1932 /*
1933 * Make sure nobody is waiting for us to release the VM,
1934 * otherwise we can deadlock when we wait on each other
1935 */
1918 int core_waiters = -EBUSY;
1919
1920 init_completion(&core_state->startup);
1921 core_state->dumper.task = tsk;
1922 core_state->dumper.next = NULL;
1923
1924 down_write(&mm->mmap_sem);
1925 if (!mm->core_state)
1926 core_waiters = zap_threads(tsk, mm, core_state, exit_code);
1927 up_write(&mm->mmap_sem);
1928
1929 if (unlikely(core_waiters < 0))
1930 goto fail;
1931
1932 /*
1933 * Make sure nobody is waiting for us to release the VM,
1934 * otherwise we can deadlock when we wait on each other
1935 */
1936 vfork_done = tsk->vfork_done;
1937 if (vfork_done) {
1938 tsk->vfork_done = NULL;
1939 complete(vfork_done);
1940 }
1936 if (tsk->vfork_done)
1937 complete_vfork_done(tsk);
1941
1942 if (core_waiters)
1943 wait_for_completion(&core_state->startup);
1944fail:
1945 return core_waiters;
1946}
1947
1948static void coredump_finish(struct mm_struct *mm)

--- 355 unchanged lines hidden ---
1938
1939 if (core_waiters)
1940 wait_for_completion(&core_state->startup);
1941fail:
1942 return core_waiters;
1943}
1944
1945static void coredump_finish(struct mm_struct *mm)

--- 355 unchanged lines hidden ---