Article View: linux.kernel.netdev
Article #26852Re: [PATCH net v3 6/7] net/smc: update the urgent state under the socket spinlock
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 09:49
Date: Fri, 04 Dec 2026 09:49
97 lines
11669 bytes
11669 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] net/smc: unmarked lockless conn->urg_state access in
smc_rx_update_consumer()
--
> diff --git a/net/smc/smc_rx.c b/net/smc/smc_rx.c
> --- 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 *smc,
>
> smc_curs_add(conn->rmb_desc->len, &cons, len);
>
> - /* 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 == SMC_URG_VALID || conn->urg_rx_skip_pend) {
> - diff = smc_curs_sdiff(conn->rmb_desc->len, &cons,
> - &conn->urg_curs);
> - if (sock_flag(sk, SOCK_URGINLINE)) {
> - if (diff == 0) {
> - force = true;
> - rc = 1;
> - conn->urg_state = SMC_URG_READ;
> + local_bh_disable();
> + bh_lock_sock(sk);
> + if (conn->urg_state == SMC_URG_VALID ||
> + conn->urg_rx_skip_pend) {
> + diff = smc_curs_sdiff(conn->rmb_desc->len, &cons,
> + &conn->urg_curs);
> + if (sock_flag(sk, SOCK_URGINLINE)) {
> + if (diff == 0) {
> + force = true;
> + rc = 1;
> + conn->urg_state = SMC_URG_READ;
> + }
> + } else {
> + if (diff == 1) {
> + /* skip urgent byte */
> + force = true;
> + smc_curs_add(conn->rmb_desc->len,
> + &cons, 1);
> + conn->urg_rx_skip_pend = false;
> + } else if (diff < -1)
> + /* we read past urgent byte */
> + conn->urg_state = SMC_URG_READ;
> }
> - } else {
> - if (diff == 1) {
> - /* skip urgent byte */
> - force = true;
> - smc_curs_add(conn->rmb_desc->len, &cons, 1);
> - conn->urg_rx_skip_pend = false;
> - } else if (diff < -1)
> - /* we read past urgent byte */
> - conn->urg_state = SMC_URG_READ;
> }
> + bh_unlock_sock(sk);
> + local_bh_enable();
> }
>
> smc_curs_copy(&conn->local_tx_ctrl.cons, &cons, conn);
[Severity: Low]
With this patch the outer test becomes an intentional lockless fast
path. It is still a plain load of conn->urg_state and
conn->urg_rx_skip_pend. Meanwhile smc_cdc_handle_urg_data_arrival()
and smc_cdc_msg_recv_action() store to conn->urg_state from
softirq/tasklet context while holding only bh_lock_sock().
Nothing breaks functionally. The re-check under the spinlock decides
what actually happens, and a mark missed by the outer test is picked
up on the next call, as your comment says. But KCSAN will report this
as a data race, and the compiler is free to fuse or reload the
unmarked access.
Since the patch deliberately turns this into a double-checked
pattern, could the outer test use READ_ONCE() for both fields? The
writers would then need matching WRITE_ONCE(): the cdc paths, plus
the stores in smc_rx_update_consumer() and smc_rx_recv_urg().
The other lockless readers of urg_state already have the same issue:
smc_rx_recvmsg_data_available(), smc_rx_recvmsg() and smc_poll(). If
you would rather keep this fix minimal for stable, a follow-up that
annotates all of them would be fine too.
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-b4-disp-ba1ad55e-v3-0-6834ff90c5d0%40proton.me
Technical Details
Message-ID:
<179637777112.3146.15137668627665027393@kernel.org>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377227-linux-kernel-netdev=dewy.ruReferences:
<20261203-b4-disp-ba1ad55e-v3-6-6834ff90c5d0@proton.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377227-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v3 6/7] net/smc: update the urgent state under the socket spinlock Date: Fri, 04 Dec 2026 09:49:31 +0000 Organization: Usenet Network Message-ID: <179637777112.3146.15137668627665027393@kernel.org> References: <20261203-b4-disp-ba1ad55e-v3-6-6834ff90c5d0@proton.me> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2730048"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:3X7Myo5rGFHDhjnHAfwDfTVo6ro= sha256:jnSeoMopxp87jCHguBz0VUGSQlPRM46/cYHShPWk90A= sha1:9bHwX8B20zF/mp9mZOZMAySDUZE= sha256:Q6vZlJ8+EipUUQdDJYl1GtST5BxHsNQ/ozKvLgFe5t4= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id CEC83117B88; Fri, 4 Dec 2026 12:49:56 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.639 X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fq-TnZVqaSVZ; Fri, 4 Dec 2026 12:49:54 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377227-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 980AE117B87; Fri, 4 Dec 2026 12:49:45 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id A135C2C444; Fri, 4 Dec 2026 09:49:34 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796377773; b=5RWAWajMAu+7+YiwA+ZDB0DMq98ojqoMikj9KAMvjyikZ11fktAxWGXKB1exsmtxQSvh 2ezxRZUVYPmSv6AwiaWVo4v7USFcj1IFE318aqnHtqBGt4dviF72P8ws5anp1haOgWknf BQUPoEmCiWqeGMVm4JfRpoXveSZu754HNXvGusCeWjIVqu4d43ojifhxhT6HJe3EKlhtQ ig9ZoM/B2802smb2pUDOeVE17pvxH4WMgp1sotgqdSe9eYl7GD+w5ca9gGtz409Gdz7RX a4Ls5Q0IE4KOl8I0vmadQezzGRr03AwFgi1fDkiu6GZrz6WnOS95JquOH6NmQhckMWg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796377773; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=wo2RTDmEDPAh7dQVkRKRiqfhV6ioHdB3GvHT/uMnOvE=; b=TnAfvdQvqzbTjrrqnQ0Xm0VVa7O9/UIGtaOioUArolChOTfZFAps5bU10l8K/hW5RvSW PajzV0JY/36i2v8Pm6aoiWoqkRLvmYIeJfVcMgu/ephsp9crJUxZBakMVDUV1DEhyLC+D Iz3xN7ACLhVLNY6K5y0DTBKO7zNUn0AGyXjAahwvoot56DsOBnoDEWoa0oyPQvnF6J17J FTu20cv9lNc0Z1sbjzlGeSwtwBgCMwQhKN5SqGYlJ3EWUqWOS11mLs4Bq3osUqb2oJzCM AQ9kYfCAydo2DPlrt01MNtSLKB7zwiZFmdB+JnbYoXZ3DNfg7x2wIA+qua1BW3pIHQQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GueSlw23; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE65A606A33C; Fri, 4 Dec 2026 09:49:33 +0000 (UTC) X-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=GueSlw23 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796377773; b=maPc6pfvs7xDi83TSAPrwMYYLzFS/FP7BYwGu6H8bTmnQArT8w1zJtyfCjzhDLMH59Tj MUvGvHT4SwSVfEZ4JHZ469ileyFeLdmopmZtGKJCpQ7xGpJWuq36kfK/irOkMCb4j0HnB mvswfBbWqbn7dFUgPW+eFz0SoQO9U9iae2Qhma1Uk5Zxkg+5jQsct0ToxFrh7eOB00W0F ZgvNir+LwABTOmlFZPEJ5Ij38U4ulYPvhSM65Hfnug0wcnRTPYv13jA5wmkaaX7YsKttt JpHO1M4fG0H4Ndpekke6/5B040tsfkhls/Mg39I1BxFqAR11hTYpwhJZm576t42gV3A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796377773; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=wo2RTDmEDPAh7dQVkRKRiqfhV6ioHdB3GvHT/uMnOvE=; b=I7GkDOu9LLl8Owm9D/XwzhlOoXfEDf2Nss3rEVEAMMUYF0Te9LDLjHXUdQ7hMVCT/A+z 5u/weCQDK7jwtAjQKWxn1ihedcBbygcMFAdhk+Qpn4OoH6mZLgvu9mwHIUADARrXEECn1 ah5cuuzOFby85ryYGkfibuGpI4v3FXNungMPmUh+6BnQP6lb/gezXV7iGN5F4b3PWO28F CKHa1vMBFbQ7lJ4AmEgIdEoeBEaPe9G50Bri/7atuy6MrRJ8n0dWQB4jJy4DlxHNsEIHY 4CnbuR+N8j9WKp3hvphRi6w7QMYTpuoY8mxkijXSKocLhrQPM8+9cuNFyAgfWJlhZEg== X-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=GueSlw23; arc=none smtp.remote-ip=100.103.45.18 X-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 F02C0606A33F; Fri, 4 Dec 2026 09:49:32 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F71D1F00934; Fri, 4 Dec 2026 09:49:31 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796377772; bh=wo2RTDmEDPAh7dQVkRKRiqfhV6ioHdB3GvHT/uMnOvE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=GueSlw23s8/Lyyh66e5yPD7VCbU1K4wPeL7FAnz31JX2QdY6XBebLvIKMzW5aP9mH PdtuSRaILnfj2ApkQTMQQ5YGprizzxAcBxSoVEs89vewhZc8m5fuNyA2p+ULCaSXlO YkDH/G4cAIxIx5Wv8f9oHYuQgwORPnNu8tg0N3tujM66x76eBJClujnmPLjCthyk3u rXuZ2zrA0Qf1AS0Bb59fhwPVLsaVGljKDeSa4k4KVfckdN0nbDUuR+IVqcR6lg/Arz Ci1PK/+anlg+MfY7+R+2+U2pN1sA/7+cwhZpEt16zlVCwHmOVHTzGrjJ3FvWF0K1Lh 99ySelFNL0znA== X-Cc: edumazet@kernel.org, pabeni@redhat.com, davem@davemloft.net, kuba@kernel.org, mjambigi@linux.ibm.com, sidraya@linux.ibm.com, alibuda@linux.alibaba.com, willemb@google.com, dust.li@linux.alibaba.com, guwen@linux.alibaba.com, guangguan.wang@linux.alibaba.com, tonylu@linux.alibaba.com, ubraun@linux.ibm.com, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, hidayath@linux.ibm.com, horms@kernel.org, wenjia@linux.ibm.com, linux-kernel@vger.kernel.org, raspl@linux.ibm.com, netdev@vger.kernel.org X-In-Reply-To: <20261203-b4-disp-ba1ad55e-v3-6-6834ff90c5d0@proton.me> X-sashiko-severity: Low X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list