lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 08 Feb 2024 13:45:08 +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] tc: Fix descriptor leak in get_qdisc_kind()

Maks Mishin <maks.mishinfz@...il.com> writes:

> Add closure of fd `dlh` and fix incorrect comparison of `dlh` with NULL.
>
> Found by RASU JSC

What is this tool? It seems to be giving you bad advice.

> Signed-off-by: Maks Mishin <maks.mishinFZ@...il.com>
> ---
>  tc/tc.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tc/tc.c b/tc/tc.c
> index 575157a8..162700b2 100644
> --- a/tc/tc.c
> +++ b/tc/tc.c
> @@ -112,7 +112,7 @@ struct qdisc_util *get_qdisc_kind(const char *str)
>  
>  	snprintf(buf, sizeof(buf), "%s/q_%s.so", get_tc_lib(), str);
>  	dlh = dlopen(buf, RTLD_LAZY);
> -	if (!dlh) {
> +	if (dlh != NULL) {

if (!dlh) seems to be the preferred style in the iproute2 codebase, with
2000+ occurrences.

>  		/* look in current binary, only open once */
>  		dlh = BODY;
>  		if (dlh == NULL) {
> @@ -124,6 +124,9 @@ struct qdisc_util *get_qdisc_kind(const char *str)
>  
>  	snprintf(buf, sizeof(buf), "%s_qdisc_util", str);
>  	q = dlsym(dlh, buf);
> +	if (dlh != NULL)
> +		dlclose(dlh);

Incorrect placement of dlclose() before sym q gets dereferenced.

> +
>  	if (q == NULL)
>  		goto noexist;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ