From: Paolo Abeni <pabeni@redhat.com>
To: Antoine Tenart <atenart@kernel.org>,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
Steffen Klassert <steffen.klassert@secunet.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net] net: decrease cached dst counters in dst_release
Date: Thu, 3 Apr 2025 09:30:43 +0200 [thread overview]
Message-ID: <03151db3-61fe-478d-b91b-549d18648738@redhat.com> (raw)
In-Reply-To: <174358103232.4506.6967775691343340999@kwain>
Adding Steffen
On 4/2/25 10:03 AM, Antoine Tenart wrote:
> Quoting Paolo Abeni (2025-04-01 10:00:56)
>> On 3/26/25 6:36 PM, Antoine Tenart wrote:
>>>
>>> diff --git a/net/core/dst.c b/net/core/dst.c
>>> index 9552a90d4772..6d76b799ce64 100644
>>> --- a/net/core/dst.c
>>> +++ b/net/core/dst.c
>>> @@ -165,6 +165,14 @@ static void dst_count_dec(struct dst_entry *dst)
>>> void dst_release(struct dst_entry *dst)
>>> {
>>> if (dst && rcuref_put(&dst->__rcuref)) {
>>> +#ifdef CONFIG_DST_CACHE
>>> + if (dst->flags & DST_METADATA) {
>>> + struct metadata_dst *md_dst = (struct metadata_dst *)dst;
>>> +
>>> + if (md_dst->type == METADATA_IP_TUNNEL)
>>> + dst_cache_reset_now(&md_dst->u.tun_info.dst_cache);
>>
>> I think the fix is correct, but I'm wondering if we have a similar issue
>> for the METADATA_XFRM meta-dst. Isn't:
>>
>> dst_release(md_dst->u.xfrm_info.dst_orig);
>>
>> in metadata_dst_free() going to cause the same UaF? Why don't we need to
>> clean such dst here, too?
>
> I don't know much about XFRM but if the orig_dst doesn't have
> DST_NOCOUNT (which I guess is the case) you're right. Also Eric noted in
> ac888d58869b,
>
> """
> 1) in CONFIG_XFRM case, dst_destroy() can call
> dst_release_immediate(child), this might also cause UAF
> if the child does not have DST_NOCOUNT set.
> IPSEC maintainers might take a look and see how to address this.
> """
>
> but here I'm not sure if that is the case nor of the implications of
> moving that release.
>
> As the dst_orig one seems logical I can move it to dst_release too, but
> it seems a deeper look by XFRM experts would be needed in any way.
I also feel like the XFRM side needs some deeper look and the most
straight forward fix could have negative side effects, so I'm fine with
this patch dealing with dst_cache only.
@Steffen: could you please have a look at the possible UaF mentioned above?
Thanks,
Paolo
next prev parent reply other threads:[~2025-04-03 7:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 17:36 [PATCH net] net: decrease cached dst counters in dst_release Antoine Tenart
2025-04-01 8:00 ` Paolo Abeni
2025-04-02 8:03 ` Antoine Tenart
2025-04-03 7:30 ` Paolo Abeni [this message]
2025-04-03 11:15 ` 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=03151db3-61fe-478d-b91b-549d18648738@redhat.com \
--to=pabeni@redhat.com \
--cc=atenart@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.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