Bug 13895 - SIGSEGV in __nss_lookup_function for static binary when configured with --enable-static-nss
Summary: SIGSEGV in __nss_lookup_function for static binary when configured with --ena...
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Paul Pluzhnikov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-23 17:07 UTC by Paul Pluzhnikov
Modified: 2014-06-26 13:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
proposed patch (350 bytes, text/plain)
2012-03-23 17:07 UTC, Paul Pluzhnikov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Pluzhnikov 2012-03-23 17:07:00 UTC
Created attachment 6299 [details]
proposed patch

Original report:
http://sourceware.org/ml/libc-alpha/2012-03/msg00080.html

Reproduces with current git:
commit 3ff4252677ff55a0dd4ded5b5cbccda25812ba12
Author: Paul Pluzhnikov <ppluzhnikov@google.com>
Date:   Fri Mar 23 09:47:03 2012 -0700

cat t.c

#include <sys/types.h>
#include <pwd.h>

int main()
{
  struct passwd *pw = getpwnam("root");
  return 0;
}

gcc -g -L. -static t.c
gdb -q ./a.out

Reading symbols from /tmp/build-static-nss/a.out...done.
(gdb) r

Program received signal SIGSEGV, Segmentation fault.
0x0000000000410878 in __nss_lookup_function (ni=0x6e5f50, fct_name=0x4af0df "getpwnam_r") at nsswitch.c:460
460                 size_t namlen = (5 + strlen (ni->library->name) + 1
(gdb) bt
#0  0x0000000000410878 in __nss_lookup_function (ni=0x6e5f50, fct_name=0x4af0df "getpwnam_r") at nsswitch.c:460
#1  0x0000000000410a6e in __nss_lookup (ni=0x7fffffffd4e8, fct_name=0x4af0df "getpwnam_r", fct2_name=0x0, fctp=0x7fffffffd4e0) at nsswitch.c:161
#2  0x000000000040e416 in __getpwnam_r (name=0x4abf84 "root", resbuf=0x6e0ce0, buffer=0x6e5840 "", buflen=1024, result=0x7fffffffd538) at ../nss/getXXbyYY_r.c:202
#3  0x000000000040e12c in getpwnam (name=0x4abf84 "root") at ../nss/getXXbyYY.c:116
#4  0x0000000000400e76 in main () at t.c:6
(gdb) p ni.library
$1 = (service_library *) 0x0
(gdb) p ni.name
$2 = 0x6e5f80 "files"