mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Sarah Sharp <sarah.a.sharp@linux.intel.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Marcus Meissner <meissner@suse.de>,
	linux-kernel@vger.kernel.org, tj@kernel.org,
	akpm@linux-foundation.org, hpa@zytor.com, w@1wt.eu
Subject: Re: [PATCH] kernel: make /proc/kallsyms mode 400 to reduce ease of attacking
Date: Tue, 30 Nov 2010 12:58:51 +0100	[thread overview]
Message-ID: <20101130115851.GB9639@elte.hu> (raw)
In-Reply-To: <20101129233150.60a3c3af@lxorguk.ukuu.org.uk>


* Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:

> > >  	/* Some debugging symbols have no name.  Ignore them. */
> > > -	if (!iter->name[0])
> > > +	if (!iter->name[0] || !capable(CAP_SYS_ADMIN))
> > >  		return 0;
> 
> This is hardcoding file permission policy into the kernel in a way the
> user cannot change - its bogus in the extreme. Use file permissions that
> way saner people can chmod them as they like. Indeed quite a few people
> *already* chmod chunks of /proc.

Peter already pointed that out and i agree.

The main goal here was to establish that a regression-free patch can be implemented 
by giving user-space a *empty /proc/kallsyms file* - that we older systems do not 
crash on bootup.

> It also means that things like SELinux and Tomoyo can be used to manage security 
> on it in clever ways - something that using a capability completely buggers up.

Frankly, our security interfaces are a mess - i did not even try to figure out the 
'right' way to do it. Modularization of security subsystem made it all distinctly 
worse.

Why dont we have coherent, easy to use (and hard to mess up) security interfaces to 
begin with? The moment a kernel developer has to think of:

        retval = -EPERM;
        if (capable(CAP_SETUID)) {
                new->suid = new->uid = uid;
                if (uid != old->uid) {
                        retval = set_user(new);
                        if (retval < 0)
                                goto error;
                }
        } else if (uid != old->uid && uid != new->suid) {
                goto error;
        }

        new->fsuid = new->euid = uid;

        retval = security_task_fix_setuid(new, old, LSM_SETID_ID);
        if (retval < 0)
                goto error;


As the 'secure' implementation of a piece of kernel logic we have lost the 
'security' battle ...

The current security callbacks are absolutely nonsensical random crap slapped all 
around the kernel. It increases our security complexity and has thus the opposite 
effect - it makes us _less_ secure.

Did no-one think of merging the capabilities checks and the security subsystem 
callbacks in some easy-to-use manner, which makes the default security policy 
apparent at first sight?

This code should be written in a simpler form, something like:

        retval = -EPERM;
	if (!security_allow_task_fix_setuid(new, old)) {
                new->suid = new->uid = uid;
                if (uid != old->uid) {
                        retval = set_user(new);
                        if (retval < 0)
                                goto error;
                }
        } else if (uid != old->uid && uid != new->suid) {
                goto error;
        }

        new->fsuid = new->euid = uid;

Where the default security_allow_task_fix_setuid() is basically a CAP_SETUID check - 
and we know this from the 'security_allow_task_fix_setuid' name already.

This way all those stupid, passive security callbacks become _active participants of 
the code_, and the code becomes more compact and easier to understand - and it 
becomes harder to mess up both compatibility details and permission details.

[ And yes, i realize that this isnt a 100% replacement of the existing callback,
  because some of the default logic cannot be turned off - but heck, that's a 
  feature not a bug! We dont want to allow security modules to make things _less_ 
  secure, or break legacies, right? So they should be shaped as _additional_
  restrictions on the coarse default semantics.

  And dont get me started about the idiocy of LSM_SETID_ID. Why isnt that detail put 
  into the callback name? What's wrong with security_task_fix_setuid_id(new, old)? ]

Whoever allowed security modules to be added in their current form needs some 
talking to.

Thanks,

	Ingo

  reply	other threads:[~2010-11-30 11:59 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-16 10:46 Marcus Meissner
2010-11-17  5:07 ` Kyle McMartin
2010-11-18  7:48   ` Ingo Molnar
2010-11-20  3:18     ` Kees Cook
2010-11-26  7:51       ` Ingo Molnar
2010-11-17  5:40 ` Kyle Moffett
2010-11-17  5:41   ` Kyle Moffett
2010-11-17  5:58   ` Linus Torvalds
2010-11-17  6:19     ` Willy Tarreau
2010-11-18  7:31   ` Ingo Molnar
2010-11-23 17:24     ` Pavel Machek
2010-11-26  7:38       ` Ingo Molnar
2010-11-29 19:03         ` H. Peter Anvin
2010-11-20 11:32   ` Avi Kivity
2010-11-19 19:19 ` Sarah Sharp
2010-11-19 19:54   ` Linus Torvalds
2010-11-19 19:58     ` david
2010-11-19 20:04       ` Linus Torvalds
2010-11-19 20:16         ` Willy Tarreau
2010-11-19 20:55           ` david
2010-11-26  7:48     ` Ingo Molnar
2010-11-29 16:33       ` Sarah Sharp
2010-11-29 18:04         ` Ingo Molnar
2010-11-29 19:05           ` H. Peter Anvin
2010-11-29 19:21             ` Eric Paris
2010-11-29 19:38               ` H. Peter Anvin
2010-11-29 21:49             ` Willy Tarreau
2010-11-29 23:31         ` Alan Cox
2010-11-30 11:58           ` Ingo Molnar [this message]
2010-11-20 11:05 ` Richard W.M. Jones
  -- strict thread matches above, loose matches on Subject: below --
2010-11-19 21:12 Andy Walls
2010-11-19 23:22 ` Linus Torvalds
2010-11-20  2:40   ` Kees Cook
2010-11-20 19:47     ` Henrique de Moraes Holschuh
2010-11-29 22:58       ` Kevin Easton
2010-11-04 10:09 Marcus Meissner
2010-11-04 10:11 ` Tejun Heo
2010-11-04 11:46 ` Ingo Molnar
2010-11-04 12:29   ` Marcus Meissner
2010-11-04 13:58     ` Ingo Molnar
2010-11-04 14:11       ` Ingo Molnar
2010-11-04 14:33         ` Marcus Meissner
2010-11-04 14:38           ` Tejun Heo
2010-11-04 14:43             ` H. Peter Anvin
2010-11-04 14:48               ` Tejun Heo
2010-11-04 19:08           ` Ingo Molnar
2010-11-07 18:02           ` Andi Kleen
2010-11-07 18:32             ` H. Peter Anvin
2010-11-10  8:53               ` Ingo Molnar
2010-11-11  2:51                 ` H. Peter Anvin
2010-11-11  7:05                   ` Ingo Molnar
2010-11-05  2:38     ` Frank Rowand
2010-11-10 20:58       ` Jesper Juhl
2010-11-05  0:20 ` Jesper Juhl

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=20101130115851.GB9639@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=meissner@suse.de \
    --cc=sarah.a.sharp@linux.intel.com \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=w@1wt.eu \
    /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®