mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: some fixes to musl
Date: Sun, 24 Jul 2011 08:56:44 -0400	[thread overview]
Message-ID: <20110724125644.GJ132@brightrain.aerifal.cx> (raw)
In-Reply-To: <20110724093911.GB6076@albatros>

On Sun, Jul 24, 2011 at 01:39:11PM +0400, Vasiliy Kulikov wrote:
> > It should be obvious that a bogus LSM will create gaping security
> > holes if it's allowed such power.
> 
> I don't say such handling is perfect, just want to show it can be
> somehow justified:
> 
> Most of LSM hooks maintain some security context associated with
> file/task/socket/etc.  Some actions may require (re)allocation of this
> context.  If the allocation fails (e.g. OOM), it's wrong to allow the
> task to continue the work with the object, which has an outdated context
> (not updated against some recent activity).  So, unexpected ENOMEM is
> returned.

Are you saying that all operations on the associated object
(file/task/socket/etc.) are automatically first subjected to an LSM
hook? Or just that the LSM module author might set up a hook?

In the latter case, I would say it's a bug and potential gaping
vulnerability for a module to install a hook on any
resource-deallocation function.

If it's the former, I would say it's a bug and gaping security hole in
the whole LSM architecture. Failure to account for dependence of a
critical operation on resource allocation is a classic programming
error. To fix it, I would imagine the allocation either needs to be
moved to the action that caused (re)allocation to be needed, or LSM
hooks need to be skipped for resource deallocation functions, or LSM
hooks need to fallback to success rather than failure when resource
(re)allocation fails during a resource deallocation operation. But
since I'm not familiar with the LSM architecture, this is only
speculation.

In short, I think you've raised really good points, and LSM probably
needs an audit...

> I totally agree with you that injecting such faults where a program doesn't
> expect it is wrong, but sometimes it can be not obvious for kernel
> developers that it breaks something.

Not being aware that you're breaking something isn't a very good
excuse. In any case, following a principle of "deallocation cannot
fail" should not be too hard, and it's required for C++ RAII apps to
work anyway (what can you do if an operation fails during a
destructor?!)

> Even if they don't want to
> introduce such cases, it can be unintendedly introduced by a bug
> (e.g. sendmail setuid vulnerability).  Such bugs may be tricky to catch
> and may appear in very rare situations.  Trying to catch such cases would
> make the program much more robust against kernel bugs/changes (unless the
> error handling code complicates the whole logic and/or is not well
> tested).

I agree that it's better to check for failure and handle it where you
can. What bothers me is the creation of error cases that are usually
impossible to handle.

Rich


  reply	other threads:[~2011-07-24 12:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-21 17:02 Vasiliy Kulikov
2011-07-21 18:21 ` Rich Felker
2011-07-21 19:00   ` Solar Designer
2011-07-22  8:19     ` Vasiliy Kulikov
2011-07-22 13:30       ` Rich Felker
2011-07-21 19:17   ` Vasiliy Kulikov
2011-07-22  2:08     ` Rich Felker
2011-07-24  9:39       ` Vasiliy Kulikov
2011-07-24 12:56         ` Rich Felker [this message]
2011-07-24 18:38           ` Vasiliy Kulikov
2011-07-24  9:19   ` close(2) failure cases (was: some fixes to musl) Vasiliy Kulikov
2011-07-24 12:24     ` Rich Felker
2011-07-24 17:49       ` Vasiliy Kulikov
2011-07-24 22:29         ` Rich Felker
2011-07-25 17:36           ` Vasiliy Kulikov
2011-07-22  1:57 ` some fixes to musl Rich Felker
2011-07-22  4:30   ` Rich Felker
2011-07-22  8:26     ` 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=20110724125644.GJ132@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).