From: Steffen Klassert <steffen.klassert@secunet.com>
To: Dong Chenchen <dongchenchen2@huawei.com>
Cc: <herbert@gondor.apana.org.au>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<horms@kernel.org>, <tpluszz77@gmail.com>,
<netdev@vger.kernel.org>, <zhangchangzhong@huawei.com>,
<xuchunxiao3@huawei.com>
Subject: Re: [PATCH net] xfrm: Fix dev use-after-free in xfrm async resumption
Date: Mon, 1 Jun 2026 08:32:58 +0200 [thread overview]
Message-ID: <ah0nmpeq6TNHtQqd@secunet.com> (raw)
In-Reply-To: <20260529092111.1089315-1-dongchenchen2@huawei.com>
On Fri, May 29, 2026 at 05:21:11PM +0800, Dong Chenchen wrote:
> xfrm async resumption hold skb->dev refcnt until after transport_finish.
> However, xfrm_rcv_cb may modify skb->dev to tunnel dev without taking
> device reference, such as vti_rcv_cb. The subsequent async resumption
> will decrement the tunnel device's reference count, which lead to uaf
> of tunnel dev and refcnt leak of orig dev as below:
>
> unregister_netdevice: waiting for vti1 to become free. Usage count = -2
>
> Release refcnt of the original dev after tunnel rcv modify skb->dev to
> fix it.
>
> Fixes: 1c428b038400 ("xfrm: hold dev ref until after transport_finish NF_HOOK")
> Reported-by: Xu Chunxiao <xuchunxiao3@huawei.com>
> Signed-off-by: Dong Chenchen <dongchenchen2@huawei.com>
> ---
> net/xfrm/xfrm_input.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
> index f65291eba1f6..c979872b6006 100644
> --- a/net/xfrm/xfrm_input.c
> +++ b/net/xfrm/xfrm_input.c
> @@ -467,6 +467,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
> {
> const struct xfrm_state_afinfo *afinfo;
> struct net *net = dev_net(skb->dev);
> + struct net_device *dev = skb->dev;
> int err;
> __be32 seq;
> __be32 seq_hi;
> @@ -730,6 +731,10 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
> if (err)
> goto drop;
>
> + if (async && skb->dev != dev) {
> + dev_put(dev);
> + async = 0;
> + }
> nf_reset_ct(skb);
>
> if (decaps) {
Sashiko found issues with this patch:
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260529092111.1089315-1-dongchenchen2%40huawei.com
Please review!
next prev parent reply other threads:[~2026-06-01 6:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 9:21 [PATCH net] xfrm: Fix dev use-after-free in xfrm async resumption Dong Chenchen
2026-06-01 6:32 ` Steffen Klassert [this message]
2026-06-01 12:17 ` dongchenchen (A)
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=ah0nmpeq6TNHtQqd@secunet.com \
--to=steffen.klassert@secunet.com \
--cc=davem@davemloft.net \
--cc=dongchenchen2@huawei.com \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tpluszz77@gmail.com \
--cc=xuchunxiao3@huawei.com \
--cc=zhangchangzhong@huawei.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