mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 20:53:53 +08:00
net/smc: Ensure correct state of the socket in send path
When smc_sendmsg() is called before the SMC socket initialization has
completed, smc_tx_sendmsg() will access un-initialized fields of the
SMC socket which results in a null-pointer dereference.
Fix this by checking the socket state first in smc_tx_sendmsg().
Fixes: e0e4b8fa53
("net/smc: Add SMC statistics support")
Reported-by: syzbot+5dda108b672b54141857@syzkaller.appspotmail.com
Reviewed-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Guvenc Gulce <guvenc@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
4e3db44a24
commit
17081633e2
@ -154,6 +154,9 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len)
|
|||||||
goto out_err;
|
goto out_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sk->sk_state == SMC_INIT)
|
||||||
|
return -ENOTCONN;
|
||||||
|
|
||||||
if (len > conn->sndbuf_desc->len)
|
if (len > conn->sndbuf_desc->len)
|
||||||
SMC_STAT_RMB_TX_SIZE_SMALL(smc, !conn->lnk);
|
SMC_STAT_RMB_TX_SIZE_SMALL(smc, !conn->lnk);
|
||||||
|
|
||||||
@ -164,8 +167,6 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len)
|
|||||||
SMC_STAT_INC(smc, urg_data_cnt);
|
SMC_STAT_INC(smc, urg_data_cnt);
|
||||||
|
|
||||||
while (msg_data_left(msg)) {
|
while (msg_data_left(msg)) {
|
||||||
if (sk->sk_state == SMC_INIT)
|
|
||||||
return -ENOTCONN;
|
|
||||||
if (smc->sk.sk_shutdown & SEND_SHUTDOWN ||
|
if (smc->sk.sk_shutdown & SEND_SHUTDOWN ||
|
||||||
(smc->sk.sk_err == ECONNABORTED) ||
|
(smc->sk.sk_err == ECONNABORTED) ||
|
||||||
conn->killed)
|
conn->killed)
|
||||||
|
Loading…
Reference in New Issue
Block a user