From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796106300; b=YmAbZlVo1xcHNe1ep1LTZgX3U4MK0PqkRCIg6gRmAzcKkbtLvNSyQXUuk8n6ER/9C2Vm gJvQwKZKwstiXDhJL5jf4wzfANjiAQotSksn9buT38Wo1QDpo12LNkFJbuXnjn5oiC6Wi nYEMU812S5kbA+bhjFdPa/beGFPD4eu6wnkSpdMWUrMJkAIrReH3B/s8hEgL9UrYo+2gg mEtR1rFUyfhLL7NqDsUJ1lxV/olA2TZdEQ41jy42pOnsLqTdLzPDQbQu1IbFmk+yE0raB dG9y9HvW3+fO3Q22BKm/a61J/9ZsWHb2Q3MEGrMi3HufdIl/SVg3n/BscEKza7bitiw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796106300; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=kNRpvj6r0YTevx1AerXig7VK7kt6KS8L5p9d+pAAwNc=; b=yMvc8D0NGOru4yVFzPbfSpjz7a1iTc20UI6A0r9DB17vUUyEn/T1SM9ouWsyt33bBLg6 kEWZmzAxVD5BLEL1LsHKqR6N4oM6UdEUmNo28MI71fQhyxtMZCEEPbuKnhw32AGIkGu21 dP5E1ZZvGGyECbNvlsba6SZceUKNUN31vbNmNc+I+rdEtlyrICwLE0kmT9CQ2icq5ZRlq bb857fgdbQUG8XaS+IT0SRg8Q4ooQDYYJqGOISvXFgvpe3UBijtnPa/aHgOIQSmy5JpXz ntzMQATi8MyZq8ZRc6n+zT5INU7hEgAJ9drzJv80qzeqmx0zRzbyao0Fsf0/ch1wVrg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=K040jSRN; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39F76606A31A; Tue, 1 Dec 2026 06:25:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=K040jSRN Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8C8D1F00897; Tue, 1 Dec 2026 06:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796106300; bh=kNRpvj6r0YTevx1AerXig7VK7kt6KS8L5p9d+pAAwNc=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=K040jSRNn01h2uRWItIiZxzPG3/tJemhDxLFmxaHRASCaMK2GYJqyrUupmlRry4R6 N9McROdi5fwGeb9qGgsrhpHToUTv4eqoervWBwSG/OyrJ/DQQxgQjmGBESP1ym7llK 4QIavnzoNspbyt7Spie9K6tScxtvTJolXCb6VsAppxyFNLUHkeIJbXMVUhra0JVjgm kYA1fMw0JrSVY6FTT+j7lr9pHI/7NIvgUCq2j7jZKXgKkYKDEngQkV3r/xdgiJ7RDJ 809/om+QWUb1/5nBretzmxXjUR6TmrLQhav4crp4poyqeTvWhcdZ3TgGu4lEcFff8N C3BYp5VLJRH3A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net v3] net/smc: serialize clcsock release against CDC receive path Reply-To: sashiko-reviews@lists.linux.dev To: "Qican Ma" Cc: linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, "Heiko Carstens" , "Vasily Gorbik" , "Alexander Gordeev" , "Christian Borntraeger" In-Reply-To: <179610581608.84222.8603821461741221796@gmail.com> References: <179610581608.84222.8603821461741221796@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 06:24:59 +0000 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > In smc_cdc_msg_recv_action(), receiving a close or senddone flag writes > RCV_SHUTDOWN to smc->clcsock->sk->sk_shutdown while holding only > bh_lock_sock(&smc->sk). Meanwhile __smc_release() drops the socket lock > and calls smc_clcsock_release() (which clears smc->clcsock and calls > sock_release() under clcsock_release_lock) before calling > smc_conn_free(&smc->conn). Even on paths that call smc_conn_free() first, > an in-flight SMC-R softirq that already looked up the connection in > smc_cdc_rx_handler() can still enter smc_cdc_msg_recv() concurrently with > smc_clcsock_release() and dereference or write through a freed clcsock. >=20 > Free the SMC connection before releasing clcsock in __smc_release(), > matching smc_close_active_abort() and smc_close_passive_work(). Because > smc_conn_free() sets conn->freed while lock_sock(sk) is held and > release_sock(sk) synchronizes on sk->sk_lock.slock before > smc_clcsock_release() runs, checking !smc->conn.freed under > bh_lock_sock(&smc->sk) in smc_cdc_msg_recv() guarantees that no CDC > handler accesses smc->clcsock once smc_clcsock_release() can start. >=20 > The freed flag is written under lock_sock() but read under bh_lock_sock() > in softirq context, so the writer side and the smc_conn_create() > initializer use WRITE_ONCE() and the CDC reader uses READ_ONCE() to avoid > a KCSAN data race, as pointed out by Willem de Bruijn. >=20 > Found with an LLM-assisted code review tool and verified by inspection on > v7.4-rc4 (b6a9fa34ce4). Build-tested only; not runtime-tested due to lack > of an SMC-R/SMC-D setup. >=20 > Fixes: b38d732477e4 ("smc: socket closing and linkgroup cleanup") > Cc: stable@vger.kernel.org > Signed-off-by: Qican Ma Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/179610581608.84222.= 8603821461741221796@gmail.com?part=3D1