Skip to content

Commit 8621436

Browse files
Cong Wangdavem330
authored andcommitted
smc: disallow TCP_ULP in smc_setsockopt()
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: 734942c ("tcp: ULP infrastructure") Cc: John Fastabend <[email protected]> Signed-off-by: Karsten Graul <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2c16db6 commit 8621436

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/smc/af_smc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2161,6 +2161,9 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
21612161
struct smc_sock *smc;
21622162
int val, rc;
21632163

2164+
if (level == SOL_TCP && optname == TCP_ULP)
2165+
return -EOPNOTSUPP;
2166+
21642167
smc = smc_sk(sk);
21652168

21662169
/* generic setsockopts reaching us here always apply to the
@@ -2185,7 +2188,6 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
21852188
if (rc || smc->use_fallback)
21862189
goto out;
21872190
switch (optname) {
2188-
case TCP_ULP:
21892191
case TCP_FASTOPEN:
21902192
case TCP_FASTOPEN_CONNECT:
21912193
case TCP_FASTOPEN_KEY:

0 commit comments

Comments
 (0)