[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iLo-8gw=jEF6ixie0Nn87f+2Zot-GTwRTbbK_4rNznGWw@mail.gmail.com>
Date: Wed, 17 Sep 2025 07:18:21 -0700
From: Eric Dumazet <edumazet@...gle.com>
To: Kuniyuki Iwashima <kuniyu@...gle.com>
Cc: "David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Kuniyuki Iwashima <kuni1840@...il.com>, netdev@...r.kernel.org,
syzbot+ea28e9d85be2f327b6c6@...kaller.appspotmail.com,
"D. Wythe" <alibuda@...ux.alibaba.com>, Dust Li <dust.li@...ux.alibaba.com>,
Sidraya Jayagond <sidraya@...ux.ibm.com>, Wenjia Zhang <wenjia@...ux.ibm.com>,
Mahanta Jambigi <mjambigi@...ux.ibm.com>, Tony Lu <tonylu@...ux.alibaba.com>,
Wen Gu <guwen@...ux.alibaba.com>, Ursula Braun <ubraun@...ux.ibm.com>,
Hans Wippel <hwippel@...ux.ibm.com>
Subject: Re: [PATCH v2 net-next 1/7] smc: Fix use-after-free in __pnet_find_base_ndev().
On Tue, Sep 16, 2025 at 2:48 PM Kuniyuki Iwashima <kuniyu@...gle.com> wrote:
>
> syzbot reported use-after-free of net_device in __pnet_find_base_ndev(),
> which was called during connect(). [0]
>
> smc_pnet_find_ism_resource() fetches sk_dst_get(sk)->dev and passes
> down to pnet_find_base_ndev(), where RTNL is held. Then, UAF happened
> at __pnet_find_base_ndev() when the dev is first used.
>
> This means dev had already been freed before acquiring RTNL in
> pnet_find_base_ndev().
>
> While dev is going away, dst->dev could be swapped with blackhole_netdev,
> and the dev's refcnt by dst will be released.
>
> We must hold dev's refcnt before calling smc_pnet_find_ism_resource().
>
> Also, smc_pnet_find_roce_resource() has the same problem.
>
> Let's use __sk_dst_get() and dst_dev_rcu() in the two functions.
>
> Fixes: 0afff91c6f5e ("net/smc: add pnetid support")
> Fixes: 1619f770589a ("net/smc: add pnetid support for SMC-D and ISM")
> Reported-by: syzbot+ea28e9d85be2f327b6c6@...kaller.appspotmail.com
> Closes: https://lore.kernel.org/netdev/68c237c7.050a0220.3c6139.0036.GAE@google.com/
> Signed-off-by: Kuniyuki Iwashima <kuniyu@...gle.com>
Reviewed-by: Eric Dumazet <edumazet@...gle.com>
Powered by blists - more mailing lists