[PATCH, RFC] revert breakage from "tracehook: exec"

From: Arnd Bergmann
Date: Tue Dec 09 2008 - 09:36:29 EST


The patch 6341c39 "tracehook: exec" introduced a small regression in
2.6.27 regarding binfmt_misc exec event reporting. Since the reporting
is now done in the common search_binary_handler() function, an exec
of a misc binary will result in two (or possibly multiple) exec events
being reported, instead of just a single one, because the misc handler
contains a recursive call to search_binary_handler.

To add to the confusion, if ptrace event reporting (PTRACE_O_TRACEEVENT)
is not active, the multiple instances of send_sig (SIGTRAP) will in fact
cause only a single ptrace intercept, as the signals are not queued.
However, if PTRACE_O_TRACEEVENT is on, the debugger will actually see
multiple ptrace intercepts.

This (untested) patch moves the reporting back to the original location
and outside of the binfmt_misc path.

Signed-off-by: Ulrich Weigand <ulrich.weigand@xxxxxxxxxx>
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>

---

arch/x86/ia32/ia32_aout.c | 1 +
fs/binfmt_aout.c | 1 +
fs/binfmt_elf.c | 1 +
fs/binfmt_elf_fdpic.c | 2 ++
fs/binfmt_flat.c | 2 ++
fs/binfmt_som.c | 1 +
fs/exec.c | 1 -
7 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
index 127ec3f..f5b829a 100644
--- a/arch/x86/ia32/ia32_aout.c
+++ b/arch/x86/ia32/ia32_aout.c
@@ -444,6 +444,7 @@ beyond_if:
regs->r8 = regs->r9 = regs->r10 = regs->r11 =
regs->r12 = regs->r13 = regs->r14 = regs->r15 = 0;
set_fs(USER_DS);
+ tracehook_report_exec(&aout_format, bprm, regs);
return 0;
}

diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index 204cfd1..6979226 100644
--- a/fs/binfmt_aout.c
+++ b/fs/binfmt_aout.c
@@ -444,6 +444,7 @@ beyond_if:
regs->gp = ex.a_gpvalue;
#endif
start_thread(regs, ex.a_entry, current->mm->start_stack);
+ tracehook_report_exec(&aout_format, bprm, regs);
return 0;
}

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 8fcfa39..a7403cc 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1003,6 +1003,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
#endif

start_thread(regs, elf_entry, bprm->p);
+ tracehook_report_exec(&elf_format, bprm, regs);
retval = 0;
out:
kfree(loc);
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 5b5424c..d28052d 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -434,6 +434,8 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm,
entryaddr = interp_params.entry_addr ?: exec_params.entry_addr;
start_thread(regs, entryaddr, current->mm->start_stack);

+ tracehook_report_exec(&elf_fdpic_format, bprm, regs);
+
retval = 0;

error:
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index ccb781a..ed7aed3 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -922,6 +922,8 @@ static int load_flat_binary(struct linux_binprm * bprm, struct pt_regs * regs)

start_thread(regs, start_addr, current->mm->start_stack);

+ tracehook_report_exec(&flat_format, bprm, regs);
+
return 0;
}

diff --git a/fs/binfmt_som.c b/fs/binfmt_som.c
index 74e587a..40d88df 100644
--- a/fs/binfmt_som.c
+++ b/fs/binfmt_som.c
@@ -274,6 +274,7 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs)
map_hpux_gateway_page(current,current->mm);

start_thread_som(regs, som_entry, bprm->p);
+ tracehook_report_exec(&som_format, bprm, regs);
return 0;

/* error cleanup */
diff --git a/fs/exec.c b/fs/exec.c
index 67120ec..700edae 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1225,7 +1225,6 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
read_unlock(&binfmt_lock);
retval = fn(bprm, regs);
if (retval >= 0) {
- tracehook_report_exec(fmt, bprm, regs);
put_binfmt(fmt);
allow_write_access(bprm->file);
if (bprm->file)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/