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: Fri, 22 Dec 2023 11:25:13 +0700
From: Bagas Sanjaya <bagasdotme@...il.com>
To: Dmitry Safonov <dima@...sta.com>, Eric Dumazet <edumazet@...gle.com>,
	"David S. Miller" <davem@...emloft.net>,
	David Ahern <dsahern@...nel.org>, Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>
Cc: Dmitry Safonov <0x7f454c46@...il.com>,
	Linux Networking <netdev@...r.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	YouHong Li <liyouhong@...inos.cn>
Subject: Re: [PATCH] net/tcp_sigpool: Use kref_get_unless_zero()

On Fri, Dec 22, 2023 at 01:13:59AM +0000, Dmitry Safonov wrote:
> The freeing and re-allocation of algorithm are protected by cpool_mutex,
> so it doesn't fix an actual use-after-free, but avoids a deserved
> refcount_warn_saturate() warning.
> 
> A trivial fix for the racy behavior.
> 
> Fixes: 8c73b26315aa ("net/tcp: Prepare tcp_md5sig_pool for TCP-AO")
> Suggested-by: Eric Dumazet <edumazet@...gle.com>
> Signed-off-by: Dmitry Safonov <dima@...sta.com>
> ---
>  net/ipv4/tcp_sigpool.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/net/ipv4/tcp_sigpool.c b/net/ipv4/tcp_sigpool.c
> index 55b310a722c7..8512cb09ebc0 100644
> --- a/net/ipv4/tcp_sigpool.c
> +++ b/net/ipv4/tcp_sigpool.c
> @@ -162,9 +162,8 @@ int tcp_sigpool_alloc_ahash(const char *alg, size_t scratch_size)
>  		if (strcmp(cpool[i].alg, alg))
>  			continue;
>  
> -		if (kref_read(&cpool[i].kref) > 0)
> -			kref_get(&cpool[i].kref);
> -		else
> +		/* pairs with tcp_sigpool_release() */
> +		if (!kref_get_unless_zero(&cpool[i].kref))
>  			kref_init(&cpool[i].kref);
>  		ret = i;
>  		goto out;
> 
> ---
> base-commit: 1a44b0073b9235521280e19d963b6dfef7888f18
> change-id: 20231222-tcp-ao-kref_get_unless_zero-fe7105781ba4
> 

No observable regressions when booting the kernel with this patch applied.

Tested-by: Bagas Sanjaya <bagasdotme@...il.com>

-- 
An old man doll... just what I always wanted! - Clara

Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ