netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch net v2] smc: disallow TCP_ULP in smc_setsockopt()
@ 2021-05-05 19:40 Cong Wang
  2021-05-05 20:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Cong Wang @ 2021-05-05 19:40 UTC (permalink / raw)
  To: netdev
  Cc: linux-s390, Cong Wang, syzbot+b54a1ce86ba4a623b7f0,
	John Fastabend, Karsten Graul

From: Cong Wang <cong.wang@bytedance.com>

syzbot is able to setup kTLS on an SMC socket which coincidentally
uses sk_user_data too. Later, kTLS treats it as psock so triggers a
refcnt warning. The root cause is that smc_setsockopt() simply calls
TCP setsockopt() which includes TCP_ULP. I do not think it makes
sense to setup kTLS on top of SMC sockets, so we should just disallow
this setup.

It is hard to find a commit to blame, but we can apply this patch
since the beginning of TCP_ULP.

Reported-and-tested-by: syzbot+b54a1ce86ba4a623b7f0@syzkaller.appspotmail.com
Fixes: 734942cc4ea6 ("tcp: ULP infrastructure")
Cc: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
---
 net/smc/af_smc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index be3e80b3e27f..5eff7cccceff 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -2161,6 +2161,9 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
 	struct smc_sock *smc;
 	int val, rc;
 
+	if (level == SOL_TCP && optname == TCP_ULP)
+		return -EOPNOTSUPP;
+
 	smc = smc_sk(sk);
 
 	/* generic setsockopts reaching us here always apply to the
@@ -2185,7 +2188,6 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
 	if (rc || smc->use_fallback)
 		goto out;
 	switch (optname) {
-	case TCP_ULP:
 	case TCP_FASTOPEN:
 	case TCP_FASTOPEN_CONNECT:
 	case TCP_FASTOPEN_KEY:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch net v2] smc: disallow TCP_ULP in smc_setsockopt()
  2021-05-05 19:40 [Patch net v2] smc: disallow TCP_ULP in smc_setsockopt() Cong Wang
@ 2021-05-05 20:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-05-05 20:00 UTC (permalink / raw)
  To: Cong Wang
  Cc: netdev, linux-s390, cong.wang, syzbot+b54a1ce86ba4a623b7f0,
	john.fastabend, kgraul

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Wed,  5 May 2021 12:40:48 -0700 you wrote:
> From: Cong Wang <cong.wang@bytedance.com>
> 
> syzbot is able to setup kTLS on an SMC socket which coincidentally
> uses sk_user_data too. Later, kTLS treats it as psock so triggers a
> refcnt warning. The root cause is that smc_setsockopt() simply calls
> TCP setsockopt() which includes TCP_ULP. I do not think it makes
> sense to setup kTLS on top of SMC sockets, so we should just disallow
> this setup.
> 
> [...]

Here is the summary with links:
  - [net,v2] smc: disallow TCP_ULP in smc_setsockopt()
    https://git.kernel.org/netdev/net/c/8621436671f3

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-05-05 20:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05 19:40 [Patch net v2] smc: disallow TCP_ULP in smc_setsockopt() Cong Wang
2021-05-05 20: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;
as well as URLs for NNTP newsgroup(s).