netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: Pooja Trivedi <poojatrivedi@gmail.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
	daniel@iogearbox.net, john.fastabend@gmail.com,
	davejwatson@fb.com, aviadye@mellanox.com, borisp@mellanox.com,
	Pooja Trivedi <pooja.trivedi@stackpath.com>,
	Mallesham Jatharakonda <mallesh537@gmail.com>
Subject: Re: [PATCH V2 net 1/1] net/tls(TLS_SW): Fix list_del double free caused by a race condition in tls_tx_records
Date: Thu, 17 Oct 2019 17:25:55 -0700	[thread overview]
Message-ID: <20191017172555.3e550d33@cakuba.netronome.com> (raw)
In-Reply-To: <20191017164825.22d223d1@cakuba.netronome.com>

On Thu, 17 Oct 2019 16:48:25 -0700, Jakub Kicinski wrote:
> > The only patch that we have been able to make consistently work
> > without crashing and also without compromising performance, is the
> > previously submitted one where later thread bails out of
> > tls_tx_records. And as mentioned, it can perhaps be made more
> > efficient by rescheduling delayed work in the case where work handler
> > thread turns out to be the later thread that has to bail.  
> 
> Let me try to find a way to repro this reliably without any funky
> accelerators. The sleep in do_tcp_sendpages() should affect all cases.
> I should have some time today and tomorrow to look into this, bear with
> me..

Could you please try this?

---->8-----

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index c2b5e0d2ba1a..ab7b0af162a7 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1204,12 +1204,10 @@ static int tls_sw_do_sendpage(struct sock *sk, struct page *page,
 		goto alloc_payload;
 	}
 
-	if (num_async) {
-		/* Transmit if any encryptions have completed */
-		if (test_and_clear_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask)) {
-			cancel_delayed_work(&ctx->tx_work.work);
-			tls_tx_records(sk, flags);
-		}
+	/* Transmit if any encryptions have completed */
+	if (test_and_clear_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask)) {
+		cancel_delayed_work(&ctx->tx_work.work);
+		tls_tx_records(sk, flags);
 	}
 sendpage_end:
 	ret = sk_stream_error(sk, flags, ret);
@@ -2171,7 +2169,8 @@ static void tx_work_handler(struct work_struct *work)
 	if (!test_and_clear_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask))
 		return;
 	lock_sock(sk);
-	tls_tx_records(sk, -1);
+	if (!sk->sk_write_pending)
+		tls_tx_records(sk, -1);
 	release_sock(sk);
 }
 

      reply	other threads:[~2019-10-18  0:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAOrEdsmpHT-=zH9zyHv=pLX2ENb1S0AnkrcWVgMxqWrxKsF3yw@mail.gmail.com>
     [not found] ` <CAOrEdsmxstWoBz2AotrTx_OBFN_jycqnSqtsvLxuCLGtKKi_dA@mail.gmail.com>
2019-09-09 17:46   ` [PATCH net 0/1] net/tls(TLS_SW): double free in tls_tx_records Pooja Trivedi
2019-09-09 18:15     ` [PATCH net 1/1] net/tls(TLS_SW): Fix list_del double free caused by a race condition " Pooja Trivedi
2019-09-17 21:13       ` [PATCH V2 " Pooja Trivedi
2019-09-17 21:24         ` Pooja Trivedi
2019-09-18 21:25         ` Jakub Kicinski
2019-09-18 21:37           ` Pooja Trivedi
2019-09-18 21:45             ` Jakub Kicinski
2019-09-22  3:19               ` Pooja Trivedi
2019-09-24  0:28                 ` Jakub Kicinski
2019-09-24 16:48                   ` Pooja Trivedi
2019-09-28  0:37                     ` Jakub Kicinski
2019-10-09 16:57                       ` Pooja Trivedi
2019-10-17 23:48                         ` Jakub Kicinski
2019-10-18  0:25                           ` Jakub Kicinski [this message]

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=20191017172555.3e550d33@cakuba.netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=aviadye@mellanox.com \
    --cc=borisp@mellanox.com \
    --cc=daniel@iogearbox.net \
    --cc=davejwatson@fb.com \
    --cc=davem@davemloft.net \
    --cc=john.fastabend@gmail.com \
    --cc=mallesh537@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pooja.trivedi@stackpath.com \
    --cc=poojatrivedi@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).