[PATCH] fix: do not leak file descriptor while reading /proc/mounts

38 views
Skip to first unread message

Hosgor, Tolga (CT RDA DS EU TR MTS)

unread,
Mar 25, 2019, 8:35:42 AM3/25/19
to efibootg...@googlegroups.com, Can ÜNSAL
From: Can ÜNSAL <can....@siemens.com>

When efibootguard is invoked to read environment variables with
ebg_env_open_current /proc/mounts file descriptor is opened in get_mountpoint
without closing it.

Signed-off-by: Can ÜNSAL <can....@siemens.com>
---
env/env_disk_utils.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/env/env_disk_utils.c b/env/env_disk_utils.c
index 9fad94b..78ad130 100644
--- a/env/env_disk_utils.c
+++ b/env/env_disk_utils.c
@@ -39,6 +39,7 @@ char *get_mountpoint(char *devpath)
if (!mntpoint) {
break;
}
+ endmntent(mtab);
return mntpoint;
}
}
--
2.11.0

Andreas Reichel

unread,
Mar 25, 2019, 8:47:49 AM3/25/19
to Hosgor, Tolga (CT RDA DS EU TR MTS), efibootg...@googlegroups.com, Can ÜNSAL
Ow.. thanks.

Acked-by: Andreas Reichel <andreas.r...@siemens.com>

> --
> 2.11.0
>
> --
> You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to efibootguard-d...@googlegroups.com.
> To post to this group, send email to efibootg...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20190325123539.109952-1-tolga.hosgor%40siemens.com.
> For more options, visit https://groups.google.com/d/optout.

--
Andreas Reichel
Dipl.-Phys. (Univ.)
Software Consultant

Andreas...@tngtech.com, +49-174-3180074
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterfoehring
Geschaeftsfuehrer: Henrik Klagges, Dr. Robert Dahlke, Gerhard Mueller
Sitz: Unterfoehring * Amtsgericht Muenchen * HRB 135082

Jan Kiszka

unread,
Mar 27, 2019, 5:41:35 AM3/27/19
to [ext] Andreas Reichel, Hosgor, Tolga (CT RDA DS EU TR MTS), efibootg...@googlegroups.com, Can ÜNSAL
On 25.03.19 13:45, [ext] Andreas Reichel wrote:
> On Mon, Mar 25, 2019 at 03:35:39PM +0300, Hosgor, Tolga (CT RDA DS EU TR MTS) wrote:
>> From: Can ÜNSAL <can....@siemens.com>
>>
>> When efibootguard is invoked to read environment variables with
>> ebg_env_open_current /proc/mounts file descriptor is opened in get_mountpoint
>> without closing it.
>>
>> Signed-off-by: Can ÜNSAL <can....@siemens.com>
>> ---
>> env/env_disk_utils.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/env/env_disk_utils.c b/env/env_disk_utils.c
>> index 9fad94b..78ad130 100644
>> --- a/env/env_disk_utils.c
>> +++ b/env/env_disk_utils.c
>> @@ -39,6 +39,7 @@ char *get_mountpoint(char *devpath)
>> if (!mntpoint) {
>> break;
>> }
>> + endmntent(mtab);
>> return mntpoint;
>> }
>> }
>
> Ow.. thanks.
>
> Acked-by: Andreas Reichel <andreas.r...@siemens.com>
>

Thanks, applied to next.

I will follow up with a refactoring of this function to avoid this duplication
(and the risk to leak).

Jan

--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
Reply all
Reply to author
Forward
0 new messages