aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2009-12-17 18:27:16 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-17 18:45:31 -0500
commitf6151dfea21496d43dbaba32cfcd9c9f404769bc (patch)
tree092b73a1cd7edbd0e04fe2076ed678447446aa70 /fs/exec.c
parent9cd80bbb07fcd6d4d037fad4297496d3b132ac6b (diff)
mm: introduce coredump parameter structure
Introduce coredump parameter data structure (struct coredump_params) to simplify binfmt->core_dump() arguments. Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Suggested-by: Ingo Molnar <mingo@elte.hu> Cc: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Roland McGrath <roland@redhat.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 77db9a97a773..632b02e34ec7 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1763,17 +1763,20 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
1763 struct mm_struct *mm = current->mm; 1763 struct mm_struct *mm = current->mm;
1764 struct linux_binfmt * binfmt; 1764 struct linux_binfmt * binfmt;
1765 struct inode * inode; 1765 struct inode * inode;
1766 struct file * file;
1767 const struct cred *old_cred; 1766 const struct cred *old_cred;
1768 struct cred *cred; 1767 struct cred *cred;
1769 int retval = 0; 1768 int retval = 0;
1770 int flag = 0; 1769 int flag = 0;
1771 int ispipe = 0; 1770 int ispipe = 0;
1772 unsigned long core_limit = current->signal->rlim[RLIMIT_CORE].rlim_cur;
1773 char **helper_argv = NULL; 1771 char **helper_argv = NULL;
1774 int helper_argc = 0; 1772 int helper_argc = 0;
1775 int dump_count = 0; 1773 int dump_count = 0;
1776 static atomic_t core_dump_count = ATOMIC_INIT(0); 1774 static atomic_t core_dump_count = ATOMIC_INIT(0);
1775 struct coredump_params cprm = {
1776 .signr = signr,
1777 .regs = regs,
1778 .limit = current->signal->rlim[RLIMIT_CORE].rlim_cur,
1779 };
1777 1780
1778 audit_core_dumps(signr); 1781 audit_core_dumps(signr);
1779 1782
@@ -1829,15 +1832,15 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
1829 ispipe = format_corename(corename, signr); 1832 ispipe = format_corename(corename, signr);
1830 unlock_kernel(); 1833 unlock_kernel();
1831 1834
1832 if ((!ispipe) && (core_limit < binfmt->min_coredump)) 1835 if ((!ispipe) && (cprm.limit < binfmt->min_coredump))
1833 goto fail_unlock; 1836 goto fail_unlock;
1834 1837
1835 if (ispipe) { 1838 if (ispipe) {
1836 if (core_limit == 0) { 1839 if (cprm.limit == 0) {
1837 /* 1840 /*
1838 * Normally core limits are irrelevant to pipes, since 1841 * Normally core limits are irrelevant to pipes, since
1839 * we're not writing to the file system, but we use 1842 * we're not writing to the file system, but we use
1840 * core_limit of 0 here as a speacial value. Any 1843 * cprm.limit of 0 here as a speacial value. Any
1841 * non-zero limit gets set to RLIM_INFINITY below, but 1844 * non-zero limit gets set to RLIM_INFINITY below, but
1842 * a limit of 0 skips the dump. This is a consistent 1845 * a limit of 0 skips the dump. This is a consistent
1843 * way to catch recursive crashes. We can still crash 1846 * way to catch recursive crashes. We can still crash
@@ -1870,25 +1873,25 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
1870 goto fail_dropcount; 1873 goto fail_dropcount;
1871 } 1874 }
1872 1875
1873 core_limit = RLIM_INFINITY; 1876 cprm.limit = RLIM_INFINITY;
1874 1877
1875 /* SIGPIPE can happen, but it's just never processed */ 1878 /* SIGPIPE can happen, but it's just never processed */
1876 if (call_usermodehelper_pipe(helper_argv[0], helper_argv, NULL, 1879 if (call_usermodehelper_pipe(helper_argv[0], helper_argv, NULL,
1877 &file)) { 1880 &cprm.file)) {
1878 printk(KERN_INFO "Core dump to %s pipe failed\n", 1881 printk(KERN_INFO "Core dump to %s pipe failed\n",
1879 corename); 1882 corename);
1880 goto fail_dropcount; 1883 goto fail_dropcount;
1881 } 1884 }
1882 } else 1885 } else
1883 file = filp_open(corename, 1886 cprm.file = filp_open(corename,
1884 O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag, 1887 O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag,
1885 0600); 1888 0600);
1886 if (IS_ERR(file)) 1889 if (IS_ERR(cprm.file))
1887 goto fail_dropcount; 1890 goto fail_dropcount;
1888 inode = file->f_path.dentry->d_inode; 1891 inode = cprm.file->f_path.dentry->d_inode;
1889 if (inode->i_nlink > 1) 1892 if (inode->i_nlink > 1)
1890 goto close_fail; /* multiple links - don't dump */ 1893 goto close_fail; /* multiple links - don't dump */
1891 if (!ispipe && d_unhashed(file->f_path.dentry)) 1894 if (!ispipe && d_unhashed(cprm.file->f_path.dentry))
1892 goto close_fail; 1895 goto close_fail;
1893 1896
1894 /* AK: actually i see no reason to not allow this for named pipes etc., 1897 /* AK: actually i see no reason to not allow this for named pipes etc.,
@@ -1901,21 +1904,22 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
1901 */ 1904 */
1902 if (inode->i_uid != current_fsuid()) 1905 if (inode->i_uid != current_fsuid())
1903 goto close_fail; 1906 goto close_fail;
1904 if (!file->f_op) 1907 if (!cprm.file->f_op)
1905 goto close_fail; 1908 goto close_fail;
1906 if (!file->f_op->write) 1909 if (!cprm.file->f_op->write)
1907 goto close_fail; 1910 goto close_fail;
1908 if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0) 1911 if (!ispipe &&
1912 do_truncate(cprm.file->f_path.dentry, 0, 0, cprm.file) != 0)
1909 goto close_fail; 1913 goto close_fail;
1910 1914
1911 retval = binfmt->core_dump(signr, regs, file, core_limit); 1915 retval = binfmt->core_dump(&cprm);
1912 1916
1913 if (retval) 1917 if (retval)
1914 current->signal->group_exit_code |= 0x80; 1918 current->signal->group_exit_code |= 0x80;
1915close_fail: 1919close_fail:
1916 if (ispipe && core_pipe_limit) 1920 if (ispipe && core_pipe_limit)
1917 wait_for_dump_helpers(file); 1921 wait_for_dump_helpers(cprm.file);
1918 filp_close(file, NULL); 1922 filp_close(cprm.file, NULL);
1919fail_dropcount: 1923fail_dropcount:
1920 if (dump_count) 1924 if (dump_count)
1921 atomic_dec(&core_dump_count); 1925 atomic_dec(&core_dump_count);