Message ID | 20241101163703.24927-1-ant.v.moryakov@gmail.com |
---|---|
State | Rejected |
Headers |
Return-Path: <elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CD56A3858428 for <patchwork@sourceware.org>; Fri, 1 Nov 2024 16:37:30 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id 3E0573858D28 for <elfutils-devel@sourceware.org>; Fri, 1 Nov 2024 16:37:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E0573858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3E0573858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::133 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730479041; cv=none; b=lKzERbugMNRAkfylXd44Wnu3zrMtadQFLjph8Iet8BsYqbTtRmeakmX4jh4ktaI6n+vezurafh2ByTg5m1VTcrMJjMtcSyZEcSPvPs/e3iVfNexhFqrbSutzbtZmHrZS5wCfvOau3xVOUFcrYo7g/tg1BB8RHY6ftZCu5uqiA2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730479041; c=relaxed/simple; bh=7kFKc39/gObX4vKmsheamQPvIjFwbX5HDZFijWKy0W4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=uoa7yRAwdt00SeL5f25mSJNsE//s+NQw5cRnoktzzmQFSWBczY8X9whq3j6U+qM6OPIeWJKDNScXLhqymHRH/biKTxIfYJXPecsezjJmxCjWv4iL5/AYp9I0IiAu/1J12+cCnp1tCo+tMLOuUJlOevkAwO86VY1SCLcnHowJq9I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-539ebb5a20aso2297353e87.2 for <elfutils-devel@sourceware.org>; Fri, 01 Nov 2024 09:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730479036; x=1731083836; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=m/YeD9cHwbNYZLB1IBQGR5FRBSgKObKXuuzXPD09KWg=; b=GtRTxG10x+9I9zoIIY33/TGUd1BzSim4l+XaeBG6gG5ufhouVgEz+kCpZwX/PbpleS riQUqQrdKnKn2CD7jeGBdHAqNZrkvpFCKvmIJZY65S3JQyBpRaEbszRs6bjweosSH7rQ ChAOT9GiRxS//8DfDURkzKteAiK02b5dfk7yZIilj35zjsFtA1Wr87sgFecSk2lNJGcT MAV/E7ftABxqKlBOg8k72SzPhktfiq1NPORI8YK9rsxFGQAf4SITLcySgjC/dZxMcNMt Km16AnY7rrAbhQunUBzfvGx7ss2i98Rjl4MeKRmGfkmt95QJAv7G/Rw9KY+SXxy66E7q ZomA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730479036; x=1731083836; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=m/YeD9cHwbNYZLB1IBQGR5FRBSgKObKXuuzXPD09KWg=; b=Nyi9Q8YdFkDDTsnm+lNjnM5co2HZCz2+m7qsN4zQiSTs6RP5LituKGSzleRHqpN1Am 3LvhGHln3JXsIgAeZ+QTwLRSQ7XnUpSEK3Lyo+YkkCZ0qjvv9OebygTMY/me0KOzqtap E3+sbne1/KWgk6RyoV73CtFMUt1LYZeeafoM+vcV007SRJkwWEn9hDGVzIzsR+ZaLd/u 2h0tbIqb328C0j5OdfsMJrFAR6Jb31c/xo/sYqRCA/Sk/PZGZNlW4taJ5CIxXlVgloci s57Ce8kP+cKxDJJ2cpTHKhgVFPyHbFnClrn8Y1apaRWQCIklWhWjmn+8bu7gMbqFyhzY ay6A== X-Gm-Message-State: AOJu0Yzobi3N1uAEQh9d8xdNbEikyKGZzSemh1SNengxwDNFjvG0fJ8P FC0VAycJaramBHUJPEo25H7sn8JC27cXZyYfYLGWDSrqClkiBfonnbHcWEufyXs= X-Google-Smtp-Source: AGHT+IGiQuScrqVGVwqnMYxlSFkK5s98p/S3pR9UAnoTALLplFp6URbkhfHm/5AdnWWvJKjnAvHfKw== X-Received: by 2002:a05:6512:280a:b0:535:6b9e:bcdd with SMTP id 2adb3069b0e04-53d65df3dbfmr2121286e87.33.1730479035743; Fri, 01 Nov 2024 09:37:15 -0700 (PDT) Received: from astra-student.rasu.local (109-252-122-202.nat.spd-mgts.ru. [109.252.122.202]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53c7bc958aasm606353e87.7.2024.11.01.09.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 09:37:15 -0700 (PDT) From: Anton Moryakov <ant.v.moryakov@gmail.com> To: elfutils-devel@sourceware.org Cc: Anton Moryakov <ant.v.moryakov@gmail.com>, Maks Mishin <maks.mishinFZ@gmail.com> Subject: [PATCH] debuginfod-client.c: add dlclose call to prevent resource leak Date: Fri, 1 Nov 2024 19:37:03 +0300 Message-Id: <20241101163703.24927-1-ant.v.moryakov@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list <elfutils-devel.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/elfutils-devel/> List-Post: <mailto:elfutils-devel@sourceware.org> List-Help: <mailto:elfutils-devel-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=subscribe> Errors-To: elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org |
Series |
debuginfod-client.c: add dlclose call to prevent resource leak
|
|
Commit Message
Anton Moryakov
Nov. 1, 2024, 4:37 p.m. UTC
Previously, the handle debuginfod_so created by dlopen was not closed
in all cases, leading to a potential resource leak. This commit adds an
additional dlclose call to ensure that the handle is always properly
released, whether the symbols are successfully loaded or not.
Found by RASU JSC.
Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
elfutils/libdwfl/debuginfod-client.c | 3 +++
1 file changed, 3 insertions(+)
Comments
Hi - On Fri, Nov 01, 2024 at 07:37:03PM +0300, Anton Moryakov wrote: > Previously, the handle debuginfod_so created by dlopen was not closed > in all cases, leading to a potential resource leak. This commit adds an > additional dlclose call to ensure that the handle is always properly > released, whether the symbols are successfully loaded or not. > > Found by RASU JSC. > > Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com> > --- a/elfutils/libdwfl/debuginfod-client.c > +++ b/elfutils/libdwfl/debuginfod-client.c > @@ -127,5 +127,8 @@ __libdwfl_debuginfod_init (void) > fp_debuginfod_end = NULL; > dlclose (debuginfod_so); > } > + else{ > + dlclose (debuginfod_so); > + } This code looks broken. This dlclose's the shared library even in the successful dlopen/dlsym case, so subsequent calls through the fp_* function pointers will all fail. How has this been tested?! - FChE
diff --git a/elfutils/libdwfl/debuginfod-client.c b/elfutils/libdwfl/debuginfod-client.c index ee604ad..8f67ecf 100644 --- a/elfutils/libdwfl/debuginfod-client.c +++ b/elfutils/libdwfl/debuginfod-client.c @@ -127,5 +127,8 @@ __libdwfl_debuginfod_init (void) fp_debuginfod_end = NULL; dlclose (debuginfod_so); } + else{ + dlclose (debuginfod_so); + } } }