From: Andrew Lutomirski <luto@mit.edu>
To: vcaputo@gnugeneration.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: adopt(pid_t pid) syscall proposal [patch included]
Date: Tue, 11 Jun 2013 11:47:10 -0700 [thread overview]
Message-ID: <CAObL_7GG8sMhx_vC7WMEqPgrVTr6_A=dsuO5cSWPfPRo7hsS0w@mail.gmail.com> (raw)
In-Reply-To: <20130611183825.GK5638@shells.gnugeneration.com>
On Tue, Jun 11, 2013 at 11:38 AM, <vcaputo@gnugeneration.com> wrote:
> On Tue, Jun 11, 2013 at 09:48:22AM -0700, Andy Lutomirski wrote:
>> On 06/10/2013 06:23 PM, vcaputo@gnugeneration.com wrote:
>> >+ if (!uid_eq(cred->euid, tcred->suid) &&
>> >+ !uid_eq(cred->euid, tcred->uid) &&
>> >+ !uid_eq(cred->uid, tcred->suid) &&
>> >+ !uid_eq(cred->uid, tcred->uid) &&
>> >+ !ns_capable(cred->user_ns, CAP_KILL)) {
>> >+ ret = -EPERM;
>> >+ goto out_unlock;
>> >+ }
>> >+
>>
>> That check's far too permissive.
>
> I suspected, but that's easily improved, I just wanted to get this out
> there and see what people thought, start the discussion, as well as
> get my use case functional. Although I'm curious, what is your cause
> for concern with the existing checks?
For example, "!uid_eq(cred->euid, tcred->uid)" means that you can
adopt setuid things. Looking at ptrace may be a good start.
>
>>
>> This sounds like it will break anything that uses wait and expects its
>> children to not be stolen out from under it.
>
> This thought crossed my mind, and originally I intended to restrict
> adoption to orphans who had become children of init. It seemed like
> more general use might be desirable so I left that out. If this
> really is a possibility worth preventing we could put that restriction
> on it. To the best of my knowledge, nothing informs init of its
> becoming parent of an orphan, so we should be able to steal the orphan
> back without harm. This still enables the use case of screen/tmux
> reattachment.
>
>>
>> Also, you'll have problems with screen -x or the default tmux shareable
>> configuration. It sounds like this is better done in userspace.
>
> It just needs some determination of "session leader" applied to which
> attach adopts the backend before invoking adopt(), that logic goes in
> userspace. I imagine the implementations of both screen and tmux
> already have such determinations happening for other reasons.
What I mean is: why not just teach your userspace tool to do this
without kernel help?
--Andy
prev parent reply other threads:[~2013-06-11 18:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-11 1:23 vcaputo
2013-06-11 16:48 ` Andy Lutomirski
2013-06-11 18:38 ` vcaputo
2013-06-11 18:47 ` Andrew Lutomirski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAObL_7GG8sMhx_vC7WMEqPgrVTr6_A=dsuO5cSWPfPRo7hsS0w@mail.gmail.com' \
--to=luto@mit.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=vcaputo@gnugeneration.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®