From: Bagas Sanjaya <bagasdotme@gmail.com>
To: Dmitry Safonov <dima@arista.com>,
Eric Dumazet <edumazet@google.com>,
"David S. Miller" <davem@davemloft.net>,
David Ahern <dsahern@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Dmitry Safonov <0x7f454c46@gmail.com>,
Linux Networking <netdev@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
YouHong Li <liyouhong@kylinos.cn>
Subject: Re: [PATCH] net/tcp_sigpool: Use kref_get_unless_zero()
Date: Fri, 22 Dec 2023 11:25:13 +0700 [thread overview]
Message-ID: <ZYUPqXO7VYJ79HMc@archie.me> (raw)
In-Reply-To: <20231222-tcp-ao-kref_get_unless_zero-v1-1-551c2edd0136@arista.com>
[-- Attachment #1: Type: text/plain, Size: 1459 bytes --]
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@google.com>
> Signed-off-by: Dmitry Safonov <dima@arista.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@gmail.com>
--
An old man doll... just what I always wanted! - Clara
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2023-12-22 4:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-22 1:13 [PATCH] net/tcp_sigpool: Use kref_get_unless_zero() Dmitry Safonov
2023-12-22 4:25 ` Bagas Sanjaya [this message]
2023-12-22 17:08 ` Eric Dumazet
2024-01-01 14:50 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZYUPqXO7VYJ79HMc@archie.me \
--to=bagasdotme@gmail.com \
--cc=0x7f454c46@gmail.com \
--cc=davem@davemloft.net \
--cc=dima@arista.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liyouhong@kylinos.cn \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).