linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Kees Cook <keescook@chromium.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Laurent Vivier <laurent@vivier.eu>,
	YunQiang Su <ysu@wavecomp.com>, Helge Deller <deller@gmx.de>,
	Willy Tarreau <w@1wt.eu>
Subject: Re: [PATCH] exec: Make suid_dumpable apply to SUID/SGID binaries irrespective of invoking users
Date: Tue, 21 Dec 2021 14:27:47 -0500	[thread overview]
Message-ID: <7f0f8e71-cf62-4c0b-5f13-a41919c6cd9b@redhat.com> (raw)
In-Reply-To: <CAHk-=wg+qpNvqcROndhRidOE1i7bQm93xM=jmre98-X4qkVkMw@mail.gmail.com>

On 12/21/21 13:19, Linus Torvalds wrote:
> On Tue, Dec 21, 2021 at 10:01 AM Waiman Long <longman@redhat.com> wrote:
>> Default RLIMIT_CORE to 0 will likely mitigate this vulnerability.
>> However, there are still some userspace impacts as existing behavior
>> will be modified. For instance, we may need to modify su to restore a
>> proper value for RLIMIT_CORE after successful authentication.
> We had a "clever" idea for this that I thought people were ok with.
>
> It's been some time since this came up, but iirc the notion was to
> instead of setting the rlimit to zero (which makes it really hard to
> restore afterwards, because you don't know what the restored value
> would be, so you are dependent on user space doing it), we just never
> reset set_dumpable() when we execve.
>
> So any suid exec will do set_dumpable() to suid_dumpable, and exec'ing
> something else does nothing at all - it stays non-dumpable (obviously
> "non-dumpable" here depends on the actual value for "suid_dumpable" -
> you can enable suid dump debugging manually).
>
> And instead, we say that operations like "setsid()" that start a new
> session - *those* are the ones that enable core dumping again. Or
> doing things like a "ulimit(RLIMIT_CORE)" (which clearly implies "I
> want core-dumps").
>
> Those will all very naturally make "login" and friends work correctly,
> while keeping core-dumps disabled for some suid situation that doesn't
> explicitly set up a new context.
>
> I think the basic problem with the traditional UNIX model of "suid
> exec doesn't core dump" is that the "enter non-core-dump" is a nice
> clear "your privileges changed".
>
> But then the "exit non-core-dump" thing is an exec that *doesn't*
> change privileges. That's the odd and crazy part: you just disabled
> core-dumps because there was a privilege level change, and then you
> enable core-dumps again because there *wasn't* a privilege change -
> even if you're still at those elevated privileges.
>
> Now, this is clearly not a Linux issue - we're just doing what others
> have been doing too. But I think we should just admit that "what
> others have been doing" is simply broken.
>
> And yes, some odd situation migth be broken by this kind of change,
> but I think this kind of "the old model was broken" may simply require
> that. I suspect we can find a solution that fixes all the regular
> cases.
>
> Hmm?

I think this is a pretty clever idea. At least it is better than 
resetting RLIMIT_CORE to 0. As it is all done within the kernel, there 
is no need to change any userspace code. We may need to add a flag bit 
in the task structure to indicate using the suid_dumpable setting so 
that it can be inherited across fork/exec.

Thanks for the suggestion.

Cheers,
Longman


  reply	other threads:[~2021-12-21 19:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-21  2:17 [PATCH] exec: Make suid_dumpable apply to SUID/SGID binaries irrespective of invoking users Waiman Long
2021-12-21 15:55 ` Eric W. Biederman
2021-12-21 16:41   ` Waiman Long
2021-12-21 17:35     ` Eric W. Biederman
2021-12-21 18:01       ` Waiman Long
2021-12-21 18:19         ` Linus Torvalds
2021-12-21 19:27           ` Waiman Long [this message]
2021-12-21 20:56             ` Willy Tarreau
2021-12-21 22:13               ` Willy Tarreau
2021-12-21 23:35                 ` Eric W. Biederman
2021-12-22  6:29                   ` Willy Tarreau
2021-12-26 15:03                   ` Willy Tarreau

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=7f0f8e71-cf62-4c0b-5f13-a41919c6cd9b@redhat.com \
    --to=longman@redhat.com \
    --cc=deller@gmx.de \
    --cc=ebiederm@xmission.com \
    --cc=keescook@chromium.org \
    --cc=laurent@vivier.eu \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=w@1wt.eu \
    --cc=ysu@wavecomp.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;
as well as URLs for NNTP newsgroup(s).