* [PATCH net-next] net/smc: Ensure correct state of the socket in send path
@ 2021-06-25 15:11 Karsten Graul
2021-06-25 19:00 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Karsten Graul @ 2021-06-25 15:11 UTC (permalink / raw)
To: David Miller, Jakub Kicinski
Cc: netdev, linux-s390, Heiko Carstens, Guvenc Gulce
From: Guvenc Gulce <guvenc@linux.ibm.com>
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: e0e4b8fa5338 ("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>
---
net/smc/smc_tx.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c
index 075c4f4b41cf..289025cd545a 100644
--- a/net/smc/smc_tx.c
+++ b/net/smc/smc_tx.c
@@ -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)
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net/smc: Ensure correct state of the socket in send path
2021-06-25 15:11 [PATCH net-next] net/smc: Ensure correct state of the socket in send path Karsten Graul
@ 2021-06-25 19:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-25 19:00 UTC (permalink / raw)
To: Karsten Graul; +Cc: davem, kuba, netdev, linux-s390, hca, guvenc
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
On Fri, 25 Jun 2021 17:11:02 +0200 you wrote:
> From: Guvenc Gulce <guvenc@linux.ibm.com>
>
> 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().
>
> [...]
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-25 19:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-25 15:11 [PATCH net-next] net/smc: Ensure correct state of the socket in send path Karsten Graul
2021-06-25 19:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox