From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBF311078B; Sat, 3 Feb 2024 04:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706933335; cv=none; b=YjgJVDEDmJjuRs23CbSBRr1QGDM5b4oIwluG/2saCdSs0ZVwUXy2FNBau5K8u1qR9OvGYJozibYTZaJ0nbgoNL20HNhB/XD47FtcSm9GgePAf2JqDcQz1chtTQgKlWpM7cPFOSXYu9NrsNNi/haHqjqR5WhjPYpfEyBTZ2v2Wdk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706933335; c=relaxed/simple; bh=I/btkV30x5vlr4bBqyrLe/RftGBB6e5z5fwPl5SgfJU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dHAUgp7KrPrdEji9ZpUwW9/C3QT06piLuo7ARr7sX0fnuT8lEIfH91/HZcHHj54V+VZRSoAdNFuVcCg2VBTy02+ZT6vDXl+lbkT90s+pK0pt8uunCySgO8Jtks3dkBzBACIKMgYa9Y5uukfpOPe3v2R65ROdlmph03TeIBddadM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=pbIGNwfe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="pbIGNwfe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81880C433F1; Sat, 3 Feb 2024 04:08:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1706933335; bh=I/btkV30x5vlr4bBqyrLe/RftGBB6e5z5fwPl5SgfJU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pbIGNwfe2sZ+LAf0iKti/cPBCzbURWjYgvuLcD5IuGHkbIjeQpmoZb33+nEieU3D8 cyuslLVFuSBlpEsLzdAICtDuyW7ZZBi9z5uNpX5ZhotddLUwtbkY9qY3uzy4/tdNfL bm2iwTCB52iecwQhAniTdeFzE2rzOdMC3XSQBIxc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Oleg Nesterov , David Howells , Marc Dionne , linux-afs@lists.infradead.org, Sasha Levin Subject: [PATCH 6.1 033/219] rxrpc_find_service_conn_rcu: fix the usage of read_seqbegin_or_lock() Date: Fri, 2 Feb 2024 20:03:26 -0800 Message-ID: <20240203035321.012207242@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240203035317.354186483@linuxfoundation.org> References: <20240203035317.354186483@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Oleg Nesterov [ Upstream commit bad1a11c0f061aa073bab785389fe04f19ba02e1 ] rxrpc_find_service_conn_rcu() should make the "seq" counter odd on the second pass, otherwise read_seqbegin_or_lock() never takes the lock. Signed-off-by: Oleg Nesterov Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org Link: https://lore.kernel.org/r/20231117164846.GA10410@redhat.com/ Signed-off-by: Sasha Levin --- net/rxrpc/conn_service.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/rxrpc/conn_service.c b/net/rxrpc/conn_service.c index 6e6aa02c6f9e..249353417a18 100644 --- a/net/rxrpc/conn_service.c +++ b/net/rxrpc/conn_service.c @@ -31,7 +31,7 @@ struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *peer, struct rxrpc_conn_proto k; struct rxrpc_skb_priv *sp = rxrpc_skb(skb); struct rb_node *p; - unsigned int seq = 0; + unsigned int seq = 1; k.epoch = sp->hdr.epoch; k.cid = sp->hdr.cid & RXRPC_CIDMASK; @@ -41,6 +41,7 @@ struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *peer, * under just the RCU read lock, so we have to check for * changes. */ + seq++; /* 2 on the 1st/lockless path, otherwise odd */ read_seqbegin_or_lock(&peer->service_conn_lock, &seq); p = rcu_dereference_raw(peer->service_conns.rb_node); -- 2.43.0