All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Maxim Mikityanskiy <maximmi@nvidia.com>
Cc: Tariq Toukan <tariqt@nvidia.com>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"edumazet@google.com" <edumazet@google.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Boris Pismenny <borisp@nvidia.com>,
	"john.fastabend@gmail.com" <john.fastabend@gmail.com>,
	"davem@davemloft.net" <davem@davemloft.net>
Subject: Re: [PATCH net] net/tls: Remove the context from the list in tls_device_down
Date: Mon, 25 Jul 2022 11:37:01 -0700	[thread overview]
Message-ID: <20220725113701.18774af6@kernel.org> (raw)
In-Reply-To: <f085d0f65adc41f255a1a9b1bae7b0767ff3c15a.camel@nvidia.com>

On Mon, 25 Jul 2022 14:35:08 +0000 Maxim Mikityanskiy wrote:
> On Fri, 2022-07-22 at 15:04 -0700, Jakub Kicinski wrote:
> > On Thu, 21 Jul 2022 12:11:27 +0300 Maxim Mikityanskiy wrote:  
> > > tls_device_down takes a reference on all contexts it's going to move to
> > > the degraded state (software fallback). If sk_destruct runs afterwards,
> > > it can reduce the reference counter back to 1 and return early without
> > > destroying the context. Then tls_device_down will release the reference
> > > it took and call tls_device_free_ctx. However, the context will still
> > > stay in tls_device_down_list forever. The list will contain an item,
> > > memory for which is released, making a memory corruption possible.
> > > 
> > > Fix the above bug by properly removing the context from all lists before
> > > any call to tls_device_free_ctx.  
> > 
> > SGTM. The tls_device_down_list has no use, tho, is the plan to remove
> > it later as a cleanup or your upcoming patches make use of it?  
> 
> I don't plan to remove it. Right, we never iterate over it, so instead
> of moving the context to tls_device_down_list, we can remove it from
> list, as long as we check to not remove it second time on destruction.
> 
> However, this way we don't gain anything, but lose a debugging
> opportunity: for example, when list debugging is enabled, double
> list_del will be detected.

I see. I haven't actually checked if list_del_init() would do as well
here.

> So, it doesn't make sense to me to remove this list, but if you still
> want to do it, Tariq has a patch for this.

Fine either way, thanks for the explanation.

  reply	other threads:[~2022-07-25 18:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-21  9:11 [PATCH net] net/tls: Remove the context from the list in tls_device_down Maxim Mikityanskiy
2022-07-22 22:04 ` Jakub Kicinski
2022-07-25 14:35   ` Maxim Mikityanskiy
2022-07-25 18:37     ` Jakub Kicinski [this message]
2022-07-24 20:50 ` patchwork-bot+netdevbpf

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=20220725113701.18774af6@kernel.org \
    --to=kuba@kernel.org \
    --cc=borisp@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=maximmi@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tariqt@nvidia.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.