public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: DJ Delorie <dj@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: nsswitch: do not reload if "/" changes
Date: Mon, 18 Jan 2021 11:47:36 +0100	[thread overview]
Message-ID: <87o8hmr06v.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <xnft2zvyho.fsf@greed.delorie.com> (DJ Delorie's message of "Sun,  17 Jan 2021 20:13:07 -0500")

* DJ Delorie:

>> I have one remaining question: Should we load service modules after /
>> has changed?  Disabling reloading brings us back to the old behavior in
>> terms of exposure to untrusted /, but maybe we can do even better and
>> stop loading service modules altogether?  Assuming that this change is
>> compatible with init systems.
>
> This patch makes it "no worse than before" but I'm not sure we can make
> it better than before, because we have no hints that we're entering a
> container, and by the time we have, it's too late to load the right
> module.  The options become (1) don't load the module and definitely
> fail, or (2) maybe load the module in the container and work (and,
> depending on your app, open a security hole?) (which is the "old way").
>
> We would either need a new API that says "about to enter container" (or
> hack into the namespace syscalls) or at least dlopen all mentioned
> modules when we parse nsswitch.conf

Are you concerned with the case that there are no NSS calls before
entering the container, so that we don't initialize anything at all?

> +  /* Before we reload, verify that "/" hasn't changed.  We assume that
> +     errors here are very unlikely, but the chance that we're entering
> +     a container is also very unlikely, so we err on the side of both
> +     very unlikely things not happening at the same time.  */
> +  if (__stat64 ("/", &str) == 0)

Hmm.  Upon second thought, I think this need to be made fail-closed by
disabling reload on stat failure.  The two things aren't as unrelated as
one might think (chroot + truning on some security filter doesn't seem
to be uncommon).  Now of course it's a bit unlikely that anything can be
loaded later if / can't be read, but is there a harm in macking this
explicity?

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill


  reply	other threads:[~2021-01-18 10:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-16  0:59 DJ Delorie
2021-01-16 10:52 ` Florian Weimer
2021-01-18  1:13   ` DJ Delorie
2021-01-18 10:47     ` Florian Weimer [this message]
2021-01-18 18:20       ` DJ Delorie
2021-01-19 16:37         ` Florian Weimer
2021-01-22 19:10           ` [v2] " DJ Delorie
2021-01-26  9:58             ` Florian Weimer
2021-01-26 16:19               ` DJ Delorie
2021-01-26 16:30                 ` Florian Weimer
2021-01-26 16:47                   ` DJ Delorie
2021-01-27 17:28                     ` Carlos O'Donell
2021-01-27 18:44                       ` DJ Delorie
2021-01-28  0:31                         ` Joseph Myers
2021-01-28  0:34                           ` DJ Delorie
2021-01-28  0:39                             ` Joseph Myers
2021-01-28  1:15                               ` DJ Delorie
2021-01-18 12:42 ` Andreas Schwab
2021-01-18 12:53   ` Florian Weimer
2021-01-18 18:27   ` DJ Delorie
2021-01-18 15:59 ` Carlos O'Donell
2021-01-18 16:53   ` Florian Weimer
2021-01-19 14:30     ` Carlos O'Donell
2021-01-19 14:40       ` Florian Weimer
2021-01-18 18:35   ` DJ Delorie

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=87o8hmr06v.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=dj@redhat.com \
    --cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).