This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix for crash in NSS when libc built with--enable-static-nss and exe built with -static


On Sun, Mar 18, 2012 at 6:58 AM, Joseph S. Myers
<joseph@codesourcery.com> wrote:

> Once the underlying change to make static NSS is in you should file a bug
> report in Bugzilla for the present issue, if there isn't one already.

Bug filed: http://sourceware.org/bugzilla/show_bug.cgi?id=13895

> You're evidently familiar with this code, ...

Sadly, I am not. As far as I can tell, this code goes all the way back
to this original commit (5f0e6fc7):

+Sun Jun 23 19:42:05 1996  Ulrich Drepper  <drepper@cygnus.com>
+
...
+       * nss/Makefile, nss/XXX-lookup.c, nss/file-lookup.c,
+       nss/getXXbyYY.c, nss/getXXbyYY_r.c, nss/getXXent.c,
+       nss/getXXent_r.c, nss/host-lookup.c, nss/network-lookup.c,
+       nss/nsswitch.c, nss/nsswitch.h, nss/proto-lookup.c,
+       nss/service-lookup.c: New files.  Implementation of name
+       service switch, following the approach in Solaris.

> Could you explain what the various values (ni->library->name, ni->name,
> fct_name) are supposed to be here (both for static-nss and the normal
> case), and why, therefore, the new code is correct and the old code isn't?

In the SHARED or !DO_STATIC_NSS case, ni->library is initialized by
nss_load_library, and as far as I can tell, ni->library->name is always
set to ni->name.

In the DO_STATIC_NSS case, nss_load_library is not called, and ni->library
stays NULL.

This suggests that we could replace all uses of ni->library->name with
ni->name and get rid of an extra memory reference.

I've added an "assert(ni->name == ni->library->name)" and ran "make check"
(both with and without --enable-static-nss), which didn't show any failures.

> Would the change ever have any effect for the normal (non-static-nss) case?

The original patch only touched code that is in the else clause of
"#if !defined DO_STATIC_NSS || defined SHARED"

Updated patch (attached) does change non-static-nss case, and also adds
a test case.

Thanks,
-- 
Paul Pluzhnikov

2012-03-26  Paul Pluzhnikov  <ppluzhnikov@google.com>

	[BZ #13895]
	* nss/nsswitch.c (nss_load_library, __nss_lookup_function): Avoid
	extra indirection.
	* nss/Makefile (tests-static, tests): Add tst-nss-static.
	* nss/tst-nss-static.c: New.

Attachment: glibc-crash-static-nss-20120326.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]