coredump.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. #include <linux/slab.h>
  2. #include <linux/file.h>
  3. #include <linux/fdtable.h>
  4. #include <linux/mm.h>
  5. #include <linux/stat.h>
  6. #include <linux/fcntl.h>
  7. #include <linux/swap.h>
  8. #include <linux/string.h>
  9. #include <linux/init.h>
  10. #include <linux/pagemap.h>
  11. #include <linux/perf_event.h>
  12. #include <linux/highmem.h>
  13. #include <linux/spinlock.h>
  14. #include <linux/key.h>
  15. #include <linux/personality.h>
  16. #include <linux/binfmts.h>
  17. #include <linux/coredump.h>
  18. #include <linux/utsname.h>
  19. #include <linux/pid_namespace.h>
  20. #include <linux/module.h>
  21. #include <linux/namei.h>
  22. #include <linux/mount.h>
  23. #include <linux/security.h>
  24. #include <linux/syscalls.h>
  25. #include <linux/tsacct_kern.h>
  26. #include <linux/cn_proc.h>
  27. #include <linux/audit.h>
  28. #include <linux/tracehook.h>
  29. #include <linux/kmod.h>
  30. #include <linux/fsnotify.h>
  31. #include <linux/fs_struct.h>
  32. #include <linux/pipe_fs_i.h>
  33. #include <linux/oom.h>
  34. #include <linux/compat.h>
  35. #include <asm/uaccess.h>
  36. #include <asm/mmu_context.h>
  37. #include <asm/tlb.h>
  38. #include <asm/exec.h>
  39. #include <trace/events/task.h>
  40. #include "internal.h"
  41. #include "coredump.h"
  42. #include <trace/events/sched.h>
  43. int core_uses_pid;
  44. char core_pattern[CORENAME_MAX_SIZE] = "core";
  45. unsigned int core_pipe_limit;
  46. struct core_name {
  47. char *corename;
  48. int used, size;
  49. };
  50. static atomic_t call_count = ATOMIC_INIT(1);
  51. /* The maximal length of core_pattern is also specified in sysctl.c */
  52. static int expand_corename(struct core_name *cn)
  53. {
  54. char *old_corename = cn->corename;
  55. cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
  56. cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
  57. if (!cn->corename) {
  58. kfree(old_corename);
  59. return -ENOMEM;
  60. }
  61. return 0;
  62. }
  63. static int cn_printf(struct core_name *cn, const char *fmt, ...)
  64. {
  65. char *cur;
  66. int need;
  67. int ret;
  68. va_list arg;
  69. va_start(arg, fmt);
  70. need = vsnprintf(NULL, 0, fmt, arg);
  71. va_end(arg);
  72. if (likely(need < cn->size - cn->used - 1))
  73. goto out_printf;
  74. ret = expand_corename(cn);
  75. if (ret)
  76. goto expand_fail;
  77. out_printf:
  78. cur = cn->corename + cn->used;
  79. va_start(arg, fmt);
  80. vsnprintf(cur, need + 1, fmt, arg);
  81. va_end(arg);
  82. cn->used += need;
  83. return 0;
  84. expand_fail:
  85. return ret;
  86. }
  87. static void cn_escape(char *str)
  88. {
  89. for (; *str; str++)
  90. if (*str == '/')
  91. *str = '!';
  92. }
  93. static int cn_print_exe_file(struct core_name *cn)
  94. {
  95. struct file *exe_file;
  96. char *pathbuf, *path;
  97. int ret;
  98. exe_file = get_mm_exe_file(current->mm);
  99. if (!exe_file) {
  100. char *commstart = cn->corename + cn->used;
  101. ret = cn_printf(cn, "%s (path unknown)", current->comm);
  102. cn_escape(commstart);
  103. return ret;
  104. }
  105. pathbuf = kmalloc(PATH_MAX, GFP_TEMPORARY);
  106. if (!pathbuf) {
  107. ret = -ENOMEM;
  108. goto put_exe_file;
  109. }
  110. path = d_path(&exe_file->f_path, pathbuf, PATH_MAX);
  111. if (IS_ERR(path)) {
  112. ret = PTR_ERR(path);
  113. goto free_buf;
  114. }
  115. cn_escape(path);
  116. ret = cn_printf(cn, "%s", path);
  117. free_buf:
  118. kfree(pathbuf);
  119. put_exe_file:
  120. fput(exe_file);
  121. return ret;
  122. }
  123. /* format_corename will inspect the pattern parameter, and output a
  124. * name into corename, which must have space for at least
  125. * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator.
  126. */
  127. static int format_corename(struct core_name *cn, struct coredump_params *cprm)
  128. {
  129. const struct cred *cred = current_cred();
  130. const char *pat_ptr = core_pattern;
  131. int ispipe = (*pat_ptr == '|');
  132. int pid_in_pattern = 0;
  133. int err = 0;
  134. cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
  135. cn->corename = kmalloc(cn->size, GFP_KERNEL);
  136. cn->used = 0;
  137. if (!cn->corename)
  138. return -ENOMEM;
  139. /* Repeat as long as we have more pattern to process and more output
  140. space */
  141. while (*pat_ptr) {
  142. if (*pat_ptr != '%') {
  143. if (*pat_ptr == 0)
  144. goto out;
  145. err = cn_printf(cn, "%c", *pat_ptr++);
  146. } else {
  147. switch (*++pat_ptr) {
  148. /* single % at the end, drop that */
  149. case 0:
  150. goto out;
  151. /* Double percent, output one percent */
  152. case '%':
  153. err = cn_printf(cn, "%c", '%');
  154. break;
  155. /* pid */
  156. case 'p':
  157. pid_in_pattern = 1;
  158. err = cn_printf(cn, "%d",
  159. task_tgid_vnr(current));
  160. break;
  161. /* uid */
  162. case 'u':
  163. err = cn_printf(cn, "%d", cred->uid);
  164. break;
  165. /* gid */
  166. case 'g':
  167. err = cn_printf(cn, "%d", cred->gid);
  168. break;
  169. case 'd':
  170. err = cn_printf(cn, "%d",
  171. __get_dumpable(cprm->mm_flags));
  172. break;
  173. /* signal that caused the coredump */
  174. case 's':
  175. err = cn_printf(cn, "%ld", cprm->siginfo->si_signo);
  176. break;
  177. /* UNIX time of coredump */
  178. case 't': {
  179. struct timeval tv;
  180. do_gettimeofday(&tv);
  181. err = cn_printf(cn, "%lu", tv.tv_sec);
  182. break;
  183. }
  184. /* hostname */
  185. case 'h': {
  186. char *namestart = cn->corename + cn->used;
  187. down_read(&uts_sem);
  188. err = cn_printf(cn, "%s",
  189. utsname()->nodename);
  190. up_read(&uts_sem);
  191. cn_escape(namestart);
  192. break;
  193. }
  194. /* executable */
  195. case 'e': {
  196. char *commstart = cn->corename + cn->used;
  197. err = cn_printf(cn, "%s", current->comm);
  198. cn_escape(commstart);
  199. break;
  200. }
  201. case 'E':
  202. err = cn_print_exe_file(cn);
  203. break;
  204. /* core limit size */
  205. case 'c':
  206. err = cn_printf(cn, "%lu",
  207. rlimit(RLIMIT_CORE));
  208. break;
  209. default:
  210. break;
  211. }
  212. ++pat_ptr;
  213. }
  214. if (err)
  215. return err;
  216. }
  217. /* Backward compatibility with core_uses_pid:
  218. *
  219. * If core_pattern does not include a %p (as is the default)
  220. * and core_uses_pid is set, then .%pid will be appended to
  221. * the filename. Do not do this for piped commands. */
  222. if (!ispipe && !pid_in_pattern && core_uses_pid) {
  223. err = cn_printf(cn, ".%d", task_tgid_vnr(current));
  224. if (err)
  225. return err;
  226. }
  227. out:
  228. return ispipe;
  229. }
  230. static int zap_process(struct task_struct *start, int exit_code)
  231. {
  232. struct task_struct *t;
  233. int nr = 0;
  234. start->signal->group_exit_code = exit_code;
  235. start->signal->group_stop_count = 0;
  236. t = start;
  237. do {
  238. task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK);
  239. if (t != current && t->mm) {
  240. sigaddset(&t->pending.signal, SIGKILL);
  241. signal_wake_up(t, 1);
  242. nr++;
  243. }
  244. } while_each_thread(start, t);
  245. return nr;
  246. }
  247. static int zap_threads(struct task_struct *tsk, struct mm_struct *mm,
  248. struct core_state *core_state, int exit_code)
  249. {
  250. struct task_struct *g, *p;
  251. unsigned long flags;
  252. int nr = -EAGAIN;
  253. spin_lock_irq(&tsk->sighand->siglock);
  254. if (!signal_group_exit(tsk->signal)) {
  255. mm->core_state = core_state;
  256. nr = zap_process(tsk, exit_code);
  257. tsk->signal->group_exit_task = tsk;
  258. /* ignore all signals except SIGKILL, see prepare_signal() */
  259. tsk->signal->flags = SIGNAL_GROUP_COREDUMP;
  260. clear_tsk_thread_flag(tsk, TIF_SIGPENDING);
  261. }
  262. spin_unlock_irq(&tsk->sighand->siglock);
  263. if (unlikely(nr < 0))
  264. return nr;
  265. if (atomic_read(&mm->mm_users) == nr + 1)
  266. goto done;
  267. /*
  268. * We should find and kill all tasks which use this mm, and we should
  269. * count them correctly into ->nr_threads. We don't take tasklist
  270. * lock, but this is safe wrt:
  271. *
  272. * fork:
  273. * None of sub-threads can fork after zap_process(leader). All
  274. * processes which were created before this point should be
  275. * visible to zap_threads() because copy_process() adds the new
  276. * process to the tail of init_task.tasks list, and lock/unlock
  277. * of ->siglock provides a memory barrier.
  278. *
  279. * do_exit:
  280. * The caller holds mm->mmap_sem. This means that the task which
  281. * uses this mm can't pass exit_mm(), so it can't exit or clear
  282. * its ->mm.
  283. *
  284. * de_thread:
  285. * It does list_replace_rcu(&leader->tasks, &current->tasks),
  286. * we must see either old or new leader, this does not matter.
  287. * However, it can change p->sighand, so lock_task_sighand(p)
  288. * must be used. Since p->mm != NULL and we hold ->mmap_sem
  289. * it can't fail.
  290. *
  291. * Note also that "g" can be the old leader with ->mm == NULL
  292. * and already unhashed and thus removed from ->thread_group.
  293. * This is OK, __unhash_process()->list_del_rcu() does not
  294. * clear the ->next pointer, we will find the new leader via
  295. * next_thread().
  296. */
  297. rcu_read_lock();
  298. for_each_process(g) {
  299. if (g == tsk->group_leader)
  300. continue;
  301. if (g->flags & PF_KTHREAD)
  302. continue;
  303. p = g;
  304. do {
  305. if (p->mm) {
  306. if (unlikely(p->mm == mm)) {
  307. lock_task_sighand(p, &flags);
  308. nr += zap_process(p, exit_code);
  309. p->signal->flags = SIGNAL_GROUP_EXIT;
  310. unlock_task_sighand(p, &flags);
  311. }
  312. break;
  313. }
  314. } while_each_thread(g, p);
  315. }
  316. rcu_read_unlock();
  317. done:
  318. atomic_set(&core_state->nr_threads, nr);
  319. return nr;
  320. }
  321. static int coredump_wait(int exit_code, struct core_state *core_state)
  322. {
  323. struct task_struct *tsk = current;
  324. struct mm_struct *mm = tsk->mm;
  325. int core_waiters = -EBUSY;
  326. init_completion(&core_state->startup);
  327. core_state->dumper.task = tsk;
  328. core_state->dumper.next = NULL;
  329. down_write(&mm->mmap_sem);
  330. if (!mm->core_state)
  331. core_waiters = zap_threads(tsk, mm, core_state, exit_code);
  332. up_write(&mm->mmap_sem);
  333. if (core_waiters > 0) {
  334. struct core_thread *ptr;
  335. wait_for_completion(&core_state->startup);
  336. /*
  337. * Wait for all the threads to become inactive, so that
  338. * all the thread context (extended register state, like
  339. * fpu etc) gets copied to the memory.
  340. */
  341. ptr = core_state->dumper.next;
  342. while (ptr != NULL) {
  343. wait_task_inactive(ptr->task, 0);
  344. ptr = ptr->next;
  345. }
  346. }
  347. return core_waiters;
  348. }
  349. static void coredump_finish(struct mm_struct *mm)
  350. {
  351. struct core_thread *curr, *next;
  352. struct task_struct *task;
  353. spin_lock_irq(&current->sighand->siglock);
  354. current->signal->group_exit_task = NULL;
  355. current->signal->flags = SIGNAL_GROUP_EXIT;
  356. spin_unlock_irq(&current->sighand->siglock);
  357. next = mm->core_state->dumper.next;
  358. while ((curr = next) != NULL) {
  359. next = curr->next;
  360. task = curr->task;
  361. /*
  362. * see exit_mm(), curr->task must not see
  363. * ->task == NULL before we read ->next.
  364. */
  365. smp_mb();
  366. curr->task = NULL;
  367. wake_up_process(task);
  368. }
  369. mm->core_state = NULL;
  370. }
  371. static void wait_for_dump_helpers(struct file *file)
  372. {
  373. struct pipe_inode_info *pipe;
  374. pipe = file_inode(file)->i_pipe;
  375. pipe_lock(pipe);
  376. pipe->readers++;
  377. pipe->writers--;
  378. while ((pipe->readers > 1) && (!signal_pending(current))) {
  379. wake_up_interruptible_sync(&pipe->wait);
  380. kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
  381. pipe_wait(pipe);
  382. }
  383. pipe->readers--;
  384. pipe->writers++;
  385. pipe_unlock(pipe);
  386. }
  387. /*
  388. * umh_pipe_setup
  389. * helper function to customize the process used
  390. * to collect the core in userspace. Specifically
  391. * it sets up a pipe and installs it as fd 0 (stdin)
  392. * for the process. Returns 0 on success, or
  393. * PTR_ERR on failure.
  394. * Note that it also sets the core limit to 1. This
  395. * is a special value that we use to trap recursive
  396. * core dumps
  397. */
  398. static int umh_pipe_setup(struct subprocess_info *info, struct cred *new)
  399. {
  400. struct file *files[2];
  401. struct coredump_params *cp = (struct coredump_params *)info->data;
  402. int err = create_pipe_files(files, 0);
  403. if (err)
  404. return err;
  405. cp->file = files[1];
  406. err = replace_fd(0, files[0], 0);
  407. fput(files[0]);
  408. /* and disallow core files too */
  409. current->signal->rlim[RLIMIT_CORE] = (struct rlimit){1, 1};
  410. return err;
  411. }
  412. void do_coredump(siginfo_t *siginfo)
  413. {
  414. struct core_state core_state;
  415. struct core_name cn;
  416. struct mm_struct *mm = current->mm;
  417. struct linux_binfmt * binfmt;
  418. const struct cred *old_cred;
  419. struct cred *cred;
  420. int retval = 0;
  421. int flag = 0;
  422. int ispipe;
  423. struct files_struct *displaced;
  424. bool need_nonrelative = false;
  425. static atomic_t core_dump_count = ATOMIC_INIT(0);
  426. struct coredump_params cprm = {
  427. .siginfo = siginfo,
  428. .regs = signal_pt_regs(),
  429. .limit = rlimit(RLIMIT_CORE),
  430. /*
  431. * We must use the same mm->flags while dumping core to avoid
  432. * inconsistency of bit flags, since this flag is not protected
  433. * by any locks.
  434. */
  435. .mm_flags = mm->flags,
  436. };
  437. audit_core_dumps(siginfo->si_signo);
  438. binfmt = mm->binfmt;
  439. if (!binfmt || !binfmt->core_dump)
  440. goto fail;
  441. if (!__get_dumpable(cprm.mm_flags))
  442. goto fail;
  443. cred = prepare_creds();
  444. if (!cred)
  445. goto fail;
  446. /*
  447. * We cannot trust fsuid as being the "true" uid of the process
  448. * nor do we know its entire history. We only know it was tainted
  449. * so we dump it as root in mode 2, and only into a controlled
  450. * environment (pipe handler or fully qualified path).
  451. */
  452. if (__get_dumpable(cprm.mm_flags) == SUID_DUMP_ROOT) {
  453. /* Setuid core dump mode */
  454. flag = O_EXCL; /* Stop rewrite attacks */
  455. cred->fsuid = GLOBAL_ROOT_UID; /* Dump root private */
  456. need_nonrelative = true;
  457. }
  458. retval = coredump_wait(siginfo->si_signo, &core_state);
  459. if (retval < 0)
  460. goto fail_creds;
  461. old_cred = override_creds(cred);
  462. ispipe = format_corename(&cn, &cprm);
  463. if (ispipe) {
  464. int dump_count;
  465. char **helper_argv;
  466. struct subprocess_info *sub_info;
  467. if (ispipe < 0) {
  468. printk(KERN_WARNING "format_corename failed\n");
  469. printk(KERN_WARNING "Aborting core\n");
  470. goto fail_corename;
  471. }
  472. if (cprm.limit == 1) {
  473. /* See umh_pipe_setup() which sets RLIMIT_CORE = 1.
  474. *
  475. * Normally core limits are irrelevant to pipes, since
  476. * we're not writing to the file system, but we use
  477. * cprm.limit of 1 here as a speacial value, this is a
  478. * consistent way to catch recursive crashes.
  479. * We can still crash if the core_pattern binary sets
  480. * RLIM_CORE = !1, but it runs as root, and can do
  481. * lots of stupid things.
  482. *
  483. * Note that we use task_tgid_vnr here to grab the pid
  484. * of the process group leader. That way we get the
  485. * right pid if a thread in a multi-threaded
  486. * core_pattern process dies.
  487. */
  488. printk(KERN_WARNING
  489. "Process %d(%s) has RLIMIT_CORE set to 1\n",
  490. task_tgid_vnr(current), current->comm);
  491. printk(KERN_WARNING "Aborting core\n");
  492. goto fail_unlock;
  493. }
  494. cprm.limit = RLIM_INFINITY;
  495. dump_count = atomic_inc_return(&core_dump_count);
  496. if (core_pipe_limit && (core_pipe_limit < dump_count)) {
  497. printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
  498. task_tgid_vnr(current), current->comm);
  499. printk(KERN_WARNING "Skipping core dump\n");
  500. goto fail_dropcount;
  501. }
  502. helper_argv = argv_split(GFP_KERNEL, cn.corename+1, NULL);
  503. if (!helper_argv) {
  504. printk(KERN_WARNING "%s failed to allocate memory\n",
  505. __func__);
  506. goto fail_dropcount;
  507. }
  508. retval = -ENOMEM;
  509. sub_info = call_usermodehelper_setup(helper_argv[0],
  510. helper_argv, NULL, GFP_KERNEL,
  511. umh_pipe_setup, NULL, &cprm);
  512. if (sub_info)
  513. retval = call_usermodehelper_exec(sub_info,
  514. UMH_WAIT_EXEC);
  515. argv_free(helper_argv);
  516. if (retval) {
  517. printk(KERN_INFO "Core dump to %s pipe failed\n",
  518. cn.corename);
  519. goto close_fail;
  520. }
  521. } else {
  522. struct inode *inode;
  523. if (cprm.limit < binfmt->min_coredump)
  524. goto fail_unlock;
  525. if (need_nonrelative && cn.corename[0] != '/') {
  526. printk(KERN_WARNING "Pid %d(%s) can only dump core "\
  527. "to fully qualified path!\n",
  528. task_tgid_vnr(current), current->comm);
  529. printk(KERN_WARNING "Skipping core dump\n");
  530. goto fail_unlock;
  531. }
  532. cprm.file = filp_open(cn.corename,
  533. O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag,
  534. 0600);
  535. if (IS_ERR(cprm.file))
  536. goto fail_unlock;
  537. inode = file_inode(cprm.file);
  538. if (inode->i_nlink > 1)
  539. goto close_fail;
  540. if (d_unhashed(cprm.file->f_path.dentry))
  541. goto close_fail;
  542. /*
  543. * AK: actually i see no reason to not allow this for named
  544. * pipes etc, but keep the previous behaviour for now.
  545. */
  546. if (!S_ISREG(inode->i_mode))
  547. goto close_fail;
  548. /*
  549. * Dont allow local users get cute and trick others to coredump
  550. * into their pre-created files.
  551. */
  552. if (!uid_eq(inode->i_uid, current_fsuid()))
  553. goto close_fail;
  554. if (!cprm.file->f_op || !cprm.file->f_op->write)
  555. goto close_fail;
  556. if (do_truncate(cprm.file->f_path.dentry, 0, 0, cprm.file))
  557. goto close_fail;
  558. }
  559. /* get us an unshared descriptor table; almost always a no-op */
  560. retval = unshare_files(&displaced);
  561. if (retval)
  562. goto close_fail;
  563. if (displaced)
  564. put_files_struct(displaced);
  565. retval = binfmt->core_dump(&cprm);
  566. if (retval)
  567. current->signal->group_exit_code |= 0x80;
  568. if (ispipe && core_pipe_limit)
  569. wait_for_dump_helpers(cprm.file);
  570. close_fail:
  571. if (cprm.file)
  572. filp_close(cprm.file, NULL);
  573. fail_dropcount:
  574. if (ispipe)
  575. atomic_dec(&core_dump_count);
  576. fail_unlock:
  577. kfree(cn.corename);
  578. fail_corename:
  579. coredump_finish(mm);
  580. revert_creds(old_cred);
  581. fail_creds:
  582. put_cred(cred);
  583. fail:
  584. return;
  585. }
  586. /*
  587. * Core dumping helper functions. These are the only things you should
  588. * do on a core-file: use only these functions to write out all the
  589. * necessary info.
  590. */
  591. int dump_write(struct file *file, const void *addr, int nr)
  592. {
  593. return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
  594. }
  595. EXPORT_SYMBOL(dump_write);
  596. int dump_seek(struct file *file, loff_t off)
  597. {
  598. int ret = 1;
  599. if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
  600. if (file->f_op->llseek(file, off, SEEK_CUR) < 0)
  601. return 0;
  602. } else {
  603. char *buf = (char *)get_zeroed_page(GFP_KERNEL);
  604. if (!buf)
  605. return 0;
  606. while (off > 0) {
  607. unsigned long n = off;
  608. if (n > PAGE_SIZE)
  609. n = PAGE_SIZE;
  610. if (!dump_write(file, buf, n)) {
  611. ret = 0;
  612. break;
  613. }
  614. off -= n;
  615. }
  616. free_page((unsigned long)buf);
  617. }
  618. return ret;
  619. }
  620. EXPORT_SYMBOL(dump_seek);