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=1796398913; b=UXJJMIawrEIlqEsRX8L9Sgh5shUHUjlVHL2vspM95B4z6BI9lYAUeS9TPLfXmWc0ST9j KotT2Rf8jODHrSQNqeHodQ3F28OIYy1+3mqvhHdjCJDjHhWizv3aB05KtiiJj8cXQheIg otDrdeKnkNuJ3vfXO276AHEDeIf6GiEuzSzH+C10YfF5mo0msvUWm4InaH+FYTx8b8M/K JCanDLvKp3NStljVgGHH1MlrvRqW0yNymfvykg+3llz2yRlLCXz37rSlr3LLZVliYB2JC Pj3u/uCexhieqx1wkAdvWCQdYMgGjynyXaJkIoGHPqGuzKaAFio5ytPnqhRSPLTO9CA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796398913; 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=5ZfYAzI/8NNtNhSmrbh/BTQX1w/4JxeAkhM6+SAyisk=; b=qypeo7xzC6vD7jpc8+lha05h3bucXvUmORYN4vIzd8C9uemOBpCjDGAAvTak9Rrj3wPI tTBWIDRuMS+LVXWaziLZuA+ENdU2Loo/4BvcgPO38/aoUO9Hhe4b9A3LmuFfJCmMwM4a9 iGwOj57/lqO+Tu8YZe0qiJZ5Ccbr5jwkb+J4G3edfLuAGy9udOi37fG2Urd1K+y7KYM0/ HW94XJ2FPEds2HbGSK5ob5DzjPfyqoY7ip0s5EverWcmCSjXW7CPg5AtovW0HVxHoidW9 2LJz+Ms4j6sz00qEaPJohzeslJHUbrGjdLnp7PKOmO0zwpLDQeJ/1KxCbvRC9S3VG0g== 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=PKjrz6Vj; 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 0E9D7606A322; Fri, 4 Dec 2026 15:41:52 +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=PKjrz6Vj Received: by smtp.kernel.org (Postfix) with ESMTPSA id C47161F000C2; Fri, 4 Dec 2026 15:41:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796398912; bh=5ZfYAzI/8NNtNhSmrbh/BTQX1w/4JxeAkhM6+SAyisk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=PKjrz6Vj9q7drhhaSqtFitTBYR5lBqWjSQfKpXNINwPKYV2BJXm70NmRvQDDTyRSt 1OrxNqdmQFMJ2mj9S7nMTpnSyytLzSgJqBsmaZAO5lNGG4PjBM5YtzuTYxl4qerpae jiYhzyf9r40dhuELUkgi69qvJJ1NwzggMfr9GZqTqAzIwQdfgI4oMBh+eLMbgQDJFO I3YmUjRDAzRKzW0GK/SXj7m0LU2gMyPL+M5dYSSHu2hu3Dj+mvkvfSZrGSk33P3lEZ 8K7FPd1bxcjOndVft3wQbeGBrza1mL0WdQ6hXzqB0VbtB/l/Wv1PGUDvAISWg03Y+0 cbLmtu0Y/y4NQ== Subject: Re: [PATCH net-next v2 1/4] net/smc: bound the SMC-Rv1 add-link rkey exchange From: netdev-bot+sashiko@kernel.org To: ermenson.sec@gmail.com Cc: alibuda@linux.alibaba.com, dust.li@linux.alibaba.com, sidraya@linux.ibm.com, mjambigi@linux.ibm.com, tonylu@linux.alibaba.com, guwen@linux.alibaba.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org Date: Fri, 04 Dec 2026 15:41:51 +0000 Message-ID: <179639891135.3146.7633707286604525482@kernel.org> In-Reply-To: <20261203153514.1440337-2-ermenson.sec@gmail.com> References: <20261203153514.1440337-2-ermenson.sec@gmail.com> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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] The commit message says "Neither check rejects a message a conforming peer can send." That holds for the round cap but not for… - [Low] The new overall deadline (SMC_LLC_RKEY_EXCHG_TIME) is only checked at the top of each round. -- net/smc: bound the SMC-Rv1 add-link rkey exchange This commit limits the SMC-Rv1 ADD_LINK_CONT rkey exchange loops in smc_llc_cli_rkey_exchange() and smc_llc_srv_rkey_exchange() to SMC_LLC_RKEY_CONT_MSG_MAX (128) rounds. It also adds an overall deadline, SMC_LLC_RKEY_EXCHG_TIME. A peer that keeps reporting num_rkeys=255 can no longer keep the loop running forever. > Cap the rounds at that derived limit and give > the exchange as a whole a deadline: the round cap on its own would > still allow 128 * SMC_LLC_WAIT_TIME of held mutex, and a deadline on > its own would still allow an unbounded number of instant rounds under > it. Neither check rejects a message a conforming peer can send. [Severity: Low] Is the last sentence accurate for the deadline? The round cap comes from the protocol. SMC_LLC_RKEY_EXCHG_TIME is a fixed (SMC_LLC_WAIT_TIME * 10), which is 20 seconds no matter how many rkeys need to be exchanged. Before this patch, a peer only had to answer each ADD_LINK_CONT within SMC_LLC_WAIT_TIME. A full 128 round exchange could therefore legitimately take up to about 256 seconds. Both smc_llc_cli_rkey_exchange() and smc_llc_srv_rkey_exchange() now run this check at the top of each round: timeo = (long)(expire - jiffies); if (timeo <= 0) { rc = -ETIMEDOUT; ... } A peer can answer every message within 2 seconds and still be aborted, if its replies average more than about 156 ms per round over 128 rounds. Slow rounds can have several causes: - the peer blocks in smc_wr_tx_get_free_slot(), for up to SMC_WR_TX_WAIT_FREE_SLOT_TIME - workqueue latency - a non-Linux SMC-Rv1 implementation Nothing is logged when this happens. smc_llc_cli_add_link() sets rc = 0 and goes to out_clear_lnk. smc_llc_srv_add_link() goes to out_err. In both cases the link group quietly runs without its second link. Could the commit message say that the deadline can reject a slow but conforming peer? Or could the deadline be derived from the number of rounds instead? > diff --git a/net/smc/smc_llc.c b/net/smc/smc_llc.c > index c9ccd8480369c..818dd84e720fc 100644 > --- a/net/smc/smc_llc.c > +++ b/net/smc/smc_llc.c [ ... ] > @@ -1359,11 +1384,25 @@ static int smc_llc_srv_rkey_exchange(struct smc_link *link, > down_write(&lgr->rmbs_lock); > num_rkeys_send = lgr->conns_num; > buf_pos = smc_llc_get_first_rmb(lgr, &buf_lst); > + expire = jiffies + SMC_LLC_RKEY_EXCHG_TIME; > do { > + long timeo; > + > + if (rounds++ >= SMC_LLC_RKEY_CONT_MSG_MAX) { > + rc = -EPROTO; > + goto out; > + } > + timeo = (long)(expire - jiffies); > + if (timeo <= 0) { > + rc = -ETIMEDOUT; > + goto out; > + } > + if (timeo > SMC_LLC_WAIT_TIME) > + timeo = SMC_LLC_WAIT_TIME; > + > smc_llc_add_link_cont(link, link_new, &num_rkeys_send, > &buf_lst, &buf_pos); > - qentry = smc_llc_wait(lgr, link, SMC_LLC_WAIT_TIME, > - SMC_LLC_ADD_LINK_CONT); > + qentry = smc_llc_wait(lgr, link, timeo, SMC_LLC_ADD_LINK_CONT); [Severity: Low] Can the exchange run past SMC_LLC_RKEY_EXCHG_TIME here? timeo is computed and capped before smc_llc_add_link_cont(), then passed unchanged to smc_llc_wait(). smc_llc_add_link_cont() can sleep: smc_llc_add_link_cont() smc_llc_add_pending_send() smc_wr_tx_get_free_slot() wait_event_interruptible_timeout(link->wr_tx_wait, ..., SMC_WR_TX_WAIT_FREE_SLOT_TIME); SMC_WR_TX_WAIT_FREE_SLOT_TIME is 10 * HZ. This wait can happen when all TX slots are busy, for example when the peer delays completions. Say a round starts with R jiffies left. It can block for up to 10 seconds in the send, then still wait up to min(R, SMC_LLC_WAIT_TIME) for the reply. The exchange can therefore end about 10 seconds past the deadline. That is also how much longer rmbs_lock, llc_conf_mutex and smc_server_lgr_pending can stay held. The later patch in this series, "net/smc: check the ADD_LINK_CONT send result in the server rkey exchange", only adds a return value check after the send. It does not recompute timeo, so the overrun is still there at the end of the series. The client loop has a similar but smaller overrun. In smc_llc_cli_rkey_exchange(), the send is the last step of a round, after the deadline-checked wait: smc_llc_flow_qentry_del(&lgr->llc_flow_lcl); rc = smc_llc_add_link_cont(link, link_new, &num_rkeys_send, &buf_lst, &buf_pos); if (rc) break; } while (num_rkeys_send || num_rkeys_recv); A send that blocks after the last wait can also run up to 10 seconds past the deadline. Would it work to compute timeo after smc_llc_add_link_cont() returns, just before smc_llc_wait(), and abort if it is <= 0? Otherwise, the comment on SMC_LLC_RKEY_EXCHG_TIME and the commit message could call the deadline approximate. > if (!qentry) { > rc = -ETIMEDOUT; > goto out; [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203153514.1440337-1-ermenson.sec%40gmail.com