diff options
-rw-r--r-- | fs/exec.c | 33 | ||||
-rw-r--r-- | include/linux/binfmts.h | 3 |
2 files changed, 19 insertions, 17 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 |
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index fd88a3945aa1..0092102db2de 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h | |||
@@ -18,7 +18,7 @@ struct pt_regs; | |||
18 | #define BINPRM_BUF_SIZE 128 | 18 | #define BINPRM_BUF_SIZE 128 |
19 | 19 | ||
20 | #ifdef __KERNEL__ | 20 | #ifdef __KERNEL__ |
21 | #include <linux/list.h> | 21 | #include <linux/sched.h> |
22 | 22 | ||
23 | #define CORENAME_MAX_SIZE 128 | 23 | #define CORENAME_MAX_SIZE 128 |
24 | 24 | ||
@@ -58,6 +58,7 @@ struct linux_binprm { | |||
58 | unsigned interp_flags; | 58 | unsigned interp_flags; |
59 | unsigned interp_data; | 59 | unsigned interp_data; |
60 | unsigned long loader, exec; | 60 | unsigned long loader, exec; |
61 | char tcomm[TASK_COMM_LEN]; | ||
61 | }; | 62 | }; |
62 | 63 | ||
63 | #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0 | 64 | #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0 |