From nobody Wed May 15 14:35:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+107942+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+107942+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1692674528; cv=none; d=zohomail.com; s=zohoarc; b=LYDe0lxiuWXTNiSoyzGfFQETITSU6AsNTT+m9YUPCiSdBEhw4QuSon5edtHBIGJKYj+S6+4vaoA2MlJlftIL3Matfv8AKPVms3UGZIYK65UDZgx1lS5EMQpPCGPXGyXa78xMYgDs+E2FoFFk2JY+TALwhifkeJJvhtBvPr1iLqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692674528; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=OESO2U2aV70vvhXwsoKNYqtMLcHal6uAUcoZFCn5dBI=; b=RpmtREyvfRtEZg20oeOVyShXAbJu3XnY3kvWKgWj6frV1IPPQoNWblFDFbAswLlCMYNBJr9WWLbKqMWEq+e51KmqrADdfVGhm1v5Z+78KQOncMu0h57B3bXTdvyvGV6MU3oG0VpzYgw/jT63W9iWfq2EYsVSsa6a291m0s1v5i8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+107942+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1692674528183958.5123596429615; Mon, 21 Aug 2023 20:22:08 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=6JndfEg+WyIASk2dS+epfFojkiL/O+y+kaS2+24q4l4=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1692674527; v=1; b=HqfgZiLRZv5bc9l1v8+0I7t06TVI58SUNp96B26UwRkBOn9c7f6xmbnRtrhfm7WsHzewNpKF EtQIt1eTDPF2lb1qBUEDifIfyKP6Z4O+SjlgPXcOLY4Nhm/sv1FTChTs/6yuXb6derttBi7Fry7 AXDDnbwrviQN1TiTqYjW/9hw= X-Received: by 127.0.0.2 with SMTP id aPaJYY1788612xuZySCVcJCj; Mon, 21 Aug 2023 20:22:07 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.700.1692674524445818488 for ; Mon, 21 Aug 2023 20:22:07 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="354093272" X-IronPort-AV: E=Sophos;i="6.01,191,1684825200"; d="scan'208";a="354093272" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2023 20:22:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="826173466" X-IronPort-AV: E=Sophos;i="6.01,191,1684825200"; d="scan'208";a="826173466" X-Received: from njayapra-mobl.gar.corp.intel.com ([10.67.145.115]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2023 20:22:05 -0700 From: "Jayaprakash, N" To: devel@edk2.groups.io Cc: Jayaprakash N , Rebecca Cran , Michael D Kinney , Kloper Dimitry Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: file descriptor leak in rename() Date: Tue, 22 Aug 2023 08:51:54 +0530 Message-Id: <20230822032154.2009-2-n.jayaprakash@intel.com> In-Reply-To: <20230822032154.2009-1-n.jayaprakash@intel.com> References: <20230822032154.2009-1-n.jayaprakash@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,n.jayaprakash@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: U95egl478KNesLwKKRzxCYppx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1692674530608100003 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4529 rename() call leads to a function that makes open() for source file to be renamed. The resulting file descriptor is never closed. If you have to rename a couple of files this will quickly exhaust the descriptor table. The fix is trivial - just close the fd before returning from the function. Cc: Rebecca Cran Cc: Michael D Kinney Cc: Jayaprakash N Signed-off-by: Kloper Dimitry Reviewed-by: Michael D Kinney --- StdLib/LibC/Uefi/Devices/UefiShell/daShell.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c b/StdLib/LibC/Uef= i/Devices/UefiShell/daShell.c index 861765e..06fcc3b 100644 --- a/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c +++ b/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c @@ -670,6 +670,7 @@ da_ShellRename( free(NewFileInfo); if(Status =3D=3D EFI_SUCCESS) { // File has been successfully renamed. We are DONE! + close(OldFd); return 0; } errno =3D EFI2errno( Status ); @@ -688,6 +689,7 @@ da_ShellRename( else { errno =3D ENOMEM; } + close(OldFd); } return -1; } --=20 2.40.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107942): https://edk2.groups.io/g/devel/message/107942 Mute This Topic: https://groups.io/mt/100888179/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-