public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [edk2-libc Patch 0/1] file descriptor leak in rename
@ 2023-08-22  3:21 Jayaprakash, N
  2023-08-22  3:21 ` [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: file descriptor leak in rename() Jayaprakash, N
  0 siblings, 1 reply; 3+ messages in thread
From: Jayaprakash, N @ 2023-08-22  3:21 UTC (permalink / raw)
  To: devel; +Cc: Jayaprakash N

This patch provides fix for the file descriptor leak issue in 
rename function from the LibC library of the StdLib of edk2-libc

Jayaprakash N (1):
  edk2-libc/StdLib: file descriptor leak in rename()

 StdLib/LibC/Uefi/Devices/UefiShell/daShell.c | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.40.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107941): https://edk2.groups.io/g/devel/message/107941
Mute This Topic: https://groups.io/mt/100888175/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: file descriptor leak in rename()
  2023-08-22  3:21 [edk2-devel] [edk2-libc Patch 0/1] file descriptor leak in rename Jayaprakash, N
@ 2023-08-22  3:21 ` Jayaprakash, N
  2023-08-22 17:46   ` Michael D Kinney
  0 siblings, 1 reply; 3+ messages in thread
From: Jayaprakash, N @ 2023-08-22  3:21 UTC (permalink / raw)
  To: devel; +Cc: Jayaprakash N, Rebecca Cran, Michael D Kinney, Kloper Dimitry

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4529

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 <rebecca@bsdio.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jayaprakash N <n.jayaprakash@intel.com>
Signed-off-by: Kloper Dimitry <dimitry.kloper@intel.com>
---
 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/Uefi/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 == EFI_SUCCESS) {
           // File has been successfully renamed.  We are DONE!
+          close(OldFd);
           return 0;
         }
         errno = EFI2errno( Status );
@@ -688,6 +689,7 @@ da_ShellRename(
     else {
       errno = ENOMEM;
     }
+    close(OldFd);
   }
   return -1;
 }
-- 
2.40.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
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/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: file descriptor leak in rename()
  2023-08-22  3:21 ` [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: file descriptor leak in rename() Jayaprakash, N
@ 2023-08-22 17:46   ` Michael D Kinney
  0 siblings, 0 replies; 3+ messages in thread
From: Michael D Kinney @ 2023-08-22 17:46 UTC (permalink / raw)
  To: Jayaprakash, N, devel@edk2.groups.io
  Cc: Rebecca Cran, Kloper, Dimitry, Kinney, Michael D

Reviewed-by: Michael D Kinney <michael.d.kinneyu@intel.com>



> -----Original Message-----
> From: Jayaprakash, N <n.jayaprakash@intel.com>
> Sent: Monday, August 21, 2023 8:22 PM
> To: devel@edk2.groups.io
> Cc: Jayaprakash, N <n.jayaprakash@intel.com>; Rebecca Cran
> <rebecca@bsdio.com>; Kinney, Michael D <michael.d.kinney@intel.com>;
> Kloper, Dimitry <dimitry.kloper@intel.com>
> Subject: [edk2-libc Patch 1/1] edk2-libc/StdLib: file descriptor leak in
> rename()
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4529
> 
> 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 <rebecca@bsdio.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Jayaprakash N <n.jayaprakash@intel.com>
> Signed-off-by: Kloper Dimitry <dimitry.kloper@intel.com>
> ---
>  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/Uefi/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 == EFI_SUCCESS) {
>            // File has been successfully renamed.  We are DONE!
> +          close(OldFd);
>            return 0;
>          }
>          errno = EFI2errno( Status );
> @@ -688,6 +689,7 @@ da_ShellRename(
>      else {
>        errno = ENOMEM;
>      }
> +    close(OldFd);
>    }
>    return -1;
>  }
> --
> 2.40.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107955): https://edk2.groups.io/g/devel/message/107955
Mute This Topic: https://groups.io/mt/100888179/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-22 17:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-22  3:21 [edk2-devel] [edk2-libc Patch 0/1] file descriptor leak in rename Jayaprakash, N
2023-08-22  3:21 ` [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: file descriptor leak in rename() Jayaprakash, N
2023-08-22 17:46   ` Michael D Kinney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox