From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id C35EA385802A for ; Sat, 16 Jan 2021 10:52:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C35EA385802A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-125-vDrUaAINMIuo1vPBjc9EDw-1; Sat, 16 Jan 2021 05:52:42 -0500 X-MC-Unique: vDrUaAINMIuo1vPBjc9EDw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 129A21800D41 for ; Sat, 16 Jan 2021 10:52:41 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-69.ams2.redhat.com [10.36.112.69]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A8505C1A1; Sat, 16 Jan 2021 10:52:39 +0000 (UTC) From: Florian Weimer To: DJ Delorie via Libc-alpha Subject: Re: nsswitch: do not reload if "/" changes References: Date: Sat, 16 Jan 2021 11:52:38 +0100 In-Reply-To: (DJ Delorie via Libc-alpha's message of "Fri, 15 Jan 2021 19:59:12 -0500") Message-ID: <87pn25nog9.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jan 2021 10:52:46 -0000 * DJ Delorie via Libc-alpha: > diff --git a/nss/nss_database.c b/nss/nss_database.c > index e719ec0865..580ea7b963 100644 > --- a/nss/nss_database.c > +++ b/nss/nss_database.c > @@ -33,6 +33,11 @@ struct nss_database_state > { > struct nss_database_data data; > __libc_lock_define (, lock); > + /* If "/" changes, we switched into a container and do NOT want to > + reload anything. This data must be persistent across > + reloads. */ > + ino64_t root_ino; > + ino64_t root_dev; > }; dev_t for root_dev? > @@ -53,6 +58,8 @@ global_state_allocate (void *closure) > memset (result->data.services, 0, sizeof (result->data.services)); > result->data.initialized = true; > result->data.reload_disabled = false; > + result->root_ino = 0; > + result->root_dev = 0; > __libc_lock_init (result->lock); > } Perhaps you can match the declaration order in the initialization? > diff --git a/nss/nss_database.h b/nss/nss_database.h > index 1f827e6def..f94c629174 100644 > --- a/nss/nss_database.h > +++ b/nss/nss_database.h > @@ -75,6 +75,10 @@ struct nss_database_data > nss_action_list services[NSS_DATABASE_COUNT]; > int reload_disabled; /* Actually bool; int for atomic access. */ > bool initialized; > + /* If "/" changes, we switched into a container and do NOT want to > + reload anything. */ > + ino64_t root_ino; > + ino64_t root_dev; > }; > > /* Called by fork in the parent process, before forking. */ This does not seem to be needed? Rest looks good. 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. 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