From: Stephen Hemminger <stephen.hemminger@vyatta.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Chris Wright <chrisw@osdl.org>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH] sysctl: permission check based on capability not euid
Date: Wed, 28 May 2008 12:12:00 -0700 [thread overview]
Message-ID: <20080528121200.54c04b5a@speedy> (raw)
This patch modifies the permission checks for sysctl's from being based on uid=0 (root)
to use the capability system. This matches the behavior of other OS's using sysctl's
and capabilities. Linux has tried to get away from using uid=0 for security overrides
and use capabilities instead.
I was working on Quagga enhancement that involved enabling a sysctl, and it didn't
work because is a safe daemon and drops privileges and resets its real/effective uid
after initialization; it then re-enables only the capabilities when it needs to
do some privileged operation. This wouldn't work because sysctl's were still using
the root based permission check. The existing code in quagga to enable ip forwarding
doesn't work for the same reason.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
Maybe once the BKL is gone, the last vestiges of current->euid == 0 can be wiped out
as well.
--- a/include/linux/capability.h 2008-05-27 17:33:02.000000000 -0700
+++ b/include/linux/capability.h 2008-05-27 17:33:27.000000000 -0700
@@ -261,6 +261,7 @@ typedef struct kernel_cap_struct {
arbitrary SCSI commands */
/* Allow setting encryption key on loopback filesystem */
/* Allow setting zone reclaim policy */
+/* Allow setting any sysctl value */
#define CAP_SYS_ADMIN 21
--- a/kernel/sysctl.c 2008-05-27 17:32:33.000000000 -0700
+++ b/kernel/sysctl.c 2008-05-27 17:32:46.000000000 -0700
@@ -1561,7 +1561,7 @@ out:
static int test_perm(int mode, int op)
{
- if (!current->euid)
+ if (capable(CAP_SYS_ADMIN))
mode >>= 6;
else if (in_egroup_p(0))
mode >>= 3;
next reply other threads:[~2008-05-28 19:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-28 19:12 Stephen Hemminger [this message]
2008-05-28 20:14 ` [PATCH] sysctl: permission check based on capability not euid Chris Wright
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=20080528121200.54c04b5a@speedy \
--to=stephen.hemminger@vyatta.com \
--cc=akpm@linux-foundation.org \
--cc=chrisw@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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).