diff mbox series

mptcp: remove tcp ulp setsockopt support

Message ID 20211205192700.25396-1-fw@strlen.de (mailing list archive)
State Accepted, archived
Commit 13dc812544f714e3e47d71e307f00ee6ffdebb7a
Delegated to: Matthieu Baerts
Headers show
Series mptcp: remove tcp ulp setsockopt support | expand

Checks

Context Check Description
matttbe/build success Build and static analysis OK
matttbe/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
matttbe/KVM_Validation__normal warning Unstable: 1 failed test(s): packetdrill_add_addr
matttbe/KVM_Validation__debug warning Unstable: 2 failed test(s): packetdrill_mp_join selftest_mptcp_join

Commit Message

Florian Westphal Dec. 5, 2021, 7:27 p.m. UTC
TCP_ULP setsockopt cannot be used for mptcp because its already
used internally to plumb subflow (tcp) sockets to the mptcp layer.

syzbot managed to trigger a crash for mptcp connections that are
in fallback mode:

KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027]
CPU: 1 PID: 1083 Comm: syz-executor.3 Not tainted 5.16.0-rc2-syzkaller #0
RIP: 0010:tls_build_proto net/tls/tls_main.c:776 [inline]
[..]
 __tcp_set_ulp net/ipv4/tcp_ulp.c:139 [inline]
 tcp_set_ulp+0x428/0x4c0 net/ipv4/tcp_ulp.c:160
 do_tcp_setsockopt+0x455/0x37c0 net/ipv4/tcp.c:3391
 mptcp_setsockopt+0x1b47/0x2400 net/mptcp/sockopt.c:638

Remove support for TCP_ULP setsockopt.

Reported-by: syzbot+1fd9b69cde42967d1add@syzkaller.appspotmail.com
Signed-off-by: Florian Westphal <fw@strlen.de>
---

Comments

Matthieu Baerts Dec. 6, 2021, 9:44 a.m. UTC | #1
Hi Florian,

(without netdev and syzbot ML)

On 05/12/2021 20:27, Florian Westphal wrote:
> TCP_ULP setsockopt cannot be used for mptcp because its already
> used internally to plumb subflow (tcp) sockets to the mptcp layer.
> 
> syzbot managed to trigger a crash for mptcp connections that are
> in fallback mode:
> 
> KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027]
> CPU: 1 PID: 1083 Comm: syz-executor.3 Not tainted 5.16.0-rc2-syzkaller #0
> RIP: 0010:tls_build_proto net/tls/tls_main.c:776 [inline]
> [..]
>  __tcp_set_ulp net/ipv4/tcp_ulp.c:139 [inline]
>  tcp_set_ulp+0x428/0x4c0 net/ipv4/tcp_ulp.c:160
>  do_tcp_setsockopt+0x455/0x37c0 net/ipv4/tcp.c:3391
>  mptcp_setsockopt+0x1b47/0x2400 net/mptcp/sockopt.c:638
> 
> Remove support for TCP_ULP setsockopt.

Good catch!
Indeed, it doesn't make sense to support TCP_ULP.

> Reported-by: syzbot+1fd9b69cde42967d1add@syzkaller.appspotmail.com
> Signed-off-by: Florian Westphal <fw@strlen.de>

I guess we need a Fixes tag here:

Fixes: d9e4c1291810 ("mptcp: only admit explicitly supported sockopt")

BTW, did you send this patch to netdev ML on purpose?
I guess this is fine but they will probably ask for the Fixes tag as it
looks like a bug-fix. Do you want me to reply to this email on netdev
and include this "Fixes" tag in my email?

Cheers,
Matt
Florian Westphal Dec. 6, 2021, 10:58 a.m. UTC | #2
Matthieu Baerts <matthieu.baerts@tessares.net> wrote:
> BTW, did you send this patch to netdev ML on purpose?

Yes, it was a reply to syzbot report.

> I guess this is fine but they will probably ask for the Fixes tag as it
> looks like a bug-fix. Do you want me to reply to this email on netdev
> and include this "Fixes" tag in my email?

I think it can go in via mptcp tree.
This patch is fine but there is still another ULP bug left, will send a
patch soon.
Jakub Kicinski Dec. 6, 2021, 3:53 p.m. UTC | #3
On Sun,  5 Dec 2021 20:27:00 +0100 Florian Westphal wrote:
> TCP_ULP setsockopt cannot be used for mptcp because its already
> used internally to plumb subflow (tcp) sockets to the mptcp layer.
> 
> syzbot managed to trigger a crash for mptcp connections that are
> in fallback mode:

Fallback mode meaning ops are NULL? I'm slightly confused by this
report.

> KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027]
> CPU: 1 PID: 1083 Comm: syz-executor.3 Not tainted 5.16.0-rc2-syzkaller #0
> RIP: 0010:tls_build_proto net/tls/tls_main.c:776 [inline]
> [..]
>  __tcp_set_ulp net/ipv4/tcp_ulp.c:139 [inline]
>  tcp_set_ulp+0x428/0x4c0 net/ipv4/tcp_ulp.c:160
>  do_tcp_setsockopt+0x455/0x37c0 net/ipv4/tcp.c:3391
>  mptcp_setsockopt+0x1b47/0x2400 net/mptcp/sockopt.c:638
> 
> Remove support for TCP_ULP setsockopt.
> 
> Reported-by: syzbot+1fd9b69cde42967d1add@syzkaller.appspotmail.com
> Signed-off-by: Florian Westphal <fw@strlen.de>
Jakub Kicinski Dec. 6, 2021, 3:55 p.m. UTC | #4
On Mon, 6 Dec 2021 07:53:26 -0800 Jakub Kicinski wrote:
> On Sun,  5 Dec 2021 20:27:00 +0100 Florian Westphal wrote:
> > TCP_ULP setsockopt cannot be used for mptcp because its already
> > used internally to plumb subflow (tcp) sockets to the mptcp layer.
> > 
> > syzbot managed to trigger a crash for mptcp connections that are
> > in fallback mode:  
> 
> Fallback mode meaning ops are NULL? I'm slightly confused by this
> report.

Ah, it's the socket not the ops.

> > KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027]
> > CPU: 1 PID: 1083 Comm: syz-executor.3 Not tainted 5.16.0-rc2-syzkaller #0
> > RIP: 0010:tls_build_proto net/tls/tls_main.c:776 [inline]
> > [..]
> >  __tcp_set_ulp net/ipv4/tcp_ulp.c:139 [inline]
> >  tcp_set_ulp+0x428/0x4c0 net/ipv4/tcp_ulp.c:160
> >  do_tcp_setsockopt+0x455/0x37c0 net/ipv4/tcp.c:3391
> >  mptcp_setsockopt+0x1b47/0x2400 net/mptcp/sockopt.c:638
> > 
> > Remove support for TCP_ULP setsockopt.
> > 
> > Reported-by: syzbot+1fd9b69cde42967d1add@syzkaller.appspotmail.com
> > Signed-off-by: Florian Westphal <fw@strlen.de>
Mat Martineau Dec. 6, 2021, 6:44 p.m. UTC | #5
On Mon, 6 Dec 2021, Jakub Kicinski wrote:

> On Mon, 6 Dec 2021 07:53:26 -0800 Jakub Kicinski wrote:
>> On Sun,  5 Dec 2021 20:27:00 +0100 Florian Westphal wrote:
>>> TCP_ULP setsockopt cannot be used for mptcp because its already
>>> used internally to plumb subflow (tcp) sockets to the mptcp layer.
>>>
>>> syzbot managed to trigger a crash for mptcp connections that are
>>> in fallback mode:
>>
>> Fallback mode meaning ops are NULL? I'm slightly confused by this
>> report.
>
> Ah, it's the socket not the ops.
>
>>> KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027]
>>> CPU: 1 PID: 1083 Comm: syz-executor.3 Not tainted 5.16.0-rc2-syzkaller #0
>>> RIP: 0010:tls_build_proto net/tls/tls_main.c:776 [inline]
>>> [..]
>>>  __tcp_set_ulp net/ipv4/tcp_ulp.c:139 [inline]
>>>  tcp_set_ulp+0x428/0x4c0 net/ipv4/tcp_ulp.c:160
>>>  do_tcp_setsockopt+0x455/0x37c0 net/ipv4/tcp.c:3391
>>>  mptcp_setsockopt+0x1b47/0x2400 net/mptcp/sockopt.c:638
>>>
>>> Remove support for TCP_ULP setsockopt.
>>>
>>> Reported-by: syzbot+1fd9b69cde42967d1add@syzkaller.appspotmail.com
>>> Signed-off-by: Florian Westphal <fw@strlen.de>

Jakub -

If you could mark this as "Not Applicable" in netdevbpf patchwork, we'll 
apply it to the mptcp tree and resubmit to netdev with some related 
patches.

Thanks,

--
Mat Martineau
Intel
Mat Martineau Dec. 6, 2021, 6:47 p.m. UTC | #6
On Mon, 6 Dec 2021, Matthieu Baerts wrote:

> Hi Florian,
>
> (without netdev and syzbot ML)
>
> On 05/12/2021 20:27, Florian Westphal wrote:
>> TCP_ULP setsockopt cannot be used for mptcp because its already
>> used internally to plumb subflow (tcp) sockets to the mptcp layer.
>>
>> syzbot managed to trigger a crash for mptcp connections that are
>> in fallback mode:
>>
>> KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027]
>> CPU: 1 PID: 1083 Comm: syz-executor.3 Not tainted 5.16.0-rc2-syzkaller #0
>> RIP: 0010:tls_build_proto net/tls/tls_main.c:776 [inline]
>> [..]
>>  __tcp_set_ulp net/ipv4/tcp_ulp.c:139 [inline]
>>  tcp_set_ulp+0x428/0x4c0 net/ipv4/tcp_ulp.c:160
>>  do_tcp_setsockopt+0x455/0x37c0 net/ipv4/tcp.c:3391
>>  mptcp_setsockopt+0x1b47/0x2400 net/mptcp/sockopt.c:638
>>
>> Remove support for TCP_ULP setsockopt.
>
> Good catch!
> Indeed, it doesn't make sense to support TCP_ULP.
>
>> Reported-by: syzbot+1fd9b69cde42967d1add@syzkaller.appspotmail.com
>> Signed-off-by: Florian Westphal <fw@strlen.de>
>
> I guess we need a Fixes tag here:
>
> Fixes: d9e4c1291810 ("mptcp: only admit explicitly supported sockopt")
>

Thanks Florian.

Matthieu, could you apply this to the export branch with your suggested 
Fixes tag?

Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>

--
Mat Martineau
Intel
Jakub Kicinski Dec. 6, 2021, 6:57 p.m. UTC | #7
On Mon, 6 Dec 2021 10:44:16 -0800 (PST) Mat Martineau wrote:
> If you could mark this as "Not Applicable" in netdevbpf patchwork, we'll 
> apply it to the mptcp tree and resubmit to netdev with some related 
> patches.

For sure, I was asking because technically I added the code that hit
the oops to tls a week or so ago, so I wanted to make sure it's not 
my fault ;) Marked in pw appropriately now.
Matthieu Baerts Dec. 7, 2021, 1:23 p.m. UTC | #8
Hi Mat,

On 06/12/2021 19:47, Mat Martineau wrote:
> On Mon, 6 Dec 2021, Matthieu Baerts wrote:
> 
>> Hi Florian,
>>
>> (without netdev and syzbot ML)
>>
>> On 05/12/2021 20:27, Florian Westphal wrote:
>>> TCP_ULP setsockopt cannot be used for mptcp because its already
>>> used internally to plumb subflow (tcp) sockets to the mptcp layer.
>>>
>>> syzbot managed to trigger a crash for mptcp connections that are
>>> in fallback mode:
>>>
>>> KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027]
>>> CPU: 1 PID: 1083 Comm: syz-executor.3 Not tainted
>>> 5.16.0-rc2-syzkaller #0
>>> RIP: 0010:tls_build_proto net/tls/tls_main.c:776 [inline]
>>> [..]
>>>  __tcp_set_ulp net/ipv4/tcp_ulp.c:139 [inline]
>>>  tcp_set_ulp+0x428/0x4c0 net/ipv4/tcp_ulp.c:160
>>>  do_tcp_setsockopt+0x455/0x37c0 net/ipv4/tcp.c:3391
>>>  mptcp_setsockopt+0x1b47/0x2400 net/mptcp/sockopt.c:638
>>>
>>> Remove support for TCP_ULP setsockopt.
>>
>> Good catch!
>> Indeed, it doesn't make sense to support TCP_ULP.
>>
>>> Reported-by: syzbot+1fd9b69cde42967d1add@syzkaller.appspotmail.com
>>> Signed-off-by: Florian Westphal <fw@strlen.de>
>>
>> I guess we need a Fixes tag here:
>>
>> Fixes: d9e4c1291810 ("mptcp: only admit explicitly supported sockopt")
>>
> 
> Thanks Florian.
> 
> Matthieu, could you apply this to the export branch with your suggested
> Fixes tag?
> 
> Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>

Sure, just did:

- 13dc812544f7: mptcp: remove tcp ulp setsockopt support

- Results: 5fd3630ba52a..4be3d8d5b45c

Builds and tests are now in progress:



https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20211207T132312

https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export

Cheers,
Matt
diff mbox series

Patch

diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index 3c3db22fd36a..aa3fcd86dbe2 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -543,7 +543,6 @@  static bool mptcp_supported_sockopt(int level, int optname)
 		case TCP_NODELAY:
 		case TCP_THIN_LINEAR_TIMEOUTS:
 		case TCP_CONGESTION:
-		case TCP_ULP:
 		case TCP_CORK:
 		case TCP_KEEPIDLE:
 		case TCP_KEEPINTVL: