From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7006D3858D33; Wed, 22 May 2024 23:03:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7006D3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1716419022; bh=XpmhTTVs2Vxmugyc84DLLTXy5D5adjtaUuSNN5gksY8=; h=From:To:Subject:Date:From; b=P9Lx3Ez2J6CECskWOwb1D1BnJMfHxa9hUi+Svw7eEIZyZ+YwjalcgSGBzyXg0pXV/ daBUJYR64DeN9Ku9vasGxfyPeT7acuDFe4YHPuCWPfmL75jlkuILU0lBaUhKG7sCcV m4MKlusKeA0rQ1Jls/xAP7d4lOXb9/J4r4ViCCnQ= From: "m.novosyolov at rosalinux dot ru" To: glibc-bugs@sourceware.org Subject: [Bug nss/31791] New: [Regression] nss: memory for >8 elements in nsswitch.conf is not freed Date: Wed, 22 May 2024 23:03:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: nss X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: m.novosyolov at rosalinux dot ru X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31791 Bug ID: 31791 Summary: [Regression] nss: memory for >8 elements in nsswitch.conf is not freed Product: glibc Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: nss Assignee: unassigned at sourceware dot org Reporter: m.novosyolov at rosalinux dot ru Target Milestone: --- Add >8 elements into any line of /etc/nsswitch.conf , for example: hosts: files dns m3 m4 m5 m6 m7 m8 m9 Make a simple test program proga.c: #include #include #include int main (void) { struct group *g =3D getgrnam("users"); if (g !=3D NULL) { printf("%s\n", g->gr_name); } return 0; } Install gcc and ASAN sanitizer library if it is in a separate package, exam= ple for ROSA Linux: sudo dnf install gcc lib64asan-devel for Ubuntu: sudo apt install gcc Build that program with ASAN: gcc -fsanitize=3Daddress proga.c -o proga Run it: ./proga ASAN will report a memory leak: =3D=3D1011=3D=3DERROR: LeakSanitizer: detected memory leaks Direct leak of 208 byte(s) in 1 object(s) allocated from: #0 0x7fcf7e4fbb37 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x7fcf7e0afde3 in __libc_dynarray_emplace_enlarge (/lib/x86_64-linux-gnu/libc.so.6+0xafde3) (BuildId: 4d9090d61bf70e6b3225d583f0f08193f54670b2) #2 0x7fcf7e152239 (/lib/x86_64-linux-gnu/libc.so.6+0x152239) (BuildId: 4d9090d61bf70e6b3225d583f0f08193f54670b2) #3 0x7fcf7e1526f8 (/lib/x86_64-linux-gnu/libc.so.6+0x1526f8) (BuildId: 4d9090d61bf70e6b3225d583f0f08193f54670b2) #4 0x7fcf7e15062b in __nss_group_lookup2 (/lib/x86_64-linux-gnu/libc.so.6+0x15062b) (BuildId: 4d9090d61bf70e6b3225d583f0f08193f54670b2) #5 0x7fcf7e1562b8 in getgrnam_r (/lib/x86_64-linux-gnu/libc.so.6+0x1562= b8) (BuildId: 4d9090d61bf70e6b3225d583f0f08193f54670b2) #6 0x7fcf7e156157 in getgrnam (/lib/x86_64-linux-gnu/libc.so.6+0x156157) (BuildId: 4d9090d61bf70e6b3225d583f0f08193f54670b2) #7 0x7fcf7e4d0520 in getgrnam ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors= .inc:1922 #8 0x55d5ac172223 in main (/root/proga+0x1223) (BuildId: 71a7b40bd7a3e314f7d5bb5819561d156835cd45) #9 0x7fcf7e02a1c9 (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 4d9090d61bf70e6b3225d583f0f08193f54670b2) #10 0x7fcf7e02a28a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 4d9090d61bf70e6b3225d583f0f08193f54670b2) #11 0x55d5ac172144 in _start (/root/proga+0x1144) (BuildId: 71a7b40bd7a3e314f7d5bb5819561d156835cd45) SUMMARY: AddressSanitizer: 208 byte(s) leaked in 1 allocation(s). Now make <8 elements in that line of /etc/nsswitch.conf: hosts: files dns m3 m4 m5 m6 m7 And rerun: ./proga Memory leak will not be reported. __libc_dynarray_emplace_enlarge is called if default array size is not enou= gh. But then that additionally allocated memory is not freed. This happens with all recent versions of glibc, tested reporoduced on 2.33, 2.38 and 2.39. Tested glibc 2.31, there is NO memory leak there. I suspect that commit f8847d83e17774ed5e9c0f75ef693680b91bcae4 "nsswitch: u= se new internal API (core)" introduced this. https://github.com/bminor/glibc/commit/f8847d83e17774ed5e9c0f75ef693680b91b= cae4 Is it a feature or a bug? --=20 You are receiving this mail because: You are on the CC list for the bug.=