Skip to content

Commit 3aa0ce8

Browse files
committed
Un-inline the core-dump helper functions
Tony Luck reports that the addition of the access_ok() check in commit 0eead9a ("Don't dump task struct in a.out core-dumps") broke the ia64 compile due to missing the necessary header file includes. Rather than add yet another include (<asm/unistd.h>) to make everything happy, just uninline the silly core dump helper functions and move the bodies to fs/exec.c where they make a lot more sense. dump_seek() in particular was too big to be an inline function anyway, and none of them are in any way performance-critical. And we really don't need to mess up our include file headers more than they already are. Reported-and-tested-by: Tony Luck <tony.luck@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ae42d8d commit 3aa0ce8

File tree

2 files changed

+40
-32
lines changed

2 files changed

+40
-32
lines changed

fs/exec.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,3 +2014,41 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
20142014
fail:
20152015
return;
20162016
}
2017+
2018+
/*
2019+
* Core dumping helper functions. These are the only things you should
2020+
* do on a core-file: use only these functions to write out all the
2021+
* necessary info.
2022+
*/
2023+
int dump_write(struct file *file, const void *addr, int nr)
2024+
{
2025+
return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
2026+
}
2027+
2028+
int dump_seek(struct file *file, loff_t off)
2029+
{
2030+
int ret = 1;
2031+
2032+
if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
2033+
if (file->f_op->llseek(file, off, SEEK_CUR) < 0)
2034+
return 0;
2035+
} else {
2036+
char *buf = (char *)get_zeroed_page(GFP_KERNEL);
2037+
2038+
if (!buf)
2039+
return 0;
2040+
while (off > 0) {
2041+
unsigned long n = off;
2042+
2043+
if (n > PAGE_SIZE)
2044+
n = PAGE_SIZE;
2045+
if (!dump_write(file, buf, n)) {
2046+
ret = 0;
2047+
break;
2048+
}
2049+
off -= n;
2050+
}
2051+
free_page((unsigned long)buf);
2052+
}
2053+
return ret;
2054+
}

include/linux/coredump.h

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,7 @@
99
* These are the only things you should do on a core-file: use only these
1010
* functions to write out all the necessary info.
1111
*/
12-
static inline int dump_write(struct file *file, const void *addr, int nr)
13-
{
14-
return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
15-
}
16-
17-
static inline int dump_seek(struct file *file, loff_t off)
18-
{
19-
int ret = 1;
20-
21-
if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
22-
if (file->f_op->llseek(file, off, SEEK_CUR) < 0)
23-
return 0;
24-
} else {
25-
char *buf = (char *)get_zeroed_page(GFP_KERNEL);
26-
27-
if (!buf)
28-
return 0;
29-
while (off > 0) {
30-
unsigned long n = off;
31-
32-
if (n > PAGE_SIZE)
33-
n = PAGE_SIZE;
34-
if (!dump_write(file, buf, n)) {
35-
ret = 0;
36-
break;
37-
}
38-
off -= n;
39-
}
40-
free_page((unsigned long)buf);
41-
}
42-
return ret;
43-
}
12+
extern int dump_write(struct file *file, const void *addr, int nr);
13+
extern int dump_seek(struct file *file, loff_t off);
4414

4515
#endif /* _LINUX_COREDUMP_H */

0 commit comments

Comments
 (0)