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.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
fef30d6371
@ -2134,8 +2134,10 @@ static int smc_listen(struct socket *sock, int backlog)
|
||||
smc->clcsock->sk->sk_user_data =
|
||||
(void *)((uintptr_t)smc | SK_USER_DATA_NOCOPY);
|
||||
rc = kernel_listen(smc->clcsock, backlog);
|
||||
if (rc)
|
||||
if (rc) {
|
||||
smc->clcsock->sk->sk_data_ready = smc->clcsk_data_ready;
|
||||
goto out;
|
||||
}
|
||||
sk->sk_max_ack_backlog = backlog;
|
||||
sk->sk_ack_backlog = 0;
|
||||
sk->sk_state = SMC_LISTEN;
|
||||
|
@ -1672,14 +1672,26 @@ static void smc_link_down_work(struct work_struct *work)
|
||||
mutex_unlock(&lgr->llc_conf_mutex);
|
||||
}
|
||||
|
||||
/* Determine vlan of internal TCP socket.
|
||||
* @vlan_id: address to store the determined vlan id into
|
||||
*/
|
||||
static int smc_vlan_by_tcpsk_walk(struct net_device *lower_dev,
|
||||
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)
|
||||
{
|
||||
struct dst_entry *dst = sk_dst_get(clcsock->sk);
|
||||
struct netdev_nested_priv priv;
|
||||
struct net_device *ndev;
|
||||
int i, nest_lvl, rc = 0;
|
||||
int rc = 0;
|
||||
|
||||
ini->vlan_id = 0;
|
||||
if (!dst) {
|
||||
@ -1697,20 +1709,9 @@ int smc_vlan_by_tcpsk(struct socket *clcsock, struct smc_init_info *ini)
|
||||
goto out_rel;
|
||||
}
|
||||
|
||||
priv.data = (void *)&ini->vlan_id;
|
||||
rtnl_lock();
|
||||
nest_lvl = ndev->lower_level;
|
||||
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;
|
||||
}
|
||||
}
|
||||
netdev_walk_all_lower_dev(ndev, smc_vlan_by_tcpsk_walk, &priv);
|
||||
rtnl_unlock();
|
||||
|
||||
out_rel:
|
||||
|
Loading…
x
Reference in New Issue
Block a user