net/smc: Ensure correct state of the socket in send path
PATCH 1/1 net/smc: Ensure correct state of the socket in send path
From: Guvenc Gulce <[email protected]>
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().
--- net/smc/smc_tx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/smc/smc_tx.c +3 -2
@@ -154,6 +154,9 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len) goto out_err; } +if (sk->sk_state ==SMC_INIT ) +return -ENOTCONN ; +if (len > conn->sndbuf_desc->len)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);while (msg_data_left (msg)) { -if (sk->sk_state ==SMC_INIT ) -return -ENOTCONN ;if (smc->sk.sk_shutdown &SEND_SHUTDOWN || (smc->sk.sk_err ==ECONNABORTED ) || conn->killed)
Signature · 1 line
2.25.1
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Fri, 25 Jun 2021 17:11:02 +0200 you wrote:
From: Guvenc Gulce <[email protected]>
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 insmc_tx_sendmsg().[...]
Here is the summary with links:
- [net-next] net/smc: Ensure correct state of the socket in send path
https://git.kernel.org/netdev/net-next/c/17081633e22d
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html