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=1796375722; b=xdOasiwoQt+t4hOSnOtFP0D2+ByoYAOMgpT481krI+L071iYkUyDAIDq/QGI8ydjWEiH izK7rV4sUoTiFOpsYRoQml+vHLRPi0qc4jkqgxFEn1mzZavUf4qRbHkxF6GHcZedv3nhW qOQhe/IMBVWhelebOxrY5dr6lWwgeBf3TMXqYR102Irf/h6XRg/I9ZGPRwLsYsKdPxMJo a7YwWDzKW2TSefxJZ2FCj3Z5G9ABxm+7vwWibxfANNLvX+z7LJjtMbLbbRFU/vPE4V9S0 bfqY+uqYkDn7I1Q2NSa/mealKFZ/DgkZxwQYjjl1GOGa0xLMMAAK1ZIauZkZbGcxjpA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796375722; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Eo9S+PQXp2VVtDkVbd1eIGXtzaItQJGrFE6MWReAUm0=; b=A/QgGGkdk1WuSnfJ/BBdSNsuGKCQsjIku22hNB31gzo3ptokhqG757DbkNhjrt/40V3A ikbfkkCu+Zc3Omw9viwh4/2mD7PuDzlwEZSDqG2b3HYHIINGHvPEfmjDRif57pcwR0ssK QOLiMHR6Wn4N7LYmX0XPfCKWl1q2sh+MsuUuMwbiXFIo+ADLTQtJTvzpRvUt9X9KmfPR5 AaHPafAOAAarMThLNUJYO0054SFoExdcM1Br0UzSKNtvziF6oIQJUdt6tNucI1tnpWj3s YYTXI5LnlQK/v/DQbhKrgy87gvw5uxfndBEdLRWxKhXrBMDlD7vuvjkgtHf64EXVKPg== 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=lL4lZk8o; 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 6B3D4606A332; Fri, 4 Dec 2026 09:15:22 +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=lL4lZk8o Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12F6E1F00897; Fri, 4 Dec 2026 09:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796375722; bh=Eo9S+PQXp2VVtDkVbd1eIGXtzaItQJGrFE6MWReAUm0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=lL4lZk8ot42m33tgTd8oKg3veTjLejQ7Bl6kEt6dxDmWrgkZLNVys+omKp3TN6ukc fmCQU1Js6g1EkEAMkqmI9WDnDv4wHshSllJt7qGXgijisio0+OsBaiv62idSZQt7gq 6gYomb+sZaf3RBlCkDPQ0W1BPH6jevlECw7QclMxNi9dT/bhhhhHfv+HIhz+fg1e+u 5e1nLlSUotGt28C+OViHxtwSVgOEgJgDdcfJdwt6MLlIeVCWp84KLZkkFNQ9fGcf1b VFEUd5LccjzxSRHy8l6vvd8eEpDQenw7GZI7euI6Vv9M4ojAbYCFjuAHUWKey8mggn KuzDR3KmHB7bA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net v3 6/7] net/smc: update the urgent state under the socket spinlock Reply-To: sashiko-reviews@lists.linux.dev To: "Bryam Vargas" Cc: linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, "Heiko Carstens" , "Vasily Gorbik" , "Alexander Gordeev" , "Christian Borntraeger" In-Reply-To: <20261203-b4-disp-ba1ad55e-v3-6-6834ff90c5d0@proton.me> References: <20261203-b4-disp-ba1ad55e-v3-0-6834ff90c5d0@proton.me> <20261203-b4-disp-ba1ad55e-v3-6-6834ff90c5d0@proton.me> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 09:15:21 +0000 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] net/smc: unlocked SIOCATMARK urgent state read in smc_ioctl() - [Low] net/smc: unmarked lockless conn->urg_state access in smc_rx_update_consumer() -- commit ecdc0ee1be6bad8560d17f7bb2467d0c7e080ab9 Author: Bryam Vargas net/smc: update the urgent state under the socket spinlock This commit takes bh_lock_sock() around the urgent state checks and updates in smc_rx_update_consumer() and smc_rx_recv_urg() to serialize them with smc_cdc_msg_recv_action(). > Take the socket spinlock around both test-and-set sequences. [Severity: Medium] Does smc_ioctl() also need bh_lock_sock() around its SIOCATMARK read of conn->urg_curs and conn->urg_state? Earlier in this series, commit "net/smc: order the urgent mark across the cursor wrap rollover" updated the SIOCATMARK path to check conn->urg_state alongside conn->urg_curs while holding only lock_sock(): net/smc/af_smc.c:smc_ioctl() { ... smc_curs_copy(&cons, &conn->local_tx_ctrl.cons, conn); smc_curs_copy(&urg, &conn->urg_curs, conn); answ =3D (conn->urg_state =3D=3D SMC_URG_VALID || conn->urg_rx_skip_pend) && smc_curs_sdiff(conn->rmb_desc->len, &cons, &urg) =3D=3D 1; ... } Because smc_ioctl() copies conn->urg_curs before testing conn->urg_state, it reads them in the opposite order from smc_cdc_handle_urg_data_arrival(): CPU0 (user) CPU1 (softirq) smc_ioctl(SIOCATMARK) lock_sock(&smc->sk) urg =3D conn->urg_curs smc_cdc_msg_recv() bh_lock_sock(&smc->sk) smc_cdc_handle_urg_data_arrival() conn->urg_curs =3D prod conn->urg_state =3D SMC_URG_VALID bh_unlock_sock(&smc->sk) test conn->urg_state <-- pairs stale urg with new SMC_URG_VALID As a result, ioctl(SIOCATMARK) can observe a torn snapshot and return a fal= se positive or false negative, in addition to an unmarked data race on conn->urg_state. Taking local_bh_disable() and bh_lock_sock(&smc->sk) arou= nd the SIOCATMARK read would fix both. [ ... ] > diff --git a/net/smc/smc_rx.c b/net/smc/smc_rx.c > index 564b976426caa..2680b91e882b9 100644 > --- a/net/smc/smc_rx.c > +++ b/net/smc/smc_rx.c > @@ -67,26 +67,38 @@ static int smc_rx_update_consumer(struct smc_sock *sm= c, > =20 > smc_curs_add(conn->rmb_desc->len, &cons, len); > =20 > - /* did we process urgent data? */ > + /* did we process urgent data? smc_cdc_msg_recv_action() sets a new > + * mark under the socket spinlock, even while we own the socket: > + * test again under it. A mark set after the first test is left to > + * the next call, like one set after the unlock. > + */ > if (conn->urg_state =3D=3D SMC_URG_VALID || conn->urg_rx_skip_pend) { > - diff =3D smc_curs_sdiff(conn->rmb_desc->len, &cons, > - &conn->urg_curs); > - if (sock_flag(sk, SOCK_URGINLINE)) { > - if (diff =3D=3D 0) { > - force =3D true; > - rc =3D 1; > - conn->urg_state =3D SMC_URG_READ; > + local_bh_disable(); > + bh_lock_sock(sk); > + if (conn->urg_state =3D=3D SMC_URG_VALID || > + conn->urg_rx_skip_pend) { [Severity: Low] Should this lockless fast-path read use READ_ONCE(conn->urg_state) paired with WRITE_ONCE() on the writers? smc_cdc_handle_urg_data_arrival() and smc_cdc_msg_recv_action() update conn->urg_state under bh_lock_sock(sk) only, concurrently with this plain unlocked load, which causes KCSAN data-race reports. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-b4-disp-ba= 1ad55e-v3-0-6834ff90c5d0@proton.me?part=3D6