@@ -405,13 +405,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
405
405
rc = - EINVAL ;
406
406
goto out ;
407
407
}
408
- lock_sock (sk );
409
408
memcpy (crypto_info_aes_gcm_128 -> iv ,
410
409
cctx -> iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE ,
411
410
TLS_CIPHER_AES_GCM_128_IV_SIZE );
412
411
memcpy (crypto_info_aes_gcm_128 -> rec_seq , cctx -> rec_seq ,
413
412
TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE );
414
- release_sock (sk );
415
413
if (copy_to_user (optval ,
416
414
crypto_info_aes_gcm_128 ,
417
415
sizeof (* crypto_info_aes_gcm_128 )))
@@ -429,13 +427,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
429
427
rc = - EINVAL ;
430
428
goto out ;
431
429
}
432
- lock_sock (sk );
433
430
memcpy (crypto_info_aes_gcm_256 -> iv ,
434
431
cctx -> iv + TLS_CIPHER_AES_GCM_256_SALT_SIZE ,
435
432
TLS_CIPHER_AES_GCM_256_IV_SIZE );
436
433
memcpy (crypto_info_aes_gcm_256 -> rec_seq , cctx -> rec_seq ,
437
434
TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE );
438
- release_sock (sk );
439
435
if (copy_to_user (optval ,
440
436
crypto_info_aes_gcm_256 ,
441
437
sizeof (* crypto_info_aes_gcm_256 )))
@@ -451,13 +447,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
451
447
rc = - EINVAL ;
452
448
goto out ;
453
449
}
454
- lock_sock (sk );
455
450
memcpy (aes_ccm_128 -> iv ,
456
451
cctx -> iv + TLS_CIPHER_AES_CCM_128_SALT_SIZE ,
457
452
TLS_CIPHER_AES_CCM_128_IV_SIZE );
458
453
memcpy (aes_ccm_128 -> rec_seq , cctx -> rec_seq ,
459
454
TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE );
460
- release_sock (sk );
461
455
if (copy_to_user (optval , aes_ccm_128 , sizeof (* aes_ccm_128 )))
462
456
rc = - EFAULT ;
463
457
break ;
@@ -472,13 +466,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
472
466
rc = - EINVAL ;
473
467
goto out ;
474
468
}
475
- lock_sock (sk );
476
469
memcpy (chacha20_poly1305 -> iv ,
477
470
cctx -> iv + TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE ,
478
471
TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE );
479
472
memcpy (chacha20_poly1305 -> rec_seq , cctx -> rec_seq ,
480
473
TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE );
481
- release_sock (sk );
482
474
if (copy_to_user (optval , chacha20_poly1305 ,
483
475
sizeof (* chacha20_poly1305 )))
484
476
rc = - EFAULT ;
@@ -493,13 +485,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
493
485
rc = - EINVAL ;
494
486
goto out ;
495
487
}
496
- lock_sock (sk );
497
488
memcpy (sm4_gcm_info -> iv ,
498
489
cctx -> iv + TLS_CIPHER_SM4_GCM_SALT_SIZE ,
499
490
TLS_CIPHER_SM4_GCM_IV_SIZE );
500
491
memcpy (sm4_gcm_info -> rec_seq , cctx -> rec_seq ,
501
492
TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE );
502
- release_sock (sk );
503
493
if (copy_to_user (optval , sm4_gcm_info , sizeof (* sm4_gcm_info )))
504
494
rc = - EFAULT ;
505
495
break ;
@@ -513,13 +503,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
513
503
rc = - EINVAL ;
514
504
goto out ;
515
505
}
516
- lock_sock (sk );
517
506
memcpy (sm4_ccm_info -> iv ,
518
507
cctx -> iv + TLS_CIPHER_SM4_CCM_SALT_SIZE ,
519
508
TLS_CIPHER_SM4_CCM_IV_SIZE );
520
509
memcpy (sm4_ccm_info -> rec_seq , cctx -> rec_seq ,
521
510
TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE );
522
- release_sock (sk );
523
511
if (copy_to_user (optval , sm4_ccm_info , sizeof (* sm4_ccm_info )))
524
512
rc = - EFAULT ;
525
513
break ;
@@ -535,13 +523,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
535
523
rc = - EINVAL ;
536
524
goto out ;
537
525
}
538
- lock_sock (sk );
539
526
memcpy (crypto_info_aria_gcm_128 -> iv ,
540
527
cctx -> iv + TLS_CIPHER_ARIA_GCM_128_SALT_SIZE ,
541
528
TLS_CIPHER_ARIA_GCM_128_IV_SIZE );
542
529
memcpy (crypto_info_aria_gcm_128 -> rec_seq , cctx -> rec_seq ,
543
530
TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE );
544
- release_sock (sk );
545
531
if (copy_to_user (optval ,
546
532
crypto_info_aria_gcm_128 ,
547
533
sizeof (* crypto_info_aria_gcm_128 )))
@@ -559,13 +545,11 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
559
545
rc = - EINVAL ;
560
546
goto out ;
561
547
}
562
- lock_sock (sk );
563
548
memcpy (crypto_info_aria_gcm_256 -> iv ,
564
549
cctx -> iv + TLS_CIPHER_ARIA_GCM_256_SALT_SIZE ,
565
550
TLS_CIPHER_ARIA_GCM_256_IV_SIZE );
566
551
memcpy (crypto_info_aria_gcm_256 -> rec_seq , cctx -> rec_seq ,
567
552
TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE );
568
- release_sock (sk );
569
553
if (copy_to_user (optval ,
570
554
crypto_info_aria_gcm_256 ,
571
555
sizeof (* crypto_info_aria_gcm_256 )))
@@ -614,11 +598,9 @@ static int do_tls_getsockopt_no_pad(struct sock *sk, char __user *optval,
614
598
if (len < sizeof (value ))
615
599
return - EINVAL ;
616
600
617
- lock_sock (sk );
618
601
value = - EINVAL ;
619
602
if (ctx -> rx_conf == TLS_SW || ctx -> rx_conf == TLS_HW )
620
603
value = ctx -> rx_no_pad ;
621
- release_sock (sk );
622
604
if (value < 0 )
623
605
return value ;
624
606
@@ -635,6 +617,8 @@ static int do_tls_getsockopt(struct sock *sk, int optname,
635
617
{
636
618
int rc = 0 ;
637
619
620
+ lock_sock (sk );
621
+
638
622
switch (optname ) {
639
623
case TLS_TX :
640
624
case TLS_RX :
@@ -651,6 +635,9 @@ static int do_tls_getsockopt(struct sock *sk, int optname,
651
635
rc = - ENOPROTOOPT ;
652
636
break ;
653
637
}
638
+
639
+ release_sock (sk );
640
+
654
641
return rc ;
655
642
}
656
643
0 commit comments