do_coredump(): make sure that descriptor table isn't shared
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 22 Aug 2012 02:43:47 +0000 (22:43 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 27 Sep 2012 01:09:59 +0000 (21:09 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/exec.c

index 3fc74681cc6cca5a39553bbe0d605eb88ed8aab4..beb05a95e4a35cc25f4eee42a8f4b267b5bd0233 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -2066,6 +2066,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
        int retval = 0;
        int flag = 0;
        int ispipe;
+       struct files_struct *displaced;
        bool need_nonrelative = false;
        static atomic_t core_dump_count = ATOMIC_INIT(0);
        struct coredump_params cprm = {
@@ -2219,6 +2220,12 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
                        goto close_fail;
        }
 
+       /* get us an unshared descriptor table; almost always a no-op */
+       retval = unshare_files(&displaced);
+       if (retval)
+               goto close_fail;
+       if (displaced)
+               put_files_struct(displaced);
        retval = binfmt->core_dump(&cprm);
        if (retval)
                current->signal->group_exit_code |= 0x80;