Commit fef30d63 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net-smc-fixes-2021-11-24'

Karsten Graul says:

====================
net/smc: fixes 2021-11-24

Patch 1 from DaXing fixes a possible loop in smc_listen().
Patch 2 prevents a NULL pointer dereferencing while iterating
over the lower network devices.
====================

Link: https://lore.kernel.org/r/20211124123238.471429-1-kgraul@linux.ibm.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 06e5ba71 9ebb0c4b
...@@ -2134,8 +2134,10 @@ static int smc_listen(struct socket *sock, int backlog) ...@@ -2134,8 +2134,10 @@ static int smc_listen(struct socket *sock, int backlog)
smc->clcsock->sk->sk_user_data = smc->clcsock->sk->sk_user_data =
(void *)((uintptr_t)smc | SK_USER_DATA_NOCOPY); (void *)((uintptr_t)smc | SK_USER_DATA_NOCOPY);
rc = kernel_listen(smc->clcsock, backlog); rc = kernel_listen(smc->clcsock, backlog);
if (rc) if (rc) {
smc->clcsock->sk->sk_data_ready = smc->clcsk_data_ready;
goto out; goto out;
}
sk->sk_max_ack_backlog = backlog; sk->sk_max_ack_backlog = backlog;
sk->sk_ack_backlog = 0; sk->sk_ack_backlog = 0;
sk->sk_state = SMC_LISTEN; sk->sk_state = SMC_LISTEN;
......
...@@ -1672,14 +1672,26 @@ static void smc_link_down_work(struct work_struct *work) ...@@ -1672,14 +1672,26 @@ static void smc_link_down_work(struct work_struct *work)
mutex_unlock(&lgr->llc_conf_mutex); mutex_unlock(&lgr->llc_conf_mutex);
} }
/* Determine vlan of internal TCP socket. static int smc_vlan_by_tcpsk_walk(struct net_device *lower_dev,
* @vlan_id: address to store the determined vlan id into struct netdev_nested_priv *priv)
*/ {
unsigned short *vlan_id = (unsigned short *)priv->data;
if (is_vlan_dev(lower_dev)) {
*vlan_id = vlan_dev_vlan_id(lower_dev);
return 1;
}
return 0;
}
/* Determine vlan of internal TCP socket. */
int smc_vlan_by_tcpsk(struct socket *clcsock, struct smc_init_info *ini) int smc_vlan_by_tcpsk(struct socket *clcsock, struct smc_init_info *ini)
{ {
struct dst_entry *dst = sk_dst_get(clcsock->sk); struct dst_entry *dst = sk_dst_get(clcsock->sk);
struct netdev_nested_priv priv;
struct net_device *ndev; struct net_device *ndev;
int i, nest_lvl, rc = 0; int rc = 0;
ini->vlan_id = 0; ini->vlan_id = 0;
if (!dst) { if (!dst) {
...@@ -1697,20 +1709,9 @@ int smc_vlan_by_tcpsk(struct socket *clcsock, struct smc_init_info *ini) ...@@ -1697,20 +1709,9 @@ int smc_vlan_by_tcpsk(struct socket *clcsock, struct smc_init_info *ini)
goto out_rel; goto out_rel;
} }
priv.data = (void *)&ini->vlan_id;
rtnl_lock(); rtnl_lock();
nest_lvl = ndev->lower_level; netdev_walk_all_lower_dev(ndev, smc_vlan_by_tcpsk_walk, &priv);
for (i = 0; i < nest_lvl; i++) {
struct list_head *lower = &ndev->adj_list.lower;
if (list_empty(lower))
break;
lower = lower->next;
ndev = (struct net_device *)netdev_lower_get_next(ndev, &lower);
if (is_vlan_dev(ndev)) {
ini->vlan_id = vlan_dev_vlan_id(ndev);
break;
}
}
rtnl_unlock(); rtnl_unlock();
out_rel: out_rel:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment