lkml.org 
[lkml]   [2023]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] net: tls: fix possible race condition between do_tls_getsockopt_conf() and do_tls_setsockopt_conf()
From
On 28/2/2023 03:07, Jakub Kicinski wrote:
> 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.

I get it. I will send a v2 later.

Thanks,
Hangyu

\
 
 \ /
  Last update: 2023-03-27 00:37    [W:0.865 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site