From: David Miller <davem@davemloft.net> Date: 2017-12-04 18:57:18
From: Cong Wang <redacted>
Date: Mon, 4 Dec 2017 10:31:43 -0800
In tipc_topsrv_kern_subscr() when s->tipc_conn_new() fails
we call tipc_close_conn() to clean up, but in this case
calling conn_put() is just enough.
This fixes the folllowing crash:
...
Fixes: 14c04493cb77 ("tipc: add ability to order and receive topology events in driver")
Reported-by: syzbot <redacted>
Cc: Jon Maloy <redacted>
Cc: Ying Xue <redacted>
Signed-off-by: Cong Wang <redacted>
...
quoted hunk
@@ -511,7 +511,7 @@ bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, s = con->server; scbr = s->tipc_conn_new(*conid); if (!scbr) {- tipc_close_conn(con);+ conn_put(con); return false; }
--
2.13.0
It looks like tipc_accept_from_sock() has a similar problem? The
tipc_close_conn() will get invoked indirectly from the sock_release()
path right?
From: Cong Wang <hidden> Date: 2017-12-04 19:23:34
On Mon, Dec 4, 2017 at 10:57 AM, David Miller [off-list ref] wrote:
From: Cong Wang <redacted>
Date: Mon, 4 Dec 2017 10:31:43 -0800
quoted
In tipc_topsrv_kern_subscr() when s->tipc_conn_new() fails
we call tipc_close_conn() to clean up, but in this case
calling conn_put() is just enough.
This fixes the folllowing crash:
...
quoted
Fixes: 14c04493cb77 ("tipc: add ability to order and receive topology events in driver")
Reported-by: syzbot <redacted>
Cc: Jon Maloy <redacted>
Cc: Ying Xue <redacted>
Signed-off-by: Cong Wang <redacted>
...
quoted
@@ -511,7 +511,7 @@ bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, s = con->server; scbr = s->tipc_conn_new(*conid); if (!scbr) {- tipc_close_conn(con);+ conn_put(con); return false; }--
2.13.0
It looks like tipc_accept_from_sock() has a similar problem? The
tipc_close_conn() will get invoked indirectly from the sock_release()
path right?
Not sure, the sock_release() in tipc_accept_from_sock() is for
kernel_accept(), not for tipc_alloc_conn(). Or maybe it is hiding
deep in the call chain that I miss?
From: Cong Wang <hidden> Date: 2017-12-04 19:41:36
On Mon, Dec 4, 2017 at 11:23 AM, Cong Wang [off-list ref] wrote:
On Mon, Dec 4, 2017 at 10:57 AM, David Miller [off-list ref] wrote:
quoted
It looks like tipc_accept_from_sock() has a similar problem? The
tipc_close_conn() will get invoked indirectly from the sock_release()
path right?
Not sure, the sock_release() in tipc_accept_from_sock() is for
kernel_accept(), not for tipc_alloc_conn(). Or maybe it is hiding
deep in the call chain that I miss?
I see:
tipc_release() -> tipc_sk_leave() -> tipc_group_delete()
-> tipc_topsrv_kern_unsubscr() -> tipc_close_conn()
Seems on this path we do need to skip NULL too.
From: Jon Maloy <hidden> Date: 2017-12-04 19:44:28
-----Original Message-----
From: netdev-owner@vger.kernel.org [mailto:netdev-
owner@vger.kernel.org] On Behalf Of David Miller
Sent: Monday, December 04, 2017 13:57
To: xiyou.wangcong@gmail.com
Cc: netdev@vger.kernel.org; tipc-discussion@lists.sourceforge.net; Jon
Maloy [off-list ref]; Ying Xue [off-list ref]
Subject: Re: [Patch net v2] tipc: fix a null pointer deref on error path
From: Cong Wang <redacted>
Date: Mon, 4 Dec 2017 10:31:43 -0800
quoted
In tipc_topsrv_kern_subscr() when s->tipc_conn_new() fails we call
tipc_close_conn() to clean up, but in this case calling conn_put() is
just enough.
This fixes the folllowing crash:
...
quoted
Fixes: 14c04493cb77 ("tipc: add ability to order and receive topology
events in driver")
Reported-by: syzbot <redacted>
Cc: Jon Maloy <redacted>
Cc: Ying Xue <redacted>
Signed-off-by: Cong Wang <redacted>
...
quoted
@@ -511,7 +511,7 @@ bool tipc_topsrv_kern_subscr(struct net *net, u32
port, u32 type,
quoted
s = con->server;
scbr = s->tipc_conn_new(*conid);
if (!scbr) {
- tipc_close_conn(con);
+ conn_put(con);
return false;
}
--
2.13.0
It looks like tipc_accept_from_sock() has a similar problem? The
tipc_close_conn() will get invoked indirectly from the sock_release()
path right?
No, it doesn't. There will be a 'leaked' conn instance which will remain in the reference table until it is flushed during module removal.
We'll fix this in a separate patch. Cong's fix is correct.
///jon
From: David Miller <davem@davemloft.net> Date: 2017-12-04 19:48:05
From: Cong Wang <redacted>
Date: Mon, 4 Dec 2017 11:23:13 -0800
On Mon, Dec 4, 2017 at 10:57 AM, David Miller [off-list ref] wrote:
quoted
From: Cong Wang <redacted>
Date: Mon, 4 Dec 2017 10:31:43 -0800
quoted
In tipc_topsrv_kern_subscr() when s->tipc_conn_new() fails
we call tipc_close_conn() to clean up, but in this case
calling conn_put() is just enough.
This fixes the folllowing crash:
...
quoted
Fixes: 14c04493cb77 ("tipc: add ability to order and receive topology events in driver")
Reported-by: syzbot <redacted>
Cc: Jon Maloy <redacted>
Cc: Ying Xue <redacted>
Signed-off-by: Cong Wang <redacted>
...
quoted
@@ -511,7 +511,7 @@ bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, s = con->server; scbr = s->tipc_conn_new(*conid); if (!scbr) {- tipc_close_conn(con);+ conn_put(con); return false; }--
2.13.0
It looks like tipc_accept_from_sock() has a similar problem? The
tipc_close_conn() will get invoked indirectly from the sock_release()
path right?
Not sure, the sock_release() in tipc_accept_from_sock() is for
kernel_accept(), not for tipc_alloc_conn(). Or maybe it is hiding
deep in the call chain that I miss?
I guess I'm trying to figure out where 'newcon' is released when the
call to s->tipc_conn_new() on it fails.
It looks similar to the situation you are fixing here, which is why I
am mentioning it.
From: Jon Maloy <hidden> Date: 2017-12-04 19:49:58
-----Original Message-----
From: Cong Wang [mailto:xiyou.wangcong@gmail.com]
Sent: Monday, December 04, 2017 14:41
To: David Miller <davem@davemloft.net>
Cc: Linux Kernel Network Developers <redacted>; tipc-
discussion@lists.sourceforge.net; Jon Maloy [off-list ref];
Ying Xue [off-list ref]
Subject: Re: [Patch net v2] tipc: fix a null pointer deref on error path
On Mon, Dec 4, 2017 at 11:23 AM, Cong Wang [off-list ref]
wrote:
quoted
On Mon, Dec 4, 2017 at 10:57 AM, David Miller [off-list ref]
wrote:
quoted
quoted
It looks like tipc_accept_from_sock() has a similar problem? The
tipc_close_conn() will get invoked indirectly from the sock_release()
path right?
Not sure, the sock_release() in tipc_accept_from_sock() is for
kernel_accept(), not for tipc_alloc_conn(). Or maybe it is hiding deep
in the call chain that I miss?
I see:
tipc_release() -> tipc_sk_leave() -> tipc_group_delete()
-> tipc_topsrv_kern_unsubscr() -> tipc_close_conn()
Seems on this path we do need to skip NULL too.
You are right. The right solution is to just call conn_put() twice here.
I already have a patch ready for this, but it is part of a series that needs more review.
I should probably post it separately...
///jon
From: Jon Maloy <hidden> Date: 2017-12-04 20:32:59
-----Original Message-----
From: netdev-owner@vger.kernel.org [mailto:netdev-
owner@vger.kernel.org] On Behalf Of Jon Maloy
Sent: Monday, December 04, 2017 14:50
To: Cong Wang <redacted>; David Miller
[off-list ref]
Cc: Linux Kernel Network Developers <redacted>; tipc-
discussion@lists.sourceforge.net; Ying Xue [off-list ref]
Subject: RE: [Patch net v2] tipc: fix a null pointer deref on error path
quoted
-----Original Message-----
From: Cong Wang [mailto:xiyou.wangcong@gmail.com]
Sent: Monday, December 04, 2017 14:41
To: David Miller <davem@davemloft.net>
Cc: Linux Kernel Network Developers <redacted>; tipc-
discussion@lists.sourceforge.net; Jon Maloy [off-list ref];
Ying Xue [off-list ref]
Subject: Re: [Patch net v2] tipc: fix a null pointer deref on error
path
On Mon, Dec 4, 2017 at 11:23 AM, Cong Wang
[off-list ref]
quoted
wrote:
quoted
On Mon, Dec 4, 2017 at 10:57 AM, David Miller [off-list ref]
wrote:
quoted
quoted
It looks like tipc_accept_from_sock() has a similar problem? The
tipc_close_conn() will get invoked indirectly from the
sock_release() path right?
Not sure, the sock_release() in tipc_accept_from_sock() is for
kernel_accept(), not for tipc_alloc_conn(). Or maybe it is hiding
deep in the call chain that I miss?
I see:
tipc_release() -> tipc_sk_leave() -> tipc_group_delete()
-> tipc_topsrv_kern_unsubscr() -> tipc_close_conn()
Seems on this path we do need to skip NULL too.
You are right. The right solution is to just call conn_put() twice here.
I already have a patch ready for this, but it is part of a series that needs more
review.
I should probably post it separately...
Well, calling conn_put() twice was ok in my series, but in the current upstream version it is not enough.
I will find a different short term solution.
///jon
From: Cong Wang <hidden> Date: 2017-12-04 22:34:48
On Mon, Dec 4, 2017 at 12:32 PM, Jon Maloy [off-list ref] wrote:
quoted
You are right. The right solution is to just call conn_put() twice here.
I already have a patch ready for this, but it is part of a series that needs more
review.
I should probably post it separately...
Well, calling conn_put() twice was ok in my series, but in the current upstream version it is not enough.
I will find a different short term solution.
IMHO, for tipc_topsrv_kern_subscr() my v2 patch is more
correct, and for tipc_accept_from_sock(), v1 is needed too.
Of course v1 could fix both, but still v2 is better than v1 if
we only consider tipc_topsrv_kern_subscr() case. So this
depends if we want to consider these 2 paths as 2 cases
or 1 case. _I think_ it is better to consider them separately
since we already v2 is best fix for tipc_topsrv_kern_subscr(),
while still not sure what is the best for tipc_accept_from_sock().
From: Jon Maloy <hidden> Date: 2017-12-05 01:56:48
-----Original Message-----
From: Cong Wang [mailto:xiyou.wangcong@gmail.com]
Sent: Monday, December 04, 2017 17:34
To: Jon Maloy <redacted>
Cc: David Miller <davem@davemloft.net>; Linux Kernel Network Developers
[off-list ref]; tipc-discussion@lists.sourceforge.net; Ying Xue
[off-list ref]
Subject: Re: [Patch net v2] tipc: fix a null pointer deref on error path
On Mon, Dec 4, 2017 at 12:32 PM, Jon Maloy [off-list ref]
wrote:
quoted
quoted
You are right. The right solution is to just call conn_put() twice here.
I already have a patch ready for this, but it is part of a series
that needs more review.
I should probably post it separately...
Well, calling conn_put() twice was ok in my series, but in the current
upstream version it is not enough.
quoted
I will find a different short term solution.
IMHO, for tipc_topsrv_kern_subscr() my v2 patch is more correct, and for
tipc_accept_from_sock(), v1 is needed too.
Absolutely. I already acked v2, but maybe I wasn't clear enough about that.
What I was referring to above was tipc_kern_unsubscr(), where you also, correctly, identified a problem.
That problem is reduced, but not totally eliminated by your v1, so I am ok with that one too for now.
We have a fully safe solution for this in the pipe.
Of course v1 could fix both, but still v2 is better than v1 if we only consider
tipc_topsrv_kern_subscr() case. So this depends if we want to consider
these 2 paths as 2 cases or 1 case. _I think_ it is better to consider them
separately since we already v2 is best fix for tipc_topsrv_kern_subscr(),
while still not sure what is the best for tipc_accept_from_sock().
The tipc_accept_from_sock() problem is as far as I can see totally analogous to the tipc_kern_subscr() one, and requires the same solution. This is what my patch is providing.
BR
///jon
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
From: David Miller <davem@davemloft.net> Date: 2017-12-05 19:53:41
From: Cong Wang <redacted>
Date: Mon, 4 Dec 2017 10:31:43 -0800
In tipc_topsrv_kern_subscr() when s->tipc_conn_new() fails
we call tipc_close_conn() to clean up, but in this case
calling conn_put() is just enough.
This fixes the folllowing crash:
...
Fixes: 14c04493cb77 ("tipc: add ability to order and receive topology events in driver")
Reported-by: syzbot <redacted>
Cc: Jon Maloy <redacted>
Cc: Ying Xue <redacted>
Signed-off-by: Cong Wang <redacted>