[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXu5j+4RRGjzVxLSyz0CZCNMj4dPOxJp3pYGSN_sXFsiMhUaQ@mail.gmail.com>
Date: Thu, 8 Mar 2012 11:31:58 -0800
From: Kees Cook <keescook@...omium.org>
To: Cyrill Gorcunov <gorcunov@...nvz.org>
Cc: Oleg Nesterov <oleg@...hat.com>,
KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
Pavel Emelyanov <xemul@...allels.com>,
Tejun Heo <tj@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
LKML <linux-kernel@...r.kernel.org>,
Andy Lutomirski <luto@...capital.net>,
Will Drewry <wad@...omium.org>
Subject: Re: [RFC] c/r: prctl: Add ability to set new mm_struct::exe_file v3
On Thu, Mar 8, 2012 at 8:51 AM, Cyrill Gorcunov <gorcunov@...nvz.org> wrote:
> When we do restore we would like to have a way to setup
> a former mm_struct::exe_file so that /proc/pid/exe would
> point to the original executable file a process had at
> checkpoint time.
>
> For this the PR_SET_MM_EXE_FILE code is introduced.
> This option takes a file descriptor which will be
> set as new /proc/$pid/exe symlink.
>
> This feature is available iif CONFIG_CHECKPOINT_RESTORE is set.
> [...]
> Index: linux-2.6.git/kernel/sys.c
> ===================================================================
> --- linux-2.6.git.orig/kernel/sys.c
> +++ linux-2.6.git/kernel/sys.c
> [...]
> + exe_file = fget(fd);
> + if (!exe_file)
> + return -EBADF;
> +
> + dentry = exe_file->f_path.dentry;
> +
> + /*
> + * Because the original mm->exe_file
> + * points to executable file, make sure
> + * this one is executable as well to not
> + * break "big" picture and proc/pid/exe
> + * symlink will be still pointing to
> + * executable one.
> + */
> + err = -EACCES;
> + if (!S_ISREG(dentry->d_inode->i_mode) ||
> + exe_file->f_path.mnt->mnt_flags & MNT_NOEXEC)
> + goto exit;
I'm starting to notice that this pattern (testing ISREG and
MNT_NOEXEC) is getting repeated a few times in the kernel, and at
least the no-new-privs patch (not yet in -mm but hopefully soon given
the seccomp_filter work) updates this pattern everywhere. Perhaps this
should be extracted into a helper first, and then this patch can call
that helper here? (And then nnp can just update the single helper.)
-Kees
--
Kees Cook
ChromeOS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists