OSDN Git Service

smc: disallow TCP_ULP in smc_setsockopt()
authorCong Wang <cong.wang@bytedance.com>
Wed, 5 May 2021 19:40:48 +0000 (12:40 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 May 2021 08:59:44 +0000 (10:59 +0200)
commitbb101fb44caa73a7ff5bc24df2fd49d9602d88f1
tree621f9b1a16ae85631cc03172bf5f2827d9c62e05
parent4f21d7eb214b4751b8d285a248bbc26439fd407b
smc: disallow TCP_ULP in smc_setsockopt()

[ Upstream commit 8621436671f3a4bba5db57482e1ee604708bf1eb ]

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/smc/af_smc.c