public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Hangyu Hua <hbh25y@gmail.com>
Cc: Sabrina Dubroca <sd@queasysnail.net>,
	Florian Westphal <fw@strlen.de>,
	borisp@nvidia.com, john.fastabend@gmail.com, davem@davemloft.net,
	edumazet@google.com, pabeni@redhat.com, davejwatson@fb.com,
	aviadye@mellanox.com, ilyal@mellanox.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: tls: fix possible race condition between do_tls_getsockopt_conf() and do_tls_setsockopt_conf()
Date: Mon, 27 Feb 2023 11:07:50 -0800	[thread overview]
Message-ID: <20230227110750.6988fca5@kernel.org> (raw)
In-Reply-To: <52faaa10-f3e4-bca9-4bff-6f1ea7d26593@gmail.com>

On Mon, 27 Feb 2023 11:26:18 +0800 Hangyu Hua wrote:
> In order to reduce ambiguity, I think it may be a good idea only to
> lock do_tls_getsockopt_conf() like we did in do_tls_setsockopt()
> 
> It will look like:
> 
> static int do_tls_getsockopt(struct sock *sk, int optname,
> 			     char __user *optval, int __user *optlen)
> {
> 	int rc = 0;
> 
> 	switch (optname) {
> 	case TLS_TX:
> 	case TLS_RX:
> +		lock_sock(sk);
> 		rc = do_tls_getsockopt_conf(sk, optval, optlen,
> 					    optname == TLS_TX);
> +		release_sock(sk);
> 		break;
> 	case TLS_TX_ZEROCOPY_RO:
> 		rc = do_tls_getsockopt_tx_zc(sk, optval, optlen);
> 		break;
> 	case TLS_RX_EXPECT_NO_PAD:
> 		rc = do_tls_getsockopt_no_pad(sk, optval, optlen);
> 		break;
> 	default:
> 		rc = -ENOPROTOOPT;
> 		break;
> 	}
> 	return rc;
> }
> 
> Of cause, I will clean the lock in do_tls_getsockopt_conf(). What do you
> guys think?

I'd suggest to take the lock around the entire switch statement.

  reply	other threads:[~2023-02-27 19:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 10:58 [PATCH] net: tls: fix possible race condition between do_tls_getsockopt_conf() and do_tls_setsockopt_conf() Hangyu Hua
2023-02-24 12:06 ` Florian Westphal
2023-02-24 18:55   ` Jakub Kicinski
2023-02-24 20:22     ` Sabrina Dubroca
2023-02-24 21:06       ` Jakub Kicinski
2023-02-24 21:48         ` Sabrina Dubroca
2023-02-24 22:17           ` Jakub Kicinski
2023-02-27  3:26             ` Hangyu Hua
2023-02-27 19:07               ` Jakub Kicinski [this message]
2023-02-28  1:48                 ` Hangyu Hua

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=20230227110750.6988fca5@kernel.org \
    --to=kuba@kernel.org \
    --cc=aviadye@mellanox.com \
    --cc=borisp@nvidia.com \
    --cc=davejwatson@fb.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=hbh25y@gmail.com \
    --cc=ilyal@mellanox.com \
    --cc=john.fastabend@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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