diff options
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 51 |
1 files changed, 19 insertions, 32 deletions
@@ -1071,6 +1071,21 @@ void set_task_comm(struct task_struct *tsk, char *buf) | |||
1071 | perf_event_comm(tsk); | 1071 | perf_event_comm(tsk); |
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | static 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 | |||
1074 | int flush_old_exec(struct linux_binprm * bprm) | 1089 | int flush_old_exec(struct linux_binprm * bprm) |
1075 | { | 1090 | { |
1076 | int retval; | 1091 | int retval; |
@@ -1085,6 +1100,7 @@ int flush_old_exec(struct linux_binprm * bprm) | |||
1085 | 1100 | ||
1086 | set_mm_exe_file(bprm->mm, bprm->file); | 1101 | set_mm_exe_file(bprm->mm, bprm->file); |
1087 | 1102 | ||
1103 | filename_to_taskname(bprm->tcomm, bprm->filename, sizeof(bprm->tcomm)); | ||
1088 | /* | 1104 | /* |
1089 | * Release all of the old mmap stuff | 1105 | * Release all of the old mmap stuff |
1090 | */ | 1106 | */ |
@@ -1116,10 +1132,6 @@ EXPORT_SYMBOL(would_dump); | |||
1116 | 1132 | ||
1117 | void setup_new_exec(struct linux_binprm * bprm) | 1133 | void setup_new_exec(struct linux_binprm * bprm) |
1118 | { | 1134 | { |
1119 | int i, ch; | ||
1120 | const char *name; | ||
1121 | char tcomm[sizeof(current->comm)]; | ||
1122 | |||
1123 | arch_pick_mmap_layout(current->mm); | 1135 | arch_pick_mmap_layout(current->mm); |
1124 | 1136 | ||
1125 | /* This is the point of no return */ | 1137 | /* This is the point of no return */ |
@@ -1130,18 +1142,7 @@ void setup_new_exec(struct linux_binprm * bprm) | |||
1130 | else | 1142 | else |
1131 | set_dumpable(current->mm, suid_dumpable); | 1143 | set_dumpable(current->mm, suid_dumpable); |
1132 | 1144 | ||
1133 | name = bprm->filename; | 1145 | set_task_comm(current, bprm->tcomm); |
1134 | |||
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 | ||
1146 | /* Set the new mm task size. We have to do that late because it may | 1147 | /* 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 | * depend on TIF_32BIT which is only updated in flush_thread() on |
@@ -1914,7 +1915,6 @@ static int coredump_wait(int exit_code, struct core_state *core_state) | |||
1914 | { | 1915 | { |
1915 | struct task_struct *tsk = current; | 1916 | struct task_struct *tsk = current; |
1916 | struct mm_struct *mm = tsk->mm; | 1917 | struct mm_struct *mm = tsk->mm; |
1917 | struct completion *vfork_done; | ||
1918 | int core_waiters = -EBUSY; | 1918 | int core_waiters = -EBUSY; |
1919 | 1919 | ||
1920 | init_completion(&core_state->startup); | 1920 | init_completion(&core_state->startup); |
@@ -1926,22 +1926,9 @@ static int coredump_wait(int exit_code, struct core_state *core_state) | |||
1926 | core_waiters = zap_threads(tsk, mm, core_state, exit_code); | 1926 | core_waiters = zap_threads(tsk, mm, core_state, exit_code); |
1927 | up_write(&mm->mmap_sem); | 1927 | up_write(&mm->mmap_sem); |
1928 | 1928 | ||
1929 | if (unlikely(core_waiters < 0)) | 1929 | if (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 | } | ||
1941 | |||
1942 | if (core_waiters) | ||
1943 | wait_for_completion(&core_state->startup); | 1930 | wait_for_completion(&core_state->startup); |
1944 | fail: | 1931 | |
1945 | return core_waiters; | 1932 | return core_waiters; |
1946 | } | 1933 | } |
1947 | 1934 | ||