Netdev List
 help / color / mirror / Atom feed
From: Tariq Toukan <tariqt@nvidia.com>
To: Rishikesh Jethwani <rjethwani@purestorage.com>, netdev@vger.kernel.org
Cc: john.fastabend@gmail.com, kuba@kernel.org, sd@queasysnail.net,
	davem@davemloft.net, pabeni@redhat.com, edumazet@google.com,
	leon@kernel.org, nils.juenemann@gmail.com
Subject: Re: [PATCH 1/2] net/mlx5e: kTLS: reject stale RX queue mapping on RX offload setup
Date: Thu, 16 Jul 2026 12:02:13 +0300	[thread overview]
Message-ID: <aca7f2fe-26ed-4ace-a8df-0364cc774ed0@nvidia.com> (raw)
In-Reply-To: <16711470-33b2-4aca-917f-8a5c2a83738e@nvidia.com>



On 16/07/2026 11:35, Tariq Toukan wrote:
> 
> 
> On 15/07/2026 1:29, Rishikesh Jethwani wrote:
>> mlx5e_ktls_sk_get_rxq() treats only the -1 sentinel from
>> sk_rx_queue_get() as special and returns all other values unchanged.
>>
>> After 'ethtool -L <dev> combined N' reduces the number of channels, a
>> socket can retain an sk_rx_queue_mapping from the previous
>> configuration that is no longer valid for the current
>> priv->channels.num. If TLS RX offload is then enabled for that socket,
>> mlx5e_ktls_add_rx() uses the stale queue index and can access a
>> channel outside the current array.
>>
>> Preserve the existing -1 -> 0 fallback for sockets that do not yet
>> have a recorded RX queue, but reject queue indices that are outside
>> the current channel range and fail setup with -EINVAL instead. Wire
>> the failure through the existing err_create_tir unwind so resources
>> allocated earlier in mlx5e_ktls_add_rx() are released cleanly.
>>
>> This addresses stale queue mappings during RX offload setup. Existing
>> offloaded sockets whose channel disappears after reconfiguration are
>> handled separately in the resync path.
>>
>> Fixes: 1182f3659357 ("net/mlx5e: kTLS, Add kTLS RX HW offload support")
>> Link: https://lore.kernel.org/netdev/20260627210635.89769-1- 
>> nils.juenemann@gmail.com/
>> Reported-by: Nils Juenemann <nils.juenemann@gmail.com>
>> Tested-by: Nils Juenemann <nils.juenemann@gmail.com>
>> Signed-off-by: Rishikesh Jethwani <rjethwani@purestorage.com>
>> ---
> 
> Thanks for your patch.
> 
>>   .../ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c  | 13 ++++++++++---
>>   1 file changed, 10 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ 
>> ktls_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c
>> index bca45679e201..232e998a8f24 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c
>> @@ -620,12 +620,15 @@ void mlx5e_ktls_handle_ctx_completion(struct 
>> mlx5e_icosq_wqe_info *wi)
>>       queue_work(rule->priv->tls->rx_wq, &rule->work);
>>   }
>> -static int mlx5e_ktls_sk_get_rxq(struct sock *sk)
>> +static int mlx5e_ktls_sk_get_rxq(struct mlx5e_priv *priv, struct sock 
>> *sk)
>>   {
>>       int rxq = sk_rx_queue_get(sk);
>>       if (unlikely(rxq == -1))
>> -        rxq = 0;
>> +        return 0;
>> +
>> +    if (unlikely(rxq >= priv->channels.num))
>> +        return -EINVAL;
>>       return rxq;
>>   }
>> @@ -673,7 +676,11 @@ int mlx5e_ktls_add_rx(struct net_device *netdev, 
>> struct sock *sk,
>>       INIT_LIST_HEAD(&priv_rx->list);
>>       spin_lock_init(&priv_rx->lock);
>> -    rxq = mlx5e_ktls_sk_get_rxq(sk);
>> +    rxq = mlx5e_ktls_sk_get_rxq(priv, sk);
>> +    if (unlikely(rxq < 0)) {
>> +        err = rxq;
>> +        goto err_create_tir;
>> +    }
> 
> This is not bullet proof.
> Here you just shorten the interval and reduce the probability of the bug.
> 
> As this flow is not protected by the state_lock, it is still possible to 
> have the num of channels changing after your read above.
> 
> IMO, this can't be resolved without holding the mutex here.
> I'm doing further research to come up with the proper solution.
> 
Please note we were not CCed on this email.
Let's make sure we're not missed on future ones.

  reply	other threads:[~2026-07-16  9:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 22:29 [PATCH net 0/2] net/mlx5e: fix NULL derefs when RX queue mapping outlives channel reconfig Rishikesh Jethwani
2026-07-14 22:29 ` [PATCH 1/2] net/mlx5e: kTLS: reject stale RX queue mapping on RX offload setup Rishikesh Jethwani
2026-07-16  8:35   ` Tariq Toukan
2026-07-16  9:02     ` Tariq Toukan [this message]
2026-07-14 22:29 ` [PATCH 2/2] net/mlx5e: kTLS: guard RX resync against stale channel index Rishikesh Jethwani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aca7f2fe-26ed-4ace-a8df-0364cc774ed0@nvidia.com \
    --to=tariqt@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nils.juenemann@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=rjethwani@purestorage.com \
    --cc=sd@queasysnail.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox