* [Patch net] smc: disallow TCP_ULP in smc_setsockopt()
@ 2021-04-10 18:17 Cong Wang
2021-04-12 6:52 ` Karsten Graul
2021-04-13 7:48 ` Karsten Graul
0 siblings, 2 replies; 4+ messages in thread
From: Cong Wang @ 2021-04-10 18:17 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 cause is that smc_setsockopt() simply calls
TCP setsockopt(). I do not think it makes sense to setup kTLS on
top of SMC, so we can just disallow this.
Reported-and-tested-by: syzbot+b54a1ce86ba4a623b7f0@syzkaller.appspotmail.com
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: 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 47340b3b514f..0d4d6d28f20c 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -2162,6 +2162,9 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
struct smc_sock *smc;
int val, rc;
+ if (optname == TCP_ULP)
+ return -EOPNOTSUPP;
+
smc = smc_sk(sk);
/* generic setsockopts reaching us here always apply to the
@@ -2186,7 +2189,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] 4+ messages in thread
* Re: [Patch net] smc: disallow TCP_ULP in smc_setsockopt()
2021-04-10 18:17 [Patch net] smc: disallow TCP_ULP in smc_setsockopt() Cong Wang
@ 2021-04-12 6:52 ` Karsten Graul
2021-04-12 19:09 ` Cong Wang
2021-04-13 7:48 ` Karsten Graul
1 sibling, 1 reply; 4+ messages in thread
From: Karsten Graul @ 2021-04-12 6:52 UTC (permalink / raw)
To: Cong Wang, netdev
Cc: linux-s390, Cong Wang, syzbot+b54a1ce86ba4a623b7f0, John Fastabend
On 10/04/2021 20:17, Cong Wang 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 cause is that smc_setsockopt() simply calls
> TCP setsockopt(). I do not think it makes sense to setup kTLS on
> top of SMC, so we can just disallow this.
>
> Reported-and-tested-by: syzbot+b54a1ce86ba4a623b7f0@syzkaller.appspotmail.com
> Cc: John Fastabend <john.fastabend@gmail.com>
> Cc: 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 47340b3b514f..0d4d6d28f20c 100644
> --- a/net/smc/af_smc.c
> +++ b/net/smc/af_smc.c
> @@ -2162,6 +2162,9 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
> struct smc_sock *smc;
> int val, rc;
>
> + if (optname == TCP_ULP)
> + return -EOPNOTSUPP;
> +
> smc = smc_sk(sk);
>
> /* generic setsockopts reaching us here always apply to the
> @@ -2186,7 +2189,6 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
> if (rc || smc->use_fallback)
> goto out;
> switch (optname) {
> - case TCP_ULP:
Should'nt it return -EOPNOTSUPP in that case, too?
> case TCP_FASTOPEN:
> case TCP_FASTOPEN_CONNECT:
> case TCP_FASTOPEN_KEY:
>
--
Karsten
(I'm a dude)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch net] smc: disallow TCP_ULP in smc_setsockopt()
2021-04-12 6:52 ` Karsten Graul
@ 2021-04-12 19:09 ` Cong Wang
0 siblings, 0 replies; 4+ messages in thread
From: Cong Wang @ 2021-04-12 19:09 UTC (permalink / raw)
To: Karsten Graul
Cc: Linux Kernel Network Developers, linux-s390, Cong Wang, syzbot,
John Fastabend
On Sun, Apr 11, 2021 at 11:52 PM Karsten Graul <kgraul@linux.ibm.com> wrote:
>
>
>
> On 10/04/2021 20:17, Cong Wang 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 cause is that smc_setsockopt() simply calls
> > TCP setsockopt(). I do not think it makes sense to setup kTLS on
> > top of SMC, so we can just disallow this.
> >
> > Reported-and-tested-by: syzbot+b54a1ce86ba4a623b7f0@syzkaller.appspotmail.com
> > Cc: John Fastabend <john.fastabend@gmail.com>
> > Cc: 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 47340b3b514f..0d4d6d28f20c 100644
> > --- a/net/smc/af_smc.c
> > +++ b/net/smc/af_smc.c
> > @@ -2162,6 +2162,9 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
> > struct smc_sock *smc;
> > int val, rc;
> >
> > + if (optname == TCP_ULP)
> > + return -EOPNOTSUPP;
> > +
> > smc = smc_sk(sk);
> >
> > /* generic setsockopts reaching us here always apply to the
> > @@ -2186,7 +2189,6 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
> > if (rc || smc->use_fallback)
> > goto out;
> > switch (optname) {
> > - case TCP_ULP:
>
> Should'nt it return -EOPNOTSUPP in that case, too?
I do not think I understand this. In case of TCP_ULP, we will
not even reach this switch case after my patch.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch net] smc: disallow TCP_ULP in smc_setsockopt()
2021-04-10 18:17 [Patch net] smc: disallow TCP_ULP in smc_setsockopt() Cong Wang
2021-04-12 6:52 ` Karsten Graul
@ 2021-04-13 7:48 ` Karsten Graul
1 sibling, 0 replies; 4+ messages in thread
From: Karsten Graul @ 2021-04-13 7:48 UTC (permalink / raw)
To: Cong Wang, netdev
Cc: linux-s390, Cong Wang, syzbot+b54a1ce86ba4a623b7f0, John Fastabend
On 10/04/2021 20:17, Cong Wang 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 cause is that smc_setsockopt() simply calls
> TCP setsockopt(). I do not think it makes sense to setup kTLS on
> top of SMC, so we can just disallow this.
>
> Reported-and-tested-by: syzbot+b54a1ce86ba4a623b7f0@syzkaller.appspotmail.com
> Cc: John Fastabend <john.fastabend@gmail.com>
> Cc: Karsten Graul <kgraul@linux.ibm.com>
> Signed-off-by: Cong Wang <cong.wang@bytedance.com>
> ---
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-04-13 7:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-10 18:17 [Patch net] smc: disallow TCP_ULP in smc_setsockopt() Cong Wang
2021-04-12 6:52 ` Karsten Graul
2021-04-12 19:09 ` Cong Wang
2021-04-13 7:48 ` Karsten Graul
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).