Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 287262
b: refs/heads/master
c: 96e02d1
h: refs/heads/master
v: v3
  • Loading branch information
Heiko Carstens authored and Linus Torvalds committed Feb 6, 2012
1 parent e3f5ebc commit 7391367
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 23783f817bceedd6d4e549385e3f400ea64059e5
refs/heads/master: 96e02d1586782eadf051fa3d6bc4132d2447ac2c
33 changes: 17 additions & 16 deletions trunk/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,21 @@ void set_task_comm(struct task_struct *tsk, char *buf)
perf_event_comm(tsk);
}

static void filename_to_taskname(char *tcomm, const char *fn, unsigned int len)
{
int i, ch;

/* Copies the binary name from after last slash */
for (i = 0; (ch = *(fn++)) != '\0';) {
if (ch == '/')
i = 0; /* overwrite what we wrote */
else
if (i < len - 1)
tcomm[i++] = ch;
}
tcomm[i] = '\0';
}

int flush_old_exec(struct linux_binprm * bprm)
{
int retval;
Expand All @@ -1085,6 +1100,7 @@ int flush_old_exec(struct linux_binprm * bprm)

set_mm_exe_file(bprm->mm, bprm->file);

filename_to_taskname(bprm->tcomm, bprm->filename, sizeof(bprm->tcomm));
/*
* Release all of the old mmap stuff
*/
Expand Down Expand Up @@ -1116,10 +1132,6 @@ EXPORT_SYMBOL(would_dump);

void setup_new_exec(struct linux_binprm * bprm)
{
int i, ch;
const char *name;
char tcomm[sizeof(current->comm)];

arch_pick_mmap_layout(current->mm);

/* This is the point of no return */
Expand All @@ -1130,18 +1142,7 @@ void setup_new_exec(struct linux_binprm * bprm)
else
set_dumpable(current->mm, suid_dumpable);

name = bprm->filename;

/* Copies the binary name from after last slash */
for (i=0; (ch = *(name++)) != '\0';) {
if (ch == '/')
i = 0; /* overwrite what we wrote */
else
if (i < (sizeof(tcomm) - 1))
tcomm[i++] = ch;
}
tcomm[i] = '\0';
set_task_comm(current, tcomm);
set_task_comm(current, bprm->tcomm);

/* Set the new mm task size. We have to do that late because it may
* depend on TIF_32BIT which is only updated in flush_thread() on
Expand Down
3 changes: 2 additions & 1 deletion trunk/include/linux/binfmts.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct pt_regs;
#define BINPRM_BUF_SIZE 128

#ifdef __KERNEL__
#include <linux/list.h>
#include <linux/sched.h>

#define CORENAME_MAX_SIZE 128

Expand Down Expand Up @@ -58,6 +58,7 @@ struct linux_binprm {
unsigned interp_flags;
unsigned interp_data;
unsigned long loader, exec;
char tcomm[TASK_COMM_LEN];
};

#define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
Expand Down

0 comments on commit 7391367

Please sign in to comment.