[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <m28r3vt7jg.fsf@gmail.com>
Date: Thu, 08 Feb 2024 13:22:27 +0000
From: Donald Hunter <donald.hunter@...il.com>
To: Maks Mishin <maks.mishinfz@...il.com>
Cc: Stephen Hemminger <stephen@...workplumber.org>, netdev@...r.kernel.org
Subject: Re: [PATCH] genl: Fix descriptor leak in get_genl_kind()
Maks Mishin <maks.mishinfz@...il.com> writes:
> Signed-off-by: Maks Mishin <maks.mishinFZ@...il.com>
The subject should say [PATCH iproute2] or [PATCH iproute2-next] since
it targets that project.
> ---
> genl/genl.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/genl/genl.c b/genl/genl.c
> index 85cc73bb..74100dad 100644
> --- a/genl/genl.c
> +++ b/genl/genl.c
> @@ -71,6 +71,9 @@ static struct genl_util *get_genl_kind(const char *str)
> snprintf(buf, sizeof(buf), "%s_genl_util", str);
>
> f = dlsym(dlh, buf);
> + if (dlh != NULL)
> + dlclose(dlh);
This is broken. If the earlier dlopen() actually loaded a .so then this
dlclose() will close it again, before f gets used. When f gets
dereferenced later, the program will crash. If this works at all, it is
because dlopen(NULL, ...) returns a handle to the main program, so
dlclose() doesn't unload it.
My assumption is that the author is leaving resources to be released at
program exit. It is a short-lived command line utility after all.
> +
> if (f == NULL)
> goto noexist;
> reg:
Powered by blists - more mailing lists