From: Solar Designer <solar@openwall.com>
To: kernel-hardening@lists.openwall.com
Subject: Re: [kernel-hardening] rlimit_nproc check
Date: Sun, 12 Jun 2011 06:28:33 +0400 [thread overview]
Message-ID: <20110612022833.GB14976@openwall.com> (raw)
In-Reply-To: <20110609141745.GA11957@albatros>
Vasiliy -
On Thu, Jun 09, 2011 at 06:17:45PM +0400, Vasiliy Kulikov wrote:
> I found 8-years old patch that enables RLIMIT_NPROC check at setuid (and
> similar) calls:
>
> http://lkml.org/lkml/2003/7/13/226
>
> So, checking it on execve() is a bit redundant. But it means that
> setuid() may fail if it follows setrlimit() call and the target user
> has already reached the limit (asserted on the test C program). If the
> limit is defined in pam_limit, the attack becomes real.
Right. Dealing with setuid() failing to drop privs yet returning, which
many apps don't expect, is definitely something we (you) need to do
under this project. In Linux 2.4.x-ow, I simply do:
--- linux-2.4.37.9.orig/kernel/sys.c 2010-02-01 21:04:46 +0000
+++ linux-2.4.37.9/kernel/sys.c 2010-02-18 14:04:42 +0000
@@ -514,8 +514,10 @@ static int set_user(uid_t new_ruid, int
struct user_struct *new_user;
new_user = alloc_uid(new_ruid);
- if (!new_user)
+ if (!new_user) {
+ force_sig(SIGSEGV, current);
return -EAGAIN;
+ }
switch_uid(new_user);
if(dumpclear)
As an option, you could propose to revert that 8-year old change and
introduce the check on execve(). Unrealistic?
The requirements are:
1. setuid(2) must not fail and return, when it was invoked with
"appropriate privileges". If it fails, it must not return.
This suggests that it should not fail very often, so maybe the
RLIMIT_NPROC check does not belong there.
2. The setuid-execve sequence should not successfully start the new
program when that would exceed RLIMIT_NPROC for the target UID.
Oh, by the way, here's what I found:
Subject: [PATCH] sched: Don't allow setuid to succeed if the user does not have rt bandwidth
http://lists.openwall.net/linux-kernel/2009/02/27/177
Thanks,
Alexander
next prev parent reply other threads:[~2011-06-12 2:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-09 14:17 [kernel-hardening] rlimit_nproc check Vasiliy Kulikov
2011-06-12 2:28 ` Solar Designer [this message]
2011-06-12 13:12 ` Vasiliy Kulikov
2011-06-19 13:34 ` Vasiliy Kulikov
2011-06-23 17:11 ` Vasiliy Kulikov
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=20110612022833.GB14976@openwall.com \
--to=solar@openwall.com \
--cc=kernel-hardening@lists.openwall.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