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 [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 44F63385042A for ; Tue, 26 Jan 2021 09:58:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 44F63385042A 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-192-Obweug3ROHuIHrmucBnrJw-1; Tue, 26 Jan 2021 04:58:22 -0500 X-MC-Unique: Obweug3ROHuIHrmucBnrJw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36A8D1005513 for ; Tue, 26 Jan 2021 09:58:21 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-113-35.ams2.redhat.com [10.36.113.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E6DC7770E; Tue, 26 Jan 2021 09:58:20 +0000 (UTC) From: Florian Weimer To: DJ Delorie via Libc-alpha Subject: Re: [v2] nsswitch: do not reload if "/" changes References: Date: Tue, 26 Jan 2021 10:58:18 +0100 In-Reply-To: (DJ Delorie via Libc-alpha's message of "Fri, 22 Jan 2021 14:10:43 -0500") Message-ID: <87ft2odnph.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.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-12.6 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_H4, 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: Tue, 26 Jan 2021 09:58:25 -0000 * DJ Delorie via Libc-alpha: > + /* 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) > + { > + if (local->root_ino != 0 > + && (str.st_ino != local->root_ino > + || str.st_dev != local->root_dev)) > + { > + /* Change detected; disable reloading. */ > + atomic_store_release (&local->data.reload_disabled, 1); > + __libc_lock_unlock (local->lock); > + __nss_module_disable_loading (); > + return true; > + } > + local->root_ino = str.st_ino; > + local->root_dev = str.st_dev; > + } I still think you should disable (re)loading if __stat64 fails. > __libc_lock_unlock (local->lock); > > /* Avoid overwriting the global configuration until we have loaded > diff --git a/nss/nss_module.c b/nss/nss_module.c > index 1a9359930d..6c5f341f3e 100644 > --- a/nss/nss_module.c > +++ b/nss/nss_module.c > @@ -349,6 +349,19 @@ __nss_disable_nscd (void (*cb) (size_t, struct traced_file *)) > } > #endif > > +/* Block attempts to dlopen any module we haven't already opened. */ > +void > +__nss_module_disable_loading (void) > +{ > + __libc_lock_lock (nss_module_list_lock); > + > + for (struct nss_module *p = nss_module_list; p != NULL; p = p->next) > + if (p->state == nss_module_uninitialized) > + p->state = nss_module_failed; > + > + __libc_lock_unlock (nss_module_list_lock); > +} Maybe call __nss_module_disable_loading after releasing local->lock? Although there should not be a risk of deadlocks in the current code because there aren't any relevant function calls while nss_module_list_lock is locked. 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