From: Arnd Bergmann <arnd@arndb.de>
To: Roland McGrath <roland@redhat.com>,
Oleg Nesterov <oleg@tv-sign.ru>, Ingo Molnar <mingo@elte.hu>,
LKML <linux-kernel@vger.kernel.org>,
Ulrich Weigand <ulrich.weigand@de.ibm.com>
Subject: [PATCH, RFC] revert breakage from "tracehook: exec"
Date: Tue, 9 Dec 2008 15:33:09 +0100 [thread overview]
Message-ID: <200812091533.10628.arnd@arndb.de> (raw)
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@de.ibm.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
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)
next reply other threads:[~2008-12-09 14:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-09 14:33 Arnd Bergmann [this message]
2008-12-10 4:04 ` [PATCH, RFC] revert breakage from "tracehook: exec" Roland McGrath
2008-12-11 21:42 ` Ulrich Weigand
2008-12-10 4:04 ` [PATCH] tracehook: exec double-reporting fix Roland McGrath
2008-12-11 13:29 ` Arnd Bergmann
2008-12-11 16:44 ` [stable] " Greg KH
2008-12-11 17:59 ` Kirill A. Shutemov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200812091533.10628.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--cc=roland@redhat.com \
--cc=ulrich.weigand@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox