Bugzilla – Full Text Bug Listing |
Summary: | VUL-0: CVE-2013-4357: glibc: another getaddrinfo stack overflow? | ||
---|---|---|---|
Product: | [Novell Products] SUSE Security Incidents | Reporter: | Marcus Meissner <meissner> |
Component: | Incidents | Assignee: | Andreas Schwab <schwab> |
Status: | RESOLVED FIXED | QA Contact: | Security Team bot <security-team> |
Severity: | Normal | ||
Priority: | P3 - Medium | CC: | BArendartchuk, jsegitz, meissner, pmadhan, skliu, vkijasev |
Version: | unspecified | Flags: | krahmer:
needinfo?
(skliu) |
Target Milestone: | --- | ||
Hardware: | Other | ||
OS: | Other | ||
Whiteboard: | maint:released:sle11-sp3:57442 maint:running:58715:important maint:released:sle11-sp2:58932 maint:running:60273:critical maint:running:60374:moderate maint:released:sle10-sp3:60378 maint:released:sle11-sp1:60377 maint:released:sle10-sp4:60380 CVSSv2:RedHat:CVE-2012-6686:4.3:(AV:N/AC:M/Au:N/C:N/I:N/A:P) CVSSv2:RedHat:CVE-2013-4357:4.3:(AV:N/AC:M/Au:N/C:N/I:N/A:P) | ||
Found By: | Security Response Team | Services Priority: | |
Business Priority: | Blocker: | --- | |
Marketing QA Status: | --- | IT Deployment: | --- |
Attachments: |
getaliasbyname.c
getaliasbyname_r.c getaddrinfo.c getservbyname.c getservbyport.c getservbyport_r.c glob.c getaddrinfo.c getaliasbyname.c getaliasbyname_r.c glob.c getservbyname.c getservbyname_r.c getservbyport.c getservbyport_r.c getservbyname.c getaddrinfo.c getaliasbyname.c getaliasbyname_r.c glob.c getservbyname_r.c getsrvbyport.c getservbyport_r.c bnc-844309.c getservbyname.c getaddrinfo.c getaliasbyname.c bnc-844309 test cases |
Description
Marcus Meissner
2013-10-07 14:36:47 UTC
bugbot adjusting priority See also <http://sourceware.org/bugzilla/show_bug.cgi?id=16071> and <http://sourceware.org/bugzilla/show_bug.cgi?id=16072>. The SWAMPID for this issue is 56533. This issue was rated as low. Please submit fixed packages until 2014-04-01. When done, please reassign the bug to security-team@suse.de. Patchinfo will be handled by security team. Affected packages: SLE-11-SP2: glibc.i686, glibc Created attachment 588864 [details]
getaliasbyname.c
gcc -o getaliasbyname getaliasbyname.c
./getaliasbyname 11000000
Created attachment 588865 [details]
getaliasbyname_r.c
gcc -o getaliasbyname_r getaliasbyname_r.c
./getaliasbyname_r 11000000
Created attachment 588866 [details]
getaddrinfo.c
gcc -o getaddrinfo getaddrinfo.c
./getaddrinfo 150000000
Created attachment 588867 [details]
getservbyname.c
gcc -g -o getservbyname getservbyname.c && ./getservbyname 150000000
Created attachment 588868 [details]
getservbyport.c
gcc -g -o getservbyport getservbyport.c && ./getservbyport 150000000
Created attachment 588869 [details]
getservbyport_r.c
gcc -g -o getservbyport_r getservbyport_r.c && ./getservbyport_r 15000000
Created attachment 588870 [details]
glob.c
gcc -o glob glob.c -g && ./glob 150000000
Hi Marcus, Thank you so much. I have executed the attached programs and there are still Segmentation = faults after update. for getaddrinfo.c (from comment 9): Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7b73c79 in nscd_getserv_r () from /lib64/libc.so.6 (gdb) bt #0 0x00007ffff7b73c79 in nscd_getserv_r () from /lib64/libc.so.6 #1 0x00007ffff7b7433b in __nscd_getservbyname_r () from /lib64/libc.so.6 #2 0x00007ffff7b5a44b in getservbyname_r@@GLIBC_2.2.5 () from /lib64/libc.= so.6 #3 0x00007ffff7b2823a in gaih_inet_serv () from /lib64/libc.so.6 #4 0x00007ffff7b28c68 in gaih_inet () from /lib64/libc.so.6 #5 0x00007ffff7b2bfc6 in getaddrinfo () from /lib64/libc.so.6 #6 0x000000000040077b in main () Bug is not in a resolved state so no need to reopen it. But we should reject the patch I think. (last comment was copy and paste from a mail from the QAler) #c9 is INVALID. what is invalid? just the missing \0 ? getaddrinfo comes into this codepath: 273 size_t keylen = strlen (name) + (protocol ? 1 + strlen (protocol) : 0); 274 char key[keylen + 1]; #1 0x00007fffee709d69 in _nss_nis_getservbyname_r (name=0x7fffeeb1f010 'A' <repeats 200 times>..., protocol=0x7ffff7b92d72 <gaih_inet_typeproto+50> "udp", serv=0x7fffffffd6e0, buffer=0x7fffffffd2b0 "# \n", buflen=1024, errnop=0x7ffff7fd06a8) at nss_nis/nis-service.c:277 277 char *cp = stpcpy (key, name); => dynamic stack allocation without bounds checking. getservbyname 150000000 runs into this codepath: nscd/nscd_getserv_r.c static int nscd_getserv_r (const char *crit, size_t critlen, const char *proto, request_type type, struct servent *resultbuf, char *buf, size_t buflen, struct servent **result) .. size_t protolen = proto == NULL ? 0 : strlen (proto); size_t keylen = critlen + 1 + protolen + 1; char *key = alloca (keylen); unbound alloca Created attachment 589738 [details]
getaddrinfo.c
added \0 terminator
Created attachment 589739 [details]
getaliasbyname.c
Created attachment 589740 [details]
getaliasbyname_r.c
Created attachment 589741 [details]
glob.c
Created attachment 589742 [details]
getservbyname.c
Created attachment 589743 [details]
getservbyname_r.c
Created attachment 589744 [details]
getservbyport.c
Created attachment 589745 [details]
getservbyport_r.c
Created attachment 589748 [details]
getservbyname.c
Remove stupidity.
Created attachment 589750 [details]
getaddrinfo.c
Remove stupidity.
Created attachment 589751 [details]
getaliasbyname.c
Remove stupidity.
Created attachment 589753 [details]
getaliasbyname_r.c
Remove stupidity.
Created attachment 589754 [details]
glob.c
Created attachment 589755 [details]
getservbyname_r.c
Created attachment 589756 [details]
getsrvbyport.c
Created attachment 589757 [details]
getservbyport_r.c
(In reply to comment #29) > Created an attachment (id=589750) [details] > getaddrinfo.c > > Remove stupidity. I have tried and I am receiving this: Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7ae9577 in mempcpy () from /lib64/libc.so.6 (gdb) bt #0 0x00007ffff7ae9577 in mempcpy () from /lib64/libc.so.6 #1 0x00007ffff7b73c4e in nscd_getserv_r () from /lib64/libc.so.6 #2 0x00007ffff7b7430b in __nscd_getservbyname_r () from /lib64/libc.so.6 #3 0x00007ffff7b5a41b in getservbyname_r@@GLIBC_2.2.5 () from /lib64/libc.so.6 #4 0x00007ffff7b2821a in gaih_inet_serv () from /lib64/libc.so.6 #5 0x00007ffff7b28c48 in gaih_inet () from /lib64/libc.so.6 #6 0x00007ffff7b2bfa6 in getaddrinfo () from /lib64/libc.so.6 #7 0x000000000040073e in main () (gdb) q ~/tmpglibc # rpm -qa|grep nscd nscd-2.11.3-17.60.1 libnscd-32bit-2.0.2-73.18 libnscd-2.0.2-73.18 :~/tmpglibc # rpm -qa|grep glibc glibc-profile-2.11.3-17.60.1 glibc-i18ndata-2.11.3-17.60.1 glibc-info-2.11.3-17.60.1 glibc-2.11.3-17.60.1 glibc-profile-32bit-2.11.3-17.60.1 glibc-devel-32bit-2.11.3-17.60.1 glibc-devel-2.11.3-17.60.1 glibc-html-2.11.3-17.60.1 glibc-32bit-2.11.3-17.60.1 glibc-locale-2.11.3-17.60.1 glibc-locale-32bit-2.11.3-17.60.1 nscd/nscd_getserv_r.c static int nscd_getserv_r still has an unbound alloca(): size_t protolen = proto == NULL ? 0 : strlen (proto); size_t keylen = critlen + 1 + protolen + 1; char *key = alloca (keylen); memcpy (__mempcpy (__mempcpy (key, crit, critlen), "/", 1), proto ?: "", protolen + 1); (In reply to comment #35) > Created an attachment (id=589757) [details] > getservbyport_r.c Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7b73c49 in nscd_getserv_r () from /lib64/libc.so.6 (gdb) bt #0 0x00007ffff7b73c49 in nscd_getserv_r () from /lib64/libc.so.6 #1 0x00007ffff7b74284 in __nscd_getservbyport_r () from /lib64/libc.so.6 #2 0x00007ffff7b5a822 in getservbyport_r@@GLIBC_2.2.5 () from /lib64/libc.so.6 #3 0x0000000000400721 in main (argc=2, argv=0x7fffffffe2e8) at bnc-844309-getservbyport_r2.c:46 (gdb) q (In reply to comment #34) > Created an attachment (id=589756) [details] > getsrvbyport.c :~/tmpglibc # gdb --args ./getservbyport 150000000 ... Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7ae9d22 in memcpy () from /lib64/libc.so.6 (gdb) bt #0 0x00007ffff7ae9d22 in memcpy () from /lib64/libc.so.6 #1 0x00007ffff7b73c60 in nscd_getserv_r () from /lib64/libc.so.6 #2 0x00007ffff7b74284 in __nscd_getservbyport_r () from /lib64/libc.so.6 #3 0x00007ffff7b5a822 in getservbyport_r@@GLIBC_2.2.5 () from /lib64/libc.so.6 #4 0x00007ffff7b5a5a2 in getservbyport () from /lib64/libc.so.6 #5 0x00000000004006ed in main (argc=2, argv=0x7fffffffe2e8) at bnc-844309-getservbyport2.c:45 (gdb) q (In reply to comment #33) > Created an attachment (id=589755) [details] > getservbyname_r.c ~/tmpglibc # gdb --args ./getservbyname_r 15000000 ... Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7b73c49 in nscd_getserv_r () from /lib64/libc.so.6 (gdb) bt #0 0x00007ffff7b73c49 in nscd_getserv_r () from /lib64/libc.so.6 #1 0x00007ffff7b7430b in __nscd_getservbyname_r () from /lib64/libc.so.6 #2 0x00007ffff7b5a41b in getservbyname_r@@GLIBC_2.2.5 () from /lib64/libc.so.6 #3 0x0000000000400721 in main (argc=2, argv=0x7fffffffe2e8) at bnc-844309-getservbyname_r2.c:36 (gdb) q (In reply to comment #32) > Created an attachment (id=589754) [details] > glob.c fletcher:~/tmpglibc # gdb --args ./glob 150000000 ... Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7ae9d56 in memcpy () from /lib64/libc.so.6 (gdb) bt #0 0x00007ffff7ae9d56 in memcpy () from /lib64/libc.so.6 #1 0x00007ffff7b102b9 in glob_in_dir () from /lib64/libc.so.6 #2 0x00007ffff7b10ef9 in glob64 () from /lib64/libc.so.6 #3 0x000000000040069f in main (argc=2, argv=0x7fffffffe2f8) at bnc-844309-glob2.c:19 (gdb) q This was OK on sled11sp3-i386 with the previoues version packages on rivers.qam.suse.de (sled11sp3-i386): glibc : 2.11.3-17.56.2 update needed (In reply to comment #30) > Created an attachment (id=589751) [details] > getaliasbyname.c > > Remove stupidity. OK, was OK with the older version as well. (In reply to comment #28) > Created an attachment (id=589748) [details] > getservbyname.c > > Remove stupidity. fletcher:~/tmpglibc # gdb --args ./getservbyname 150000000 ... Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7ae9d13 in memcpy () from /lib64/libc.so.6 (gdb) bt #0 0x00007ffff7ae9d13 in memcpy () from /lib64/libc.so.6 #1 0x00007ffff7b73c60 in nscd_getserv_r () from /lib64/libc.so.6 #2 0x00007ffff7b7430b in __nscd_getservbyname_r () from /lib64/libc.so.6 #3 0x00007ffff7b5a41b in getservbyname_r@@GLIBC_2.2.5 () from /lib64/libc.so.6 #4 0x00007ffff7b5a18b in getservbyname () from /lib64/libc.so.6 #5 0x00000000004006eb in main (argc=2, argv=0x7fffffffe2e8) at bnc-844309-getservbyname2.c:57 (gdb) q Affected packages: SLE-11-SP2: glibc, glibc.i686 (In reply to comment #2) > See also <http://sourceware.org/bugzilla/show_bug.cgi?id=16071> and > <http://sourceware.org/bugzilla/show_bug.cgi?id=16072>. Hi, do you have a reproducer for this one as well? I have prepared something (according http://sourceware.org/bugzilla/show_bug.cgi?id=16072), and there are still problems with AF_INET and AF_INET6 (AF_UNSPEC is OK) getaddrinfo: Memory allocation failure *** glibc detected *** ./bnc-844309: free(): invalid pointer: 0x0000000000652828 *** ======= Backtrace: ========= /lib64/libc.so.6(+0x76808)[0x7f77d4bbc808] /lib64/libc.so.6(cfree+0x6c)[0x7f77d4bc184c] /lib64/libc.so.6(freeaddrinfo+0x20)[0x7f77d4c098d0] ./bnc-844309[0x4008b4] ./bnc-844309[0x400b5f] /lib64/libc.so.6(__libc_start_main+0xe6)[0x7f77d4b64c16] ./bnc-844309[0x400709] ======= Memory map: ======== 00400000-00402000 r-xp 00000000 fd:02 715530 /root/tmpglibc/bnc-844309 00601000-00602000 r--p 00001000 fd:02 715530 /root/tmpglibc/bnc-844309 00602000-00603000 rw-p 00002000 fd:02 715530 /root/tmpglibc/bnc-844309 00603000-013e0000 rw-p 00000000 00:00 0 [heap] 7f7650000000-7f7650021000 rw-p 00000000 00:00 0 7f7650021000-7f7654000000 ---p 00000000 00:00 0 7f77d4723000-7f77d4738000 r-xp 00000000 fd:02 237654 /lib64/libgcc_s.so.1 7f77d4738000-7f77d4937000 ---p 00015000 fd:02 237654 /lib64/libgcc_s.so.1 7f77d4937000-7f77d4938000 r--p 00014000 fd:02 237654 /lib64/libgcc_s.so.1 7f77d4938000-7f77d4939000 rw-p 00015000 fd:02 237654 /lib64/libgcc_s.so.1 7f77d4939000-7f77d4945000 r-xp 00000000 fd:02 238020 /lib64/libnss_files-2.11.3.so 7f77d4945000-7f77d4b44000 ---p 0000c000 fd:02 238020 /lib64/libnss_files-2.11.3.so 7f77d4b44000-7f77d4b45000 r--p 0000b000 fd:02 238020 /lib64/libnss_files-2.11.3.so 7f77d4b45000-7f77d4b46000 rw-p 0000c000 fd:02 238020 /lib64/libnss_files-2.11.3.so 7f77d4b46000-7f77d4cb6000 r-xp 00000000 fd:02 237573 /lib64/libc-2.11.3.so 7f77d4cb6000-7f77d4eb5000 ---p 00170000 fd:02 237573 /lib64/libc-2.11.3.so 7f77d4eb5000-7f77d4eb9000 r--p 0016f000 fd:02 237573 /lib64/libc-2.11.3.so 7f77d4eb9000-7f77d4eba000 rw-p 00173000 fd:02 237573 /lib64/libc-2.11.3.so 7f77d4eba000-7f77d4ebf000 rw-p 00000000 00:00 0 7f77d4ebf000-7f77d4ede000 r-xp 00000000 fd:02 238075 /lib64/ld-2.11.3.so 7f77d509d000-7f77d50a0000 rw-p 00000000 00:00 0 7f77d50db000-7f77d50dd000 rw-p 00000000 00:00 0 7f77d50dd000-7f77d50de000 r--p 0001e000 fd:02 238075 /lib64/ld-2.11.3.so 7f77d50de000-7f77d50df000 rw-p 0001f000 fd:02 238075 /lib64/ld-2.11.3.so 7f77d50df000-7f77d50e0000 rw-p 00000000 00:00 0 7fff9e3db000-7fff9e3fc000 rw-p 00000000 00:00 0 [stack] 7fff9e3ff000-7fff9e400000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] Worksforme. (In reply to comment #46) > Worksforme. Hi Andreas, so it is good. And it means you have a reproducer; could you be so kind to attach it here? Reproducer for what?? (In reply to comment #48) > Reproducer for what?? https://sourceware.org/bugzilla/show_bug.cgi?id=16072 Adding a large number of IPv6 entries for a host in /etc/hosts and then querying it results in a segmentation fault. How reproducible: Always Steps to Reproduce: 1. Create 50K '127.0.0.1 host-fubar' entries, and 50K '::1 host-fubar' entries in '/etc/hosts'. 2. Call getaddrinfo for 'node' = "host-fubar", no 'flags' set, and AF_INET in 'hints->ai_family'. Which in my case looks like: hints.ai_family = AF_INET; error = getaddrinfo(hostname, NULL, &hints, &res); if (error) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(error)); } freeaddrinfo(res); How you tested it? Exactly like that, except omitting the ovious bug. (In reply to comment #50) > Exactly like that, except omitting the ovious bug. Which is ... Viktor, which of the attached reproducers are you using? If thats a different one, can you attach it here? I'll check the reproducer for mistakes. (In reply to comment #51) > Which is ... The missing else. Created attachment 591713 [details]
bnc-844309.c
adjusted testcase.
the bad pattern:
error = getaddrinfo(hostname, NULL, &hints, &res);
if (error)
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(error));
freeaddrinfo(res);
was changed to:
if (error)
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(error));
else
freeaddrinfo(res);
as "res" is invalid in the errorcase.
Created attachment 591861 [details]
getservbyname.c
replace by fixed version
Created attachment 591862 [details]
getaddrinfo.c
replace by actual working version
Created attachment 591863 [details]
getaliasbyname.c
replace by working version
(In reply to comment #54) Thanks a lot. Last confirmation is needed: Te issue referred to "Create 50K '127.0.0.1 host-fubar' entries, and 50K '::1 host-fubar' entries in '/etc/hosts'." With patch there is No SIGSEGV, no other problems. Just I am not able to process 50K ... entries, at most 45K (for both) on machine with 8GB RAM; usually there is an error: getaddrinfo: Memory allocation failure The case uses huge amount of memory. With valgrind I have not found any leak. Is this expected? running out of memory is expected, as there is no crash -> GOOD Affected packages: SLE-11-SP2: glibc, glibc.i686 Update released for: glibc, glibc-64bit, glibc-debuginfo, glibc-debuginfo-64bit, glibc-debugsource, glibc-devel, glibc-devel-64bit, glibc-html, glibc-i18ndata, glibc-info, glibc-locale, glibc-locale-64bit, glibc-obsolete, glibc-profile, glibc-profile-64bit, nscd Products: SLE-DEBUGINFO 11-SP3 (i386, ia64, ppc64, s390x, x86_64) SLE-DESKTOP 11-SP3 (i386, x86_64) SLE-SDK 11-SP3 (i386, x86_64) SLE-SERVER 11-SP3 (i386, ia64, ppc64, s390x, x86_64) SLES4VMWARE 11-SP3 (i386, x86_64) SUSE-SU-2014:0760-1: An update that solves two vulnerabilities and has four fixes is now available. Category: security (low) Bug References: 836746,844309,847227,854445,863499,872832 CVE References: CVE-2013-4357,CVE-2013-4458 Sources used: SUSE Linux Enterprise Software Development Kit 11 SP3 (src): glibc-2.11.3-17.62.1 SUSE Linux Enterprise Server 11 SP3 for VMware (src): glibc-2.11.3-17.62.1 SUSE Linux Enterprise Server 11 SP3 (src): glibc-2.11.3-17.62.1 SUSE Linux Enterprise Desktop 11 SP3 (src): glibc-2.11.3-17.62.1 Looks like all updates are released. Affected packages: SLE-11-SP2: glibc.i686 Affected packages: SLE-11-SP2: glibc.i686, glibc Which testcase is failing? SUSE-SU-2014:1129-1: An update that solves four vulnerabilities and has one errata is now available. Category: security (important) Bug References: 836746,844309,892073,894553,894556 CVE References: CVE-2012-6656,CVE-2013-4357,CVE-2014-5119,CVE-2014-6040 Sources used: SUSE Linux Enterprise Server 11 SP2 LTSS (src): glibc-2.11.3-17.45.53.1 SUSE-SU-2015:0164-1: An update that solves three vulnerabilities and has two fixes is now available. Category: security (moderate) Bug References: 844309,888860,894553,894556,909053 CVE References: CVE-2012-6656,CVE-2013-4357,CVE-2014-6040 Sources used: SUSE Linux Enterprise Server 11 SP1 LTSS (src): glibc-2.11.1-0.62.1 SUSE-SU-2015:0170-1: An update that solves three vulnerabilities and has one errata is now available. Category: security (moderate) Bug References: 844309,882600,894553,894556 CVE References: CVE-2012-6656,CVE-2013-4357,CVE-2014-6040 Sources used: SUSE Linux Enterprise Server 10 SP4 LTSS (src): glibc-2.4-31.115.2 I think we released all of them now. |