Commit 845884d3 authored by Greg Ungerer's avatar Greg Ungerer Committed by Linus Torvalds

[PATCH] uclinux: delay binfmt_flat trace

Modify the initial trace output (which is based on flags in the binary
header) so that it is not done until after the magic number check.  This
may well not be a flat format binary, so the flags could be invalid.
(Prime example, running a script).

Changes prompted by patches from Stuart Hughs.
Signed-off-by: default avatarGreg Ungerer <gerg@uclinux.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 082f2c1c
...@@ -442,19 +442,22 @@ static int load_flat_file(struct linux_binprm * bprm, ...@@ -442,19 +442,22 @@ static int load_flat_file(struct linux_binprm * bprm,
flags = ntohl(hdr->flags); flags = ntohl(hdr->flags);
rev = ntohl(hdr->rev); rev = ntohl(hdr->rev);
if (flags & FLAT_FLAG_KTRACE) if (strncmp(hdr->magic, "bFLT", 4)) {
printk("BINFMT_FLAT: Loading file: %s\n", bprm->filename);
if (strncmp(hdr->magic, "bFLT", 4) ||
(rev != FLAT_VERSION && rev != OLD_FLAT_VERSION)) {
/* /*
* because a lot of people do not manage to produce good * because a lot of people do not manage to produce good
* flat binaries, we leave this printk to help them realise * flat binaries, we leave this printk to help them realise
* the problem. We only print the error if its not a script file * the problem. We only print the error if its not a script file
*/ */
if (strncmp(hdr->magic, "#!", 2)) if (strncmp(hdr->magic, "#!", 2))
printk("BINFMT_FLAT: bad magic/rev (0x%x, need 0x%x)\n", printk("BINFMT_FLAT: bad header magic\n");
rev, (int) FLAT_VERSION); return -ENOEXEC;
}
if (flags & FLAT_FLAG_KTRACE)
printk("BINFMT_FLAT: Loading file: %s\n", bprm->filename);
if (rev != FLAT_VERSION && rev != OLD_FLAT_VERSION) {
printk("BINFMT_FLAT: bad flat file version 0x%x (supported 0x%x and 0x%x)\n", rev, FLAT_VERSION, OLD_FLAT_VERSION);
return -ENOEXEC; return -ENOEXEC;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment