Commit 0eead9ab authored by Linus Torvalds's avatar Linus Torvalds

Don't dump task struct in a.out core-dumps

akiphie points out that a.out core-dumps have that odd task struct
dumping that was never used and was never really a good idea (it goes
back into the mists of history, probably the original core-dumping
code).  Just remove it.

Also do the access_ok() check on dump_write().  It probably doesn't
matter (since normal filesystems all seem to do it anyway), but he
points out that it's normally done by the VFS layer, so ...

[ I suspect that we should possibly do "vfs_write()" instead of
  calling ->write directly.  That also does the whole fsnotify and write
  statistics thing, which may or may not be a good idea. ]

And just to be anal, do this all for the x86-64 32-bit a.out emulation
code too, even though it's not enabled (and won't currently even
compile)
Reported-by: default avatarakiphie <akiphie@lavabit.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 53eeb64e
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <asm/ia32.h> #include <asm/ia32.h>
#undef WARN_OLD #undef WARN_OLD
#undef CORE_DUMP /* probably broken */ #undef CORE_DUMP /* definitely broken */
static int load_aout_binary(struct linux_binprm *, struct pt_regs *regs); static int load_aout_binary(struct linux_binprm *, struct pt_regs *regs);
static int load_aout_library(struct file *); static int load_aout_library(struct file *);
...@@ -131,21 +131,15 @@ static void set_brk(unsigned long start, unsigned long end) ...@@ -131,21 +131,15 @@ static void set_brk(unsigned long start, unsigned long end)
* macros to write out all the necessary info. * macros to write out all the necessary info.
*/ */
static int dump_write(struct file *file, const void *addr, int nr) #include <linux/coredump.h>
{
return file->f_op->write(file, addr, nr, &file->f_pos) == nr;
}
#define DUMP_WRITE(addr, nr) \ #define DUMP_WRITE(addr, nr) \
if (!dump_write(file, (void *)(addr), (nr))) \ if (!dump_write(file, (void *)(addr), (nr))) \
goto end_coredump; goto end_coredump;
#define DUMP_SEEK(offset) \ #define DUMP_SEEK(offset) \
if (file->f_op->llseek) { \ if (!dump_seek(file, offset)) \
if (file->f_op->llseek(file, (offset), 0) != (offset)) \ goto end_coredump;
goto end_coredump; \
} else \
file->f_pos = (offset)
#define START_DATA() (u.u_tsize << PAGE_SHIFT) #define START_DATA() (u.u_tsize << PAGE_SHIFT)
#define START_STACK(u) (u.start_stack) #define START_STACK(u) (u.start_stack)
...@@ -217,12 +211,6 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, ...@@ -217,12 +211,6 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
dump_size = dump.u_ssize << PAGE_SHIFT; dump_size = dump.u_ssize << PAGE_SHIFT;
DUMP_WRITE(dump_start, dump_size); DUMP_WRITE(dump_start, dump_size);
} }
/*
* Finally dump the task struct. Not be used by gdb, but
* could be useful
*/
set_fs(KERNEL_DS);
DUMP_WRITE(current, sizeof(*current));
end_coredump: end_coredump:
set_fs(fs); set_fs(fs);
return has_dumped; return has_dumped;
......
...@@ -134,10 +134,6 @@ static int aout_core_dump(struct coredump_params *cprm) ...@@ -134,10 +134,6 @@ static int aout_core_dump(struct coredump_params *cprm)
if (!dump_write(file, dump_start, dump_size)) if (!dump_write(file, dump_start, dump_size))
goto end_coredump; goto end_coredump;
} }
/* Finally dump the task struct. Not be used by gdb, but could be useful */
set_fs(KERNEL_DS);
if (!dump_write(file, current, sizeof(*current)))
goto end_coredump;
end_coredump: end_coredump:
set_fs(fs); set_fs(fs);
return has_dumped; return has_dumped;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
*/ */
static inline int dump_write(struct file *file, const void *addr, int nr) static inline int dump_write(struct file *file, const void *addr, int nr)
{ {
return file->f_op->write(file, addr, nr, &file->f_pos) == nr; return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
} }
static inline int dump_seek(struct file *file, loff_t off) static inline int dump_seek(struct file *file, loff_t off)
......
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