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 C43F8385802B for ; Tue, 26 Jan 2021 16:30:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C43F8385802B 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-103-fNQu9FQaNyi0q6gMUROwvQ-1; Tue, 26 Jan 2021 11:30:29 -0500 X-MC-Unique: fNQu9FQaNyi0q6gMUROwvQ-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 0D6908030A2 for ; Tue, 26 Jan 2021 16:30:28 +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 C453C5275D; Tue, 26 Jan 2021 16:30:26 +0000 (UTC) From: Florian Weimer To: DJ Delorie Cc: libc-alpha@sourceware.org Subject: Re: [v2] nsswitch: do not reload if "/" changes References: Date: Tue, 26 Jan 2021 17:30:23 +0100 In-Reply-To: (DJ Delorie's message of "Tue, 26 Jan 2021 11:19:02 -0500") Message-ID: <8735ynacf4.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=-6.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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: Tue, 26 Jan 2021 16:30:41 -0000 * DJ Delorie: > Florian Weimer writes: >> I still think you should disable (re)loading if __stat64 fails. > > Ok. > >> Maybe call __nss_module_disable_loading after releasing local->lock? > > Er, I already do? > > + __libc_lock_unlock (local->lock); > + __nss_module_disable_loading (); Ah, right. I was confused. > + /* 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 > + || (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; > + } 0 used to be a valid inode number for XFS, but I suspect a lot will break if / uses it. There are some style issues: + GRP(4), /* match */ + + pw = getpwnam("test1"); + gr = getgrnam("name4"); + chdir("/"); + pw = getpwnam("test2"); + gr = getgrnam("test3"); + pw = getpwnam("test1"); Comment formatting, trailing whitespace, missing space before '('. Rest looks okay. I assume the test fails in the expected way without the patch. 8-) 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