[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iK7pyiZV6gUWiqYMdWn1iZfOQM4De4=VxrWYBa=wrPESw@mail.gmail.com>
Date: Wed, 10 Sep 2025 22:57:17 -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,
"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.vnet.ibm.com>
Subject: Re: [PATCH v1 net 4/8] smc: Use sk_dst_dev_rcu() in smc_clc_prfx_match().
On Wed, Sep 10, 2025 at 8:06 PM Kuniyuki Iwashima <kuniyu@...gle.com> wrote:
>
> smc_clc_prfx_match() is called from smc_listen_work() and
> not under RCU nor RTNL.
>
> Using sk_dst_get(sk)->dev could trigger UAF.
>
> Let's use sk_dst_dev_rcu().
>
> Fixes: a046d57da19f ("smc: CLC handshake (incl. preparation steps)")
> Signed-off-by: Kuniyuki Iwashima <kuniyu@...gle.com>
> ---
> Cc: "D. Wythe" <alibuda@...ux.alibaba.com>
> Cc: Dust Li <dust.li@...ux.alibaba.com>
> Cc: Sidraya Jayagond <sidraya@...ux.ibm.com>
> Cc: Wenjia Zhang <wenjia@...ux.ibm.com>
> Cc: Mahanta Jambigi <mjambigi@...ux.ibm.com>
> Cc: Tony Lu <tonylu@...ux.alibaba.com>
> Cc: Wen Gu <guwen@...ux.alibaba.com>
> Cc: Ursula Braun <ubraun@...ux.vnet.ibm.com>
> ---
> net/smc/smc_clc.c | 24 +++++++++++-------------
> 1 file changed, 11 insertions(+), 13 deletions(-)
>
> diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
> index 9aa1d75d3079..5b4fe2c22879 100644
> --- a/net/smc/smc_clc.c
> +++ b/net/smc/smc_clc.c
> @@ -655,26 +655,24 @@ static int smc_clc_prfx_match6_rcu(struct net_device *dev,
> int smc_clc_prfx_match(struct socket *clcsock,
> struct smc_clc_msg_proposal_prefix *prop)
> {
> - struct dst_entry *dst = sk_dst_get(clcsock->sk);
> + struct net_device *dev;
> int rc;
>
> - if (!dst) {
> - rc = -ENOTCONN;
> - goto out;
> - }
> - if (!dst->dev) {
> + rcu_read_lock();
> +
> + dev = sk_dst_dev_rcu(clcsock->sk);
> + if (!dev) {
> rc = -ENODEV;
> - goto out_rel;
> + goto out;
> }
> - rcu_read_lock();
> +
> if (!prop->ipv6_prefixes_cnt)
> - rc = smc_clc_prfx_match4_rcu(dst->dev, prop);
> + rc = smc_clc_prfx_match4_rcu(dev, prop);
> else
> - rc = smc_clc_prfx_match6_rcu(dst->dev, prop);
> - rcu_read_unlock();
> -out_rel:
> - dst_release(dst);
> + rc = smc_clc_prfx_match6_rcu(dev, prop);
> out:
> + rcu_read_unlock();
> +
> return rc;
> }
I had in my tree a smaller patch without a new helper. I am not
convinced we need another one yet.
Powered by blists - more mailing lists