Re: [PATCH 0/9] proc: protect /proc/<pid>/* files across execve

From: Djalal Harouni
Date: Sat Mar 10 2012 - 19:23:51 EST


On Sat, Mar 10, 2012 at 04:01:09PM -0800, Linus Torvalds wrote:
> On Sat, Mar 10, 2012 at 3:25 PM, Djalal Harouni <tixxdz@xxxxxxxxxx> wrote:
> >
> > 1) Use the target exec_id to bind files to their exec_id task:
> >
> > For the REG files /proc/<pid>/{environ,pagemap,mem} we set the exec_id
> > of the proc_file_private to the target task, and we continue with
> > permission checks at open time, later on each read/write call the
> > permission checks are done + check the target exec_id if it equals the
> > exec_id of the proc_file_private that was set at open time, in other words
> > we bind the file to its task's exec_id, this way new exec programs can not
> > operate on the passed fd.
>
> So the exec_id approach was totally broken when it was used for
> /proc/<pid>/mem, is there any reason to believe it's a good idea now?
Yes the previously one was broken since it was not a global uniq exec_id,
it was designed for threads tracking.

The current one is a global exec_id with uniq IDs, incremented on each
do_execve_common() call.

> It's entirely predictable, and you can make the exec_id match by
> simply forking elsewhere and then passing the fd around using unix
> domain sockets, since the exec_id is just updated by incrementing a
> counter.
For the fork one yes exec_id will match but we have the permission
checks (ptrace) at each syscall, so even if two processes share the same
exec_id the ptrace check should fail.

Yes it's predictable, but I don't see how you could pass the fd to another
extern privileged process without failing at the exec_id check.

--
tixxdz
http://opendz.org
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/