diff options
Diffstat (limited to 'fs/binfmt_aout.c')
-rw-r--r-- | fs/binfmt_aout.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index 61dd00a6c7b4..d2f8872dd767 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c | |||
@@ -69,16 +69,32 @@ static int dump_write(struct file *file, const void *addr, int nr) | |||
69 | return file->f_op->write(file, addr, nr, &file->f_pos) == nr; | 69 | return file->f_op->write(file, addr, nr, &file->f_pos) == nr; |
70 | } | 70 | } |
71 | 71 | ||
72 | static int dump_seek(struct file *file, loff_t off) | ||
73 | { | ||
74 | if (file->f_op->llseek && file->f_op->llseek != no_llseek) { | ||
75 | if (file->f_op->llseek(file, off, SEEK_CUR) < 0) | ||
76 | return 0; | ||
77 | } else { | ||
78 | char *buf = (char *)get_zeroed_page(GFP_KERNEL); | ||
79 | if (!buf) | ||
80 | return 0; | ||
81 | while (off > 0) { | ||
82 | unsigned long n = off; | ||
83 | if (n > PAGE_SIZE) | ||
84 | n = PAGE_SIZE; | ||
85 | if (!dump_write(file, buf, n)) | ||
86 | return 0; | ||
87 | off -= n; | ||
88 | } | ||
89 | free_page((unsigned long)buf); | ||
90 | } | ||
91 | return 1; | ||
92 | } | ||
93 | |||
72 | #define DUMP_WRITE(addr, nr) \ | 94 | #define DUMP_WRITE(addr, nr) \ |
73 | if (!dump_write(file, (void *)(addr), (nr))) \ | 95 | if (!dump_write(file, (void *)(addr), (nr))) \ |
74 | goto end_coredump; | 96 | goto end_coredump; |
75 | 97 | ||
76 | #define DUMP_SEEK(offset) \ | ||
77 | if (file->f_op->llseek) { \ | ||
78 | if (file->f_op->llseek(file,(offset),0) != (offset)) \ | ||
79 | goto end_coredump; \ | ||
80 | } else file->f_pos = (offset) | ||
81 | |||
82 | /* | 98 | /* |
83 | * Routine writes a core dump image in the current directory. | 99 | * Routine writes a core dump image in the current directory. |
84 | * Currently only a stub-function. | 100 | * Currently only a stub-function. |
@@ -132,7 +148,8 @@ static int aout_core_dump(struct coredump_params *cprm) | |||
132 | /* struct user */ | 148 | /* struct user */ |
133 | DUMP_WRITE(&dump,sizeof(dump)); | 149 | DUMP_WRITE(&dump,sizeof(dump)); |
134 | /* Now dump all of the user data. Include malloced stuff as well */ | 150 | /* Now dump all of the user data. Include malloced stuff as well */ |
135 | DUMP_SEEK(PAGE_SIZE); | 151 | if (!dump_seek(cprm->file, PAGE_SIZE - sizeof(dump))) |
152 | goto end_coredump; | ||
136 | /* now we start writing out the user space info */ | 153 | /* now we start writing out the user space info */ |
137 | set_fs(USER_DS); | 154 | set_fs(USER_DS); |
138 | /* Dump the data area */ | 155 | /* Dump the data area */ |