Skip to contentSkip to conversation

smc: disallow TCP_ULP in smc_setsockopt()

PATCH Applied Cong Wang 2 participants 2 messages May 5, 2021

Subsystems (4)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH v2 1/1 smc: disallow TCP_ULP in smc_setsockopt()

From: Cong Wang <[email protected]>

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 [email protected]
Fixes 734942cc4ea6 ("tcp: ULP infrastructure")
Cc John Fastabend <[email protected]>
---
 net/smc/af_smc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/smc/af_smc.c +3 -1
index be3e80b3e27f..5eff7cccceff 100644
@@ -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:
Signature · 1 line
2.25.1
#1 lore raw
This patch was applied to netdev/net.git (refs/heads/master):

Hello:

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

Quoted 10 lines · On Wed, 5 May 2021 12:40:48 -0700 you wrote:

From: Cong Wang <[email protected]>

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