Skip to contentSkip to conversation

net/rxrpc/conn_client.c:885 rxrpc_disconnect_client_call() error: double unlocked 'bundle->channel_lock' (orig line 814)

PATCH New Dan Carpenter 1 participant 1 message Oct 6, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 5398/13159 net/rxrpc/conn_client.c:885 rxrpc_disconnect_client_call() error: double unlocked 'bundle->channel_lock' (orig line 814)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   2172e358cd1713c5b7c31361ac465edfe55e455c
commit: 245500d853e9f20036cec7df4f6984ece4c6bf26 [5398/13159] rxrpc: Rewrite the client connection manager
config: ia64-randconfig-m031-20201003 (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate

New smatch warnings:
net/rxrpc/conn_client.c:885 rxrpc_disconnect_client_call() error: double unlocked 'bundle->channel_lock' (orig line 814)

Old smatch warnings:
net/rxrpc/conn_client.c:494 rxrpc_maybe_add_conn() warn: inconsistent returns 'bundle->channel_lock'. net/rxrpc/conn_client.c:722 rxrpc_connect_call() error: 'bundle' dereferencing possible ERR_PTR()

vim +885 net/rxrpc/conn_client.c

245500d853e9f20 David Howells 2020-07-01  782  void rxrpc_disconnect_client_call(struct rxrpc_bundle *bundle, struct rxrpc_call *call)
45025bceef17ed5 David Howells 2016-08-24  783  {
245500d853e9f20 David Howells 2020-07-01  784  	struct rxrpc_connection *conn;
930c9f9125c85b5 David Howells 2019-03-08  785  	struct rxrpc_channel *chan = NULL;
245500d853e9f20 David Howells 2020-07-01  786  	struct rxrpc_net *rxnet = bundle->params.local->rxnet;
245500d853e9f20 David Howells 2020-07-01  787  	unsigned int channel;
245500d853e9f20 David Howells 2020-07-01  788  	bool may_reuse;
930c9f9125c85b5 David Howells 2019-03-08  789  	u32 cid;
45025bceef17ed5 David Howells 2016-08-24  790  
245500d853e9f20 David Howells 2020-07-01  791  	_enter("c=%x", call->debug_id);
930c9f9125c85b5 David Howells 2019-03-08  792  
245500d853e9f20 David Howells 2020-07-01  793  	spin_lock(&bundle->channel_lock);
245500d853e9f20 David Howells 2020-07-01  794  	set_bit(RXRPC_CALL_DISCONNECTED, &call->flags);
45025bceef17ed5 David Howells 2016-08-24  795  
45025bceef17ed5 David Howells 2016-08-24  796  	/* Calls that have never actually been assigned a channel can simply be
245500d853e9f20 David Howells 2020-07-01  797  	 * discarded.
45025bceef17ed5 David Howells 2016-08-24  798  	 */
245500d853e9f20 David Howells 2020-07-01  799  	conn = call->conn;
245500d853e9f20 David Howells 2020-07-01  800  	if (!conn) {
45025bceef17ed5 David Howells 2016-08-24  801  		_debug("call is waiting");
45025bceef17ed5 David Howells 2016-08-24  802  		ASSERTCMP(call->call_id, ==, 0);
45025bceef17ed5 David Howells 2016-08-24  803  		ASSERT(!test_bit(RXRPC_CALL_EXPOSED, &call->flags));
45025bceef17ed5 David Howells 2016-08-24  804  		list_del_init(&call->chan_wait_link);
45025bceef17ed5 David Howells 2016-08-24  805  		goto out;
45025bceef17ed5 David Howells 2016-08-24  806  	}
45025bceef17ed5 David Howells 2016-08-24  807  
245500d853e9f20 David Howells 2020-07-01  808  	cid = call->cid;
245500d853e9f20 David Howells 2020-07-01  809  	channel = cid & RXRPC_CHANNELMASK;
245500d853e9f20 David Howells 2020-07-01  810  	chan = &conn->channels[channel];
245500d853e9f20 David Howells 2020-07-01  811  	trace_rxrpc_client(conn, channel, rxrpc_client_chan_disconnect);
245500d853e9f20 David Howells 2020-07-01  812  
930c9f9125c85b5 David Howells 2019-03-08  813  	if (rcu_access_pointer(chan->call) != call) {

245500d853e9f20 David Howells 2020-07-01 @814 spin_unlock(&bundle->channel_lock);
930c9f9125c85b5 David Howells 2019-03-08 815 BUG();

I guess this config has BUG() disabled. Could this just goto out?

930c9f9125c85b5 David Howells 2019-03-08  816  	}
45025bceef17ed5 David Howells 2016-08-24  817  
245500d853e9f20 David Howells 2020-07-01  818  	may_reuse = rxrpc_may_reuse_conn(conn);
245500d853e9f20 David Howells 2020-07-01  819  
45025bceef17ed5 David Howells 2016-08-24  820  	/* If a client call was exposed to the world, we save the result for
45025bceef17ed5 David Howells 2016-08-24  821  	 * retransmission.
45025bceef17ed5 David Howells 2016-08-24  822  	 *
45025bceef17ed5 David Howells 2016-08-24  823  	 * We use a barrier here so that the call number and abort code can be
45025bceef17ed5 David Howells 2016-08-24  824  	 * read without needing to take a lock.
45025bceef17ed5 David Howells 2016-08-24  825  	 *
45025bceef17ed5 David Howells 2016-08-24  826  	 * TODO: Make the incoming packet handler check this and handle
45025bceef17ed5 David Howells 2016-08-24  827  	 * terminal retransmission without requiring access to the call.
45025bceef17ed5 David Howells 2016-08-24  828  	 */
45025bceef17ed5 David Howells 2016-08-24  829  	if (test_bit(RXRPC_CALL_EXPOSED, &call->flags)) {
f5c17aaeb2aee9b David Howells 2016-08-30  830  		_debug("exposed %u,%u", call->call_id, call->abort_code);
45025bceef17ed5 David Howells 2016-08-24  831  		__rxrpc_disconnect_call(conn, call);
245500d853e9f20 David Howells 2020-07-01  832  
245500d853e9f20 David Howells 2020-07-01  833  		if (test_and_clear_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags)) {
245500d853e9f20 David Howells 2020-07-01  834  			trace_rxrpc_client(conn, channel, rxrpc_client_to_active);
245500d853e9f20 David Howells 2020-07-01  835  			bundle->try_upgrade = false;
245500d853e9f20 David Howells 2020-07-01  836  			if (may_reuse)
245500d853e9f20 David Howells 2020-07-01  837  				rxrpc_activate_channels_locked(bundle);
245500d853e9f20 David Howells 2020-07-01  838  		}
245500d853e9f20 David Howells 2020-07-01  839  
45025bceef17ed5 David Howells 2016-08-24  840  	}
45025bceef17ed5 David Howells 2016-08-24  841  
45025bceef17ed5 David Howells 2016-08-24  842  	/* See if we can pass the channel directly to another call. */
245500d853e9f20 David Howells 2020-07-01  843  	if (may_reuse && !list_empty(&bundle->waiting_calls)) {
363deeab6d0f308 David Howells 2016-09-17  844  		trace_rxrpc_client(conn, channel, rxrpc_client_chan_pass);
45025bceef17ed5 David Howells 2016-08-24  845  		rxrpc_activate_one_channel(conn, channel);
245500d853e9f20 David Howells 2020-07-01  846  		goto out;
45025bceef17ed5 David Howells 2016-08-24  847  	}
45025bceef17ed5 David Howells 2016-08-24  848  
3136ef49a14ccc1 David Howells 2017-11-24  849  	/* Schedule the final ACK to be transmitted in a short while so that it
3136ef49a14ccc1 David Howells 2017-11-24  850  	 * can be skipped if we find a follow-on call.  The first DATA packet
3136ef49a14ccc1 David Howells 2017-11-24  851  	 * of the follow on call will implicitly ACK this call.
3136ef49a14ccc1 David Howells 2017-11-24  852  	 */
17e9e23b130e4e2 David Howells 2018-02-06  853  	if (call->completion == RXRPC_CALL_SUCCEEDED &&
17e9e23b130e4e2 David Howells 2018-02-06  854  	    test_bit(RXRPC_CALL_EXPOSED, &call->flags)) {
3136ef49a14ccc1 David Howells 2017-11-24  855  		unsigned long final_ack_at = jiffies + 2;
3136ef49a14ccc1 David Howells 2017-11-24  856  
3136ef49a14ccc1 David Howells 2017-11-24  857  		WRITE_ONCE(chan->final_ack_at, final_ack_at);
3136ef49a14ccc1 David Howells 2017-11-24  858  		smp_wmb(); /* vs rxrpc_process_delayed_final_acks() */
3136ef49a14ccc1 David Howells 2017-11-24  859  		set_bit(RXRPC_CONN_FINAL_ACK_0 + channel, &conn->flags);
3136ef49a14ccc1 David Howells 2017-11-24  860  		rxrpc_reduce_conn_timer(conn, final_ack_at);
3136ef49a14ccc1 David Howells 2017-11-24  861  	}
3136ef49a14ccc1 David Howells 2017-11-24  862  
245500d853e9f20 David Howells 2020-07-01  863  	/* Deactivate the channel. */
245500d853e9f20 David Howells 2020-07-01  864  	rcu_assign_pointer(chan->call, NULL);
245500d853e9f20 David Howells 2020-07-01  865  	set_bit(conn->bundle_shift + channel, &conn->bundle->avail_chans);
245500d853e9f20 David Howells 2020-07-01  866  	conn->act_chans	&= ~(1 << channel);
45025bceef17ed5 David Howells 2016-08-24  867  
245500d853e9f20 David Howells 2020-07-01  868  	/* If no channels remain active, then put the connection on the idle
245500d853e9f20 David Howells 2020-07-01  869  	 * list for a short while.  Give it a ref to stop it going away if it
245500d853e9f20 David Howells 2020-07-01  870  	 * becomes unbundled.
245500d853e9f20 David Howells 2020-07-01  871  	 */
245500d853e9f20 David Howells 2020-07-01  872  	if (!conn->act_chans) {
245500d853e9f20 David Howells 2020-07-01  873  		trace_rxrpc_client(conn, channel, rxrpc_client_to_idle);
245500d853e9f20 David Howells 2020-07-01  874  		conn->idle_timestamp = jiffies;
45025bceef17ed5 David Howells 2016-08-24  875  
245500d853e9f20 David Howells 2020-07-01  876  		rxrpc_get_connection(conn);
245500d853e9f20 David Howells 2020-07-01  877  		spin_lock(&rxnet->client_conn_cache_lock);
245500d853e9f20 David Howells 2020-07-01  878  		list_move_tail(&conn->cache_link, &rxnet->idle_client_conns);
245500d853e9f20 David Howells 2020-07-01  879  		spin_unlock(&rxnet->client_conn_cache_lock);
45025bceef17ed5 David Howells 2016-08-24  880  
245500d853e9f20 David Howells 2020-07-01  881  		rxrpc_set_client_reap_timer(rxnet);
45025bceef17ed5 David Howells 2016-08-24  882  	}
c6d2b8d764f5edd David Howells 2016-04-04  883  
45025bceef17ed5 David Howells 2016-08-24  884  out:
245500d853e9f20 David Howells 2020-07-01 @885  	spin_unlock(&bundle->channel_lock);
45025bceef17ed5 David Howells 2016-08-24  886  	_leave("");
45025bceef17ed5 David Howells 2016-08-24  887  	return;
245500d853e9f20 David Howells 2020-07-01  888  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org