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 [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B24453858D20 for ; Sun, 11 Feb 2024 12:04:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B24453858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B24453858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707653073; cv=none; b=UOI5Nga3GrOvQkTUNh5lJrQjcYtCbY6Op/Qh8KUODfxmlc1IQ7UiqbmB9w63qswghbr7LK5PQhjPOJ75fgmkBQvnjSWHe/piVc1DH4o1rXXeI3M559ROrnUABhF1aZF2lO0d2oKhBxIVPwwcXEH+QD2kVgDmu6YQynu8BDQkj5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707653073; c=relaxed/simple; bh=dxWFEoNeFEejY7lo6HSxYx6l4eUUaP5AGKGLgoJw6Xo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lHlawuA4grNyLq33hS3yta3stfAK3tBjpH0jZtr5iFfMDOjcHEimnXiIW2xOPvGr/j6DDBBhpTK8JIoRE25YA0Nn1c0b3o1NcYjKu7BKDRSaV6Aw3vBgNMdvpryRF9FFP1hAyXEEFU1qwzTCwc3KhwYIwbI41fkuyvzbiHnm1+Y= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707653071; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q6Px22rfTgCsl1lC/dLY3i69bK/VDUMdz8BMASneJZc=; b=JVQYPtvubcbIrg0GWPrvcQ+iKj336peyzOypE14VKYuijR3VUXpXt93ZxSw33fxG6uDKeS i0YNRP7iWBEABYsnkwFEtLky2WTleX8A/U7Z2kyvBze0vEVCDxIR3ohe+FfbG1qQ/AyVGD yv5JsNL3QRoe24KkcvdDvwhqXX/Y2fc= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-267-vfUsmAeFPouLMV2r7M29XA-1; Sun, 11 Feb 2024 07:04:28 -0500 X-MC-Unique: vfUsmAeFPouLMV2r7M29XA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA00C1C04196; Sun, 11 Feb 2024 12:04:27 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A52EC04326; Sun, 11 Feb 2024 12:04:26 +0000 (UTC) From: Florian Weimer To: Charalampos Mitrodimas via Libc-help Cc: Charalampos Mitrodimas Subject: Re: Potential Memory Leak in libc DNS Resolution Functions References: <5a2a1ca4-ebcb-45ea-9b55-ba3f890478b1@posteo.net> Date: Sun, 11 Feb 2024 13:04:25 +0100 In-Reply-To: <5a2a1ca4-ebcb-45ea-9b55-ba3f890478b1@posteo.net> (Charalampos Mitrodimas via Libc-help's message of "Sat, 10 Feb 2024 15:22:16 +0000") Message-ID: <87zfw7yzp2.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Charalampos Mitrodimas via Libc-help: > I've encountered a potential memory leak in libc, specifically within > the DNS resolution functions, as identified by Valgrind. The leak > involves __libc_alloc_buffer_allocate and related functions. Here's the > Valgrind output snippet: > > =C2=A0=C2=A0 =3D=3D4151=3D=3D 156 bytes in 1 blocks are definitely lost i= n loss record > 730 of 1,029 > =C2=A0=C2=A0 =3D=3D4151=3D=3D=C2=A0=C2=A0=C2=A0 at 0x4848899: malloc (in > /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) > =C2=A0=C2=A0 =3D=3D4151=3D=3D=C2=A0=C2=A0=C2=A0 by 0x4D15048: __libc_allo= c_buffer_allocate > (alloc_buffer_allocate.c:26) > =C2=A0=C2=A0 =3D=3D4151=3D=3D=C2=A0=C2=A0=C2=A0 by 0x4DBDC65: alloc_buffe= r_allocate (alloc_buffer.h:143) > =C2=A0=C2=A0 =3D=3D4151=3D=3D=C2=A0=C2=A0=C2=A0 by 0x4DBDC65: __resolv_co= nf_allocate (resolv_conf.c:391) > =C2=A0=C2=A0 =3D=3D4151=3D=3D=C2=A0=C2=A0=C2=A0 by 0x4DB8D0A: __resolv_co= nf_load (res_init.c:599) This is unfortunately not very illuminating because the struct resolv_conf functions are reference-counted. If there's a counter management bug somewhere, it would be reported like this by valgrind. > This issue arose in an application using Rust's email library Lettre, > ultimately traced back to libc during DNS resolution. Could you please > advise if this is a known issue and recommend any steps to address it? > I'm willing to contribute a fix, but want to make sure this is of > concern for the libc team, before starting the investigation. I don't recall a problem like this being reported before. Can you reproduce it on a recent glibc version? We have some cases of known/intended leaks (if the memory that can be leaked is bounded for the life-time of the process), but that doesn't apply here. It certainly looks like something we'd want to fix. Thanks, Florian