All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] rxrpc: Fix service call disconnection
@ 2020-02-06 13:55 David Howells
  2020-02-07 10:21 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2020-02-06 13:55 UTC (permalink / raw)
  To: netdev; +Cc: dhowells, linux-afs, linux-kernel

The recent patch that substituted a flag on an rxrpc_call for the
connection pointer being NULL as an indication that a call was disconnected
puts the set_bit in the wrong place for service calls.  This is only a
problem if a call is implicitly terminated by a new call coming in on the
same connection channel instead of a terminating ACK packet.

In such a case, rxrpc_input_implicit_end_call() calls
__rxrpc_disconnect_call(), which is now (incorrectly) setting the
disconnection bit, meaning that when rxrpc_release_call() is later called,
it doesn't call rxrpc_disconnect_call() and so the call isn't removed from
the peer's error distribution list and the list gets corrupted.

KASAN finds the issue as an access after release on a call, but the
position at which it occurs is confusing as it appears to be related to a
different call (the call site is where the latter call is being removed
from the error distribution list and either the next or pprev pointer
points to a previously released call).

Fix this by moving the setting of the flag from __rxrpc_disconnect_call()
to rxrpc_disconnect_call() in the same place that the connection pointer
was being cleared.

Fixes: 5273a191dca6 ("rxrpc: Fix NULL pointer deref due to call->conn being cleared on disconnect")
Signed-off-by: David Howells <dhowells@redhat.com>
---

 net/rxrpc/conn_object.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c
index c0b3154f7a7e..19e141eeed17 100644
--- a/net/rxrpc/conn_object.c
+++ b/net/rxrpc/conn_object.c
@@ -171,8 +171,6 @@ void __rxrpc_disconnect_call(struct rxrpc_connection *conn,
 
 	_enter("%d,%x", conn->debug_id, call->cid);
 
-	set_bit(RXRPC_CALL_DISCONNECTED, &call->flags);
-
 	if (rcu_access_pointer(chan->call) == call) {
 		/* Save the result of the call so that we can repeat it if necessary
 		 * through the channel, whilst disposing of the actual call record.
@@ -225,6 +223,7 @@ void rxrpc_disconnect_call(struct rxrpc_call *call)
 	__rxrpc_disconnect_call(conn, call);
 	spin_unlock(&conn->channel_lock);
 
+	set_bit(RXRPC_CALL_DISCONNECTED, &call->flags);
 	conn->idle_timestamp = jiffies;
 }
 



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] rxrpc: Fix service call disconnection
  2020-02-06 13:55 [PATCH net] rxrpc: Fix service call disconnection David Howells
@ 2020-02-07 10:21 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-02-07 10:21 UTC (permalink / raw)
  To: dhowells; +Cc: netdev, linux-afs, linux-kernel

From: David Howells <dhowells@redhat.com>
Date: Thu, 06 Feb 2020 13:55:01 +0000

> The recent patch that substituted a flag on an rxrpc_call for the
> connection pointer being NULL as an indication that a call was disconnected
> puts the set_bit in the wrong place for service calls.  This is only a
> problem if a call is implicitly terminated by a new call coming in on the
> same connection channel instead of a terminating ACK packet.
> 
> In such a case, rxrpc_input_implicit_end_call() calls
> __rxrpc_disconnect_call(), which is now (incorrectly) setting the
> disconnection bit, meaning that when rxrpc_release_call() is later called,
> it doesn't call rxrpc_disconnect_call() and so the call isn't removed from
> the peer's error distribution list and the list gets corrupted.
> 
> KASAN finds the issue as an access after release on a call, but the
> position at which it occurs is confusing as it appears to be related to a
> different call (the call site is where the latter call is being removed
> from the error distribution list and either the next or pprev pointer
> points to a previously released call).
> 
> Fix this by moving the setting of the flag from __rxrpc_disconnect_call()
> to rxrpc_disconnect_call() in the same place that the connection pointer
> was being cleared.
> 
> Fixes: 5273a191dca6 ("rxrpc: Fix NULL pointer deref due to call->conn being cleared on disconnect")
> Signed-off-by: David Howells <dhowells@redhat.com>

Applied and queued up for -stable.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-07 10:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-06 13:55 [PATCH net] rxrpc: Fix service call disconnection David Howells
2020-02-07 10:21 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.