mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 18:09:56 +00:00
smc: Use __sk_dst_get() and dst_dev_rcu() in smc_clc_prfx_match().
[ Upstream commit235f81045c] 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_get() and dst_dev_rcu(). Note that the returned value of smc_clc_prfx_match() is not used in the caller. Fixes:a046d57da1("smc: CLC handshake (incl. preparation steps)") Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20250916214758.650211-4-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
0736993bfe
commit
d26e80f7fb
@@ -657,26 +657,26 @@ 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;
|
||||
struct dst_entry *dst;
|
||||
int rc;
|
||||
|
||||
if (!dst) {
|
||||
rc = -ENOTCONN;
|
||||
rcu_read_lock();
|
||||
|
||||
dst = __sk_dst_get(clcsock->sk);
|
||||
dev = dst ? dst_dev_rcu(dst) : NULL;
|
||||
if (!dev) {
|
||||
rc = -ENODEV;
|
||||
goto out;
|
||||
}
|
||||
if (!dst->dev) {
|
||||
rc = -ENODEV;
|
||||
goto out_rel;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user