[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 6 Jun 2009 08:22:44 +0100
From: Al Viro <viro@...IV.linux.org.uk>
To: Alexey Dobriyan <adobriyan@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Matt Helsley <matthltc@...ibm.com>, xemul@...allels.com,
containers@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org, dave@...ux.vnet.ibm.com,
mingo@...e.hu, torvalds@...ux-foundation.org,
linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH 1/9] exec_path 1/9: introduce ->exec_path and switch
/proc/*/exe
On Thu, Jun 04, 2009 at 03:04:22AM +0400, Alexey Dobriyan wrote:
> diff --git a/fs/binfmt_som.c b/fs/binfmt_som.c
> index eff74b9..6c56262 100644
> --- a/fs/binfmt_som.c
> +++ b/fs/binfmt_som.c
> @@ -174,6 +174,7 @@ static int map_som_binary(struct file *file,
> up_write(¤t->mm->mmap_sem);
> if (retval > 0 || retval < -1024)
> retval = 0;
> + set_task_exec_path(current, &bprm->file->f_path);
Oh? Even on failure exits?
> + if (!path->mnt || !path->dentry)
> + return -ENOENT;
Umm... I really don't like that. Note that path with NULL vfsmount
and non-NULL dentry should never happen. If anything, we ought
to add path_empty(path) (!(path)->mnt) and convert such places to it.
> +static inline void set_task_exec_path(struct task_struct *tsk, struct path *path)
> +{
> + struct path old_path;
> +
> + path_get(path);
> + task_lock(tsk);
> + old_path = tsk->exec_path;
> + tsk->exec_path = *path;
> + task_unlock(tsk);
> + path_put(&old_path);
> +}
Do we ever have a right to do that to anything other than current? Note
that fork() is a special case anyway...
> + set_task_exec_path(tsk, &(struct path){ .mnt = NULL, .dentry = NULL });
Ew...
> + get_task_exec_path(current, &p->exec_path);
> +
We already have that value sitting there, so why not get_path(&p->exec_path)?
The real problem I have with that we *really* can't umount the filesystem
that used to host the binary anymore. At all.
Frankly, I'm almost tempted to add explicit way to switch the damn thing
via /proc/self/something - e.g. allow a binary to write a pathname to
/proc/self/set_exec and have that switch the sucker. The interesting
part, of course, is figuring out the security implications of that...
--
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