tree: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master head: bd4d08daeb959234a9f8365037b0fefa6ae790c6 commit: a42055e8d2c30d4decfc13ce943d09c7b9dad221 [207/219] net/tls: Add support for async encryption of records for performance
smatch warnings: net/tls/tls_sw.c:885 tls_sw_sendmsg() error: uninitialized symbol 'ret'. net/tls/tls_sw.c:1014 tls_sw_sendpage() error: uninitialized symbol 'ret'. # https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=a42055e8d2c30d4decfc13ce943d09c7b9dad221 git remote add net-next https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git git remote update net-next git checkout a42055e8d2c30d4decfc13ce943d09c7b9dad221 vim +/ret +885 net/tls/tls_sw.c a42055e8 Vakul Garg 2018-09-21 693 a42055e8 Vakul Garg 2018-09-21 694 int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) a42055e8 Vakul Garg 2018-09-21 695 { 3c4d7559 Dave Watson 2017-06-14 696 long timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT); a42055e8 Vakul Garg 2018-09-21 697 struct tls_context *tls_ctx = tls_get_ctx(sk); a42055e8 Vakul Garg 2018-09-21 698 struct tls_sw_context_tx *ctx = tls_sw_ctx_tx(tls_ctx); a42055e8 Vakul Garg 2018-09-21 699 struct crypto_tfm *tfm = crypto_aead_tfm(ctx->aead_send); a42055e8 Vakul Garg 2018-09-21 700 bool async_capable = tfm->__crt_alg->cra_flags & CRYPTO_ALG_ASYNC; a42055e8 Vakul Garg 2018-09-21 701 unsigned char record_type = TLS_RECORD_TYPE_DATA; a42055e8 Vakul Garg 2018-09-21 702 bool is_kvec = msg->msg_iter.type & ITER_KVEC; 3c4d7559 Dave Watson 2017-06-14 703 bool eor = !(msg->msg_flags & MSG_MORE); 3c4d7559 Dave Watson 2017-06-14 704 size_t try_to_copy, copied = 0; a42055e8 Vakul Garg 2018-09-21 705 struct tls_rec *rec; a42055e8 Vakul Garg 2018-09-21 706 int required_size; a42055e8 Vakul Garg 2018-09-21 707 int num_async = 0; 3c4d7559 Dave Watson 2017-06-14 708 bool full_record; a42055e8 Vakul Garg 2018-09-21 709 int record_room; a42055e8 Vakul Garg 2018-09-21 710 int num_zc = 0; 3c4d7559 Dave Watson 2017-06-14 711 int orig_size; a42055e8 Vakul Garg 2018-09-21 712 int ret; 3c4d7559 Dave Watson 2017-06-14 713 3c4d7559 Dave Watson 2017-06-14 714 if (msg->msg_flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL)) 3c4d7559 Dave Watson 2017-06-14 715 return -ENOTSUPP; 3c4d7559 Dave Watson 2017-06-14 716 3c4d7559 Dave Watson 2017-06-14 717 lock_sock(sk); 3c4d7559 Dave Watson 2017-06-14 718 a42055e8 Vakul Garg 2018-09-21 719 /* Wait till there is any pending write on socket */ a42055e8 Vakul Garg 2018-09-21 720 if (unlikely(sk->sk_write_pending)) { a42055e8 Vakul Garg 2018-09-21 721 ret = wait_on_pending_writer(sk, &timeo); a42055e8 Vakul Garg 2018-09-21 722 if (unlikely(ret)) 3c4d7559 Dave Watson 2017-06-14 723 goto send_end; a42055e8 Vakul Garg 2018-09-21 724 } 3c4d7559 Dave Watson 2017-06-14 725 3c4d7559 Dave Watson 2017-06-14 726 if (unlikely(msg->msg_controllen)) { 3c4d7559 Dave Watson 2017-06-14 727 ret = tls_proccess_cmsg(sk, msg, &record_type); a42055e8 Vakul Garg 2018-09-21 728 if (ret) { a42055e8 Vakul Garg 2018-09-21 729 if (ret == -EINPROGRESS) a42055e8 Vakul Garg 2018-09-21 730 num_async++; a42055e8 Vakul Garg 2018-09-21 731 else if (ret != -EAGAIN) 3c4d7559 Dave Watson 2017-06-14 732 goto send_end; 3c4d7559 Dave Watson 2017-06-14 733 } a42055e8 Vakul Garg 2018-09-21 734 } 3c4d7559 Dave Watson 2017-06-14 735 3c4d7559 Dave Watson 2017-06-14 736 while (msg_data_left(msg)) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I guess Smatch is complaining that it can't be sure that we always enter this loop. 50/50 it's a false positive. 3c4d7559 Dave Watson 2017-06-14 737 if (sk->sk_err) { 30be8f8d r.her...@avm.de 2018-01-12 738 ret = -sk->sk_err; 3c4d7559 Dave Watson 2017-06-14 739 goto send_end; 3c4d7559 Dave Watson 2017-06-14 740 } 3c4d7559 Dave Watson 2017-06-14 741 a42055e8 Vakul Garg 2018-09-21 742 rec = get_rec(sk); a42055e8 Vakul Garg 2018-09-21 743 if (!rec) { a42055e8 Vakul Garg 2018-09-21 744 ret = -ENOMEM; a42055e8 Vakul Garg 2018-09-21 745 goto send_end; a42055e8 Vakul Garg 2018-09-21 746 } a42055e8 Vakul Garg 2018-09-21 747 a42055e8 Vakul Garg 2018-09-21 748 orig_size = rec->sg_plaintext_size; 3c4d7559 Dave Watson 2017-06-14 749 full_record = false; 3c4d7559 Dave Watson 2017-06-14 750 try_to_copy = msg_data_left(msg); a42055e8 Vakul Garg 2018-09-21 751 record_room = TLS_MAX_PAYLOAD_SIZE - rec->sg_plaintext_size; 3c4d7559 Dave Watson 2017-06-14 752 if (try_to_copy >= record_room) { 3c4d7559 Dave Watson 2017-06-14 753 try_to_copy = record_room; 3c4d7559 Dave Watson 2017-06-14 754 full_record = true; 3c4d7559 Dave Watson 2017-06-14 755 } 3c4d7559 Dave Watson 2017-06-14 756 a42055e8 Vakul Garg 2018-09-21 757 required_size = rec->sg_plaintext_size + try_to_copy + dbe42559 Dave Watson 2018-03-22 758 tls_ctx->tx.overhead_size; 3c4d7559 Dave Watson 2017-06-14 759 3c4d7559 Dave Watson 2017-06-14 760 if (!sk_stream_memory_free(sk)) 3c4d7559 Dave Watson 2017-06-14 761 goto wait_for_sndbuf; a42055e8 Vakul Garg 2018-09-21 762 3c4d7559 Dave Watson 2017-06-14 763 alloc_encrypted: 3c4d7559 Dave Watson 2017-06-14 764 ret = alloc_encrypted_sg(sk, required_size); 3c4d7559 Dave Watson 2017-06-14 765 if (ret) { 3c4d7559 Dave Watson 2017-06-14 766 if (ret != -ENOSPC) 3c4d7559 Dave Watson 2017-06-14 767 goto wait_for_memory; 3c4d7559 Dave Watson 2017-06-14 768 3c4d7559 Dave Watson 2017-06-14 769 /* Adjust try_to_copy according to the amount that was 3c4d7559 Dave Watson 2017-06-14 770 * actually allocated. The difference is due 3c4d7559 Dave Watson 2017-06-14 771 * to max sg elements limit 3c4d7559 Dave Watson 2017-06-14 772 */ a42055e8 Vakul Garg 2018-09-21 773 try_to_copy -= required_size - rec->sg_encrypted_size; 3c4d7559 Dave Watson 2017-06-14 774 full_record = true; 3c4d7559 Dave Watson 2017-06-14 775 } a42055e8 Vakul Garg 2018-09-21 776 a42055e8 Vakul Garg 2018-09-21 777 if (!is_kvec && (full_record || eor) && !async_capable) { 3c4d7559 Dave Watson 2017-06-14 778 ret = zerocopy_from_iter(sk, &msg->msg_iter, a42055e8 Vakul Garg 2018-09-21 779 try_to_copy, &rec->sg_plaintext_num_elem, a42055e8 Vakul Garg 2018-09-21 780 &rec->sg_plaintext_size, a42055e8 Vakul Garg 2018-09-21 781 rec->sg_plaintext_data, a42055e8 Vakul Garg 2018-09-21 782 ARRAY_SIZE(rec->sg_plaintext_data), 2da19ed3 Doron Roberts-Kedes 2018-07-26 783 true); 3c4d7559 Dave Watson 2017-06-14 784 if (ret) 3c4d7559 Dave Watson 2017-06-14 785 goto fallback_to_reg_send; 3c4d7559 Dave Watson 2017-06-14 786 a42055e8 Vakul Garg 2018-09-21 787 num_zc++; 3c4d7559 Dave Watson 2017-06-14 788 copied += try_to_copy; 3c4d7559 Dave Watson 2017-06-14 789 ret = tls_push_record(sk, msg->msg_flags, record_type); a42055e8 Vakul Garg 2018-09-21 790 if (ret) { a42055e8 Vakul Garg 2018-09-21 791 if (ret == -EINPROGRESS) a42055e8 Vakul Garg 2018-09-21 792 num_async++; a42055e8 Vakul Garg 2018-09-21 793 else if (ret != -EAGAIN) 3c4d7559 Dave Watson 2017-06-14 794 goto send_end; a42055e8 Vakul Garg 2018-09-21 795 } 5a3611ef Doron Roberts-Kedes 2018-07-26 796 continue; 3c4d7559 Dave Watson 2017-06-14 797 3c4d7559 Dave Watson 2017-06-14 798 fallback_to_reg_send: a42055e8 Vakul Garg 2018-09-21 799 trim_sg(sk, rec->sg_plaintext_data, a42055e8 Vakul Garg 2018-09-21 800 &rec->sg_plaintext_num_elem, a42055e8 Vakul Garg 2018-09-21 801 &rec->sg_plaintext_size, 3c4d7559 Dave Watson 2017-06-14 802 orig_size); 3c4d7559 Dave Watson 2017-06-14 803 } 3c4d7559 Dave Watson 2017-06-14 804 a42055e8 Vakul Garg 2018-09-21 805 required_size = rec->sg_plaintext_size + try_to_copy; 3c4d7559 Dave Watson 2017-06-14 806 alloc_plaintext: 3c4d7559 Dave Watson 2017-06-14 807 ret = alloc_plaintext_sg(sk, required_size); 3c4d7559 Dave Watson 2017-06-14 808 if (ret) { 3c4d7559 Dave Watson 2017-06-14 809 if (ret != -ENOSPC) 3c4d7559 Dave Watson 2017-06-14 810 goto wait_for_memory; 3c4d7559 Dave Watson 2017-06-14 811 3c4d7559 Dave Watson 2017-06-14 812 /* Adjust try_to_copy according to the amount that was 3c4d7559 Dave Watson 2017-06-14 813 * actually allocated. The difference is due 3c4d7559 Dave Watson 2017-06-14 814 * to max sg elements limit 3c4d7559 Dave Watson 2017-06-14 815 */ a42055e8 Vakul Garg 2018-09-21 816 try_to_copy -= required_size - rec->sg_plaintext_size; 3c4d7559 Dave Watson 2017-06-14 817 full_record = true; 3c4d7559 Dave Watson 2017-06-14 818 a42055e8 Vakul Garg 2018-09-21 819 trim_sg(sk, rec->sg_encrypted_data, a42055e8 Vakul Garg 2018-09-21 820 &rec->sg_encrypted_num_elem, a42055e8 Vakul Garg 2018-09-21 821 &rec->sg_encrypted_size, a42055e8 Vakul Garg 2018-09-21 822 rec->sg_plaintext_size + dbe42559 Dave Watson 2018-03-22 823 tls_ctx->tx.overhead_size); 3c4d7559 Dave Watson 2017-06-14 824 } 3c4d7559 Dave Watson 2017-06-14 825 3c4d7559 Dave Watson 2017-06-14 826 ret = memcopy_from_iter(sk, &msg->msg_iter, try_to_copy); 3c4d7559 Dave Watson 2017-06-14 827 if (ret) 3c4d7559 Dave Watson 2017-06-14 828 goto trim_sgl; 3c4d7559 Dave Watson 2017-06-14 829 3c4d7559 Dave Watson 2017-06-14 830 copied += try_to_copy; 3c4d7559 Dave Watson 2017-06-14 831 if (full_record || eor) { 3c4d7559 Dave Watson 2017-06-14 832 ret = tls_push_record(sk, msg->msg_flags, record_type); 3c4d7559 Dave Watson 2017-06-14 833 if (ret) { a42055e8 Vakul Garg 2018-09-21 834 if (ret == -EINPROGRESS) a42055e8 Vakul Garg 2018-09-21 835 num_async++; a42055e8 Vakul Garg 2018-09-21 836 else if (ret != -EAGAIN) 3c4d7559 Dave Watson 2017-06-14 837 goto send_end; 3c4d7559 Dave Watson 2017-06-14 838 } 3c4d7559 Dave Watson 2017-06-14 839 } 3c4d7559 Dave Watson 2017-06-14 840 3c4d7559 Dave Watson 2017-06-14 841 continue; 3c4d7559 Dave Watson 2017-06-14 842 3c4d7559 Dave Watson 2017-06-14 843 wait_for_sndbuf: 3c4d7559 Dave Watson 2017-06-14 844 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); 3c4d7559 Dave Watson 2017-06-14 845 wait_for_memory: 3c4d7559 Dave Watson 2017-06-14 846 ret = sk_stream_wait_memory(sk, &timeo); 3c4d7559 Dave Watson 2017-06-14 847 if (ret) { 3c4d7559 Dave Watson 2017-06-14 848 trim_sgl: 3c4d7559 Dave Watson 2017-06-14 849 trim_both_sgl(sk, orig_size); 3c4d7559 Dave Watson 2017-06-14 850 goto send_end; 3c4d7559 Dave Watson 2017-06-14 851 } 3c4d7559 Dave Watson 2017-06-14 852 a42055e8 Vakul Garg 2018-09-21 853 if (rec->sg_encrypted_size < required_size) 3c4d7559 Dave Watson 2017-06-14 854 goto alloc_encrypted; 3c4d7559 Dave Watson 2017-06-14 855 3c4d7559 Dave Watson 2017-06-14 856 goto alloc_plaintext; 3c4d7559 Dave Watson 2017-06-14 857 } 3c4d7559 Dave Watson 2017-06-14 858 a42055e8 Vakul Garg 2018-09-21 859 if (!num_async) { a42055e8 Vakul Garg 2018-09-21 860 goto send_end; a42055e8 Vakul Garg 2018-09-21 861 } else if (num_zc) { a42055e8 Vakul Garg 2018-09-21 862 /* Wait for pending encryptions to get completed */ a42055e8 Vakul Garg 2018-09-21 863 smp_store_mb(ctx->async_notify, true); a42055e8 Vakul Garg 2018-09-21 864 a42055e8 Vakul Garg 2018-09-21 865 if (atomic_read(&ctx->encrypt_pending)) a42055e8 Vakul Garg 2018-09-21 866 crypto_wait_req(-EINPROGRESS, &ctx->async_wait); a42055e8 Vakul Garg 2018-09-21 867 else a42055e8 Vakul Garg 2018-09-21 868 reinit_completion(&ctx->async_wait.completion); a42055e8 Vakul Garg 2018-09-21 869 a42055e8 Vakul Garg 2018-09-21 870 WRITE_ONCE(ctx->async_notify, false); a42055e8 Vakul Garg 2018-09-21 871 a42055e8 Vakul Garg 2018-09-21 872 if (ctx->async_wait.err) { a42055e8 Vakul Garg 2018-09-21 873 ret = ctx->async_wait.err; a42055e8 Vakul Garg 2018-09-21 874 copied = 0; a42055e8 Vakul Garg 2018-09-21 875 } a42055e8 Vakul Garg 2018-09-21 876 } a42055e8 Vakul Garg 2018-09-21 877 a42055e8 Vakul Garg 2018-09-21 878 /* Transmit if any encryptions have completed */ a42055e8 Vakul Garg 2018-09-21 879 if (test_and_clear_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask)) { a42055e8 Vakul Garg 2018-09-21 880 cancel_delayed_work(&ctx->tx_work.work); a42055e8 Vakul Garg 2018-09-21 881 tls_tx_records(sk, msg->msg_flags); a42055e8 Vakul Garg 2018-09-21 882 } a42055e8 Vakul Garg 2018-09-21 883 3c4d7559 Dave Watson 2017-06-14 884 send_end: 3c4d7559 Dave Watson 2017-06-14 @885 ret = sk_stream_error(sk, msg->msg_flags, ret); 3c4d7559 Dave Watson 2017-06-14 886 3c4d7559 Dave Watson 2017-06-14 887 release_sock(sk); 3c4d7559 Dave Watson 2017-06-14 888 return copied ? copied : ret; 3c4d7559 Dave Watson 2017-06-14 889 } 3c4d7559 Dave Watson 2017-06-14 890 3c4d7559 Dave Watson 2017-06-14 891 int tls_sw_sendpage(struct sock *sk, struct page *page, 3c4d7559 Dave Watson 2017-06-14 892 int offset, size_t size, int flags) 3c4d7559 Dave Watson 2017-06-14 893 { a42055e8 Vakul Garg 2018-09-21 894 long timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); 3c4d7559 Dave Watson 2017-06-14 895 struct tls_context *tls_ctx = tls_get_ctx(sk); f66de3ee Boris Pismenny 2018-04-30 896 struct tls_sw_context_tx *ctx = tls_sw_ctx_tx(tls_ctx); 3c4d7559 Dave Watson 2017-06-14 897 unsigned char record_type = TLS_RECORD_TYPE_DATA; a42055e8 Vakul Garg 2018-09-21 898 size_t orig_size = size; 3c4d7559 Dave Watson 2017-06-14 899 struct scatterlist *sg; a42055e8 Vakul Garg 2018-09-21 900 struct tls_rec *rec; a42055e8 Vakul Garg 2018-09-21 901 int num_async = 0; 3c4d7559 Dave Watson 2017-06-14 902 bool full_record; 3c4d7559 Dave Watson 2017-06-14 903 int record_room; a42055e8 Vakul Garg 2018-09-21 904 bool eor; a42055e8 Vakul Garg 2018-09-21 905 int ret; 3c4d7559 Dave Watson 2017-06-14 906 3c4d7559 Dave Watson 2017-06-14 907 if (flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | 3c4d7559 Dave Watson 2017-06-14 908 MSG_SENDPAGE_NOTLAST)) 3c4d7559 Dave Watson 2017-06-14 909 return -ENOTSUPP; 3c4d7559 Dave Watson 2017-06-14 910 3c4d7559 Dave Watson 2017-06-14 911 /* No MSG_EOR from splice, only look at MSG_MORE */ 3c4d7559 Dave Watson 2017-06-14 912 eor = !(flags & (MSG_MORE | MSG_SENDPAGE_NOTLAST)); 3c4d7559 Dave Watson 2017-06-14 913 3c4d7559 Dave Watson 2017-06-14 914 lock_sock(sk); 3c4d7559 Dave Watson 2017-06-14 915 3c4d7559 Dave Watson 2017-06-14 916 sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk); 3c4d7559 Dave Watson 2017-06-14 917 a42055e8 Vakul Garg 2018-09-21 918 /* Wait till there is any pending write on socket */ a42055e8 Vakul Garg 2018-09-21 919 if (unlikely(sk->sk_write_pending)) { a42055e8 Vakul Garg 2018-09-21 920 ret = wait_on_pending_writer(sk, &timeo); a42055e8 Vakul Garg 2018-09-21 921 if (unlikely(ret)) 3c4d7559 Dave Watson 2017-06-14 922 goto sendpage_end; a42055e8 Vakul Garg 2018-09-21 923 } 3c4d7559 Dave Watson 2017-06-14 924 3c4d7559 Dave Watson 2017-06-14 925 /* Call the sk_stream functions to manage the sndbuf mem. */ 3c4d7559 Dave Watson 2017-06-14 926 while (size > 0) { 3c4d7559 Dave Watson 2017-06-14 927 size_t copy, required_size; 3c4d7559 Dave Watson 2017-06-14 928 3c4d7559 Dave Watson 2017-06-14 929 if (sk->sk_err) { 30be8f8d r.her...@avm.de 2018-01-12 930 ret = -sk->sk_err; 3c4d7559 Dave Watson 2017-06-14 931 goto sendpage_end; 3c4d7559 Dave Watson 2017-06-14 932 } 3c4d7559 Dave Watson 2017-06-14 933 a42055e8 Vakul Garg 2018-09-21 934 rec = get_rec(sk); a42055e8 Vakul Garg 2018-09-21 935 if (!rec) { a42055e8 Vakul Garg 2018-09-21 936 ret = -ENOMEM; a42055e8 Vakul Garg 2018-09-21 937 goto sendpage_end; a42055e8 Vakul Garg 2018-09-21 938 } a42055e8 Vakul Garg 2018-09-21 939 3c4d7559 Dave Watson 2017-06-14 940 full_record = false; a42055e8 Vakul Garg 2018-09-21 941 record_room = TLS_MAX_PAYLOAD_SIZE - rec->sg_plaintext_size; 3c4d7559 Dave Watson 2017-06-14 942 copy = size; 3c4d7559 Dave Watson 2017-06-14 943 if (copy >= record_room) { 3c4d7559 Dave Watson 2017-06-14 944 copy = record_room; 3c4d7559 Dave Watson 2017-06-14 945 full_record = true; 3c4d7559 Dave Watson 2017-06-14 946 } a42055e8 Vakul Garg 2018-09-21 947 required_size = rec->sg_plaintext_size + copy + dbe42559 Dave Watson 2018-03-22 948 tls_ctx->tx.overhead_size; 3c4d7559 Dave Watson 2017-06-14 949 3c4d7559 Dave Watson 2017-06-14 950 if (!sk_stream_memory_free(sk)) 3c4d7559 Dave Watson 2017-06-14 951 goto wait_for_sndbuf; 3c4d7559 Dave Watson 2017-06-14 952 alloc_payload: 3c4d7559 Dave Watson 2017-06-14 953 ret = alloc_encrypted_sg(sk, required_size); 3c4d7559 Dave Watson 2017-06-14 954 if (ret) { 3c4d7559 Dave Watson 2017-06-14 955 if (ret != -ENOSPC) 3c4d7559 Dave Watson 2017-06-14 956 goto wait_for_memory; 3c4d7559 Dave Watson 2017-06-14 957 3c4d7559 Dave Watson 2017-06-14 958 /* Adjust copy according to the amount that was 3c4d7559 Dave Watson 2017-06-14 959 * actually allocated. The difference is due 3c4d7559 Dave Watson 2017-06-14 960 * to max sg elements limit 3c4d7559 Dave Watson 2017-06-14 961 */ a42055e8 Vakul Garg 2018-09-21 962 copy -= required_size - rec->sg_plaintext_size; 3c4d7559 Dave Watson 2017-06-14 963 full_record = true; 3c4d7559 Dave Watson 2017-06-14 964 } 3c4d7559 Dave Watson 2017-06-14 965 3c4d7559 Dave Watson 2017-06-14 966 get_page(page); a42055e8 Vakul Garg 2018-09-21 967 sg = rec->sg_plaintext_data + rec->sg_plaintext_num_elem; 3c4d7559 Dave Watson 2017-06-14 968 sg_set_page(sg, page, copy, offset); 7a8c4dd9 Dave Watson 2018-01-19 969 sg_unmark_end(sg); 7a8c4dd9 Dave Watson 2018-01-19 970 a42055e8 Vakul Garg 2018-09-21 971 rec->sg_plaintext_num_elem++; 3c4d7559 Dave Watson 2017-06-14 972 3c4d7559 Dave Watson 2017-06-14 973 sk_mem_charge(sk, copy); 3c4d7559 Dave Watson 2017-06-14 974 offset += copy; 3c4d7559 Dave Watson 2017-06-14 975 size -= copy; a42055e8 Vakul Garg 2018-09-21 976 rec->sg_plaintext_size += copy; a42055e8 Vakul Garg 2018-09-21 977 tls_ctx->pending_open_record_frags = rec->sg_plaintext_num_elem; 3c4d7559 Dave Watson 2017-06-14 978 3c4d7559 Dave Watson 2017-06-14 979 if (full_record || eor || a42055e8 Vakul Garg 2018-09-21 980 rec->sg_plaintext_num_elem == a42055e8 Vakul Garg 2018-09-21 981 ARRAY_SIZE(rec->sg_plaintext_data)) { 3c4d7559 Dave Watson 2017-06-14 982 ret = tls_push_record(sk, flags, record_type); 3c4d7559 Dave Watson 2017-06-14 983 if (ret) { a42055e8 Vakul Garg 2018-09-21 984 if (ret == -EINPROGRESS) a42055e8 Vakul Garg 2018-09-21 985 num_async++; a42055e8 Vakul Garg 2018-09-21 986 else if (ret != -EAGAIN) 3c4d7559 Dave Watson 2017-06-14 987 goto sendpage_end; 3c4d7559 Dave Watson 2017-06-14 988 } 3c4d7559 Dave Watson 2017-06-14 989 } 3c4d7559 Dave Watson 2017-06-14 990 continue; 3c4d7559 Dave Watson 2017-06-14 991 wait_for_sndbuf: 3c4d7559 Dave Watson 2017-06-14 992 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); 3c4d7559 Dave Watson 2017-06-14 993 wait_for_memory: 3c4d7559 Dave Watson 2017-06-14 994 ret = sk_stream_wait_memory(sk, &timeo); 3c4d7559 Dave Watson 2017-06-14 995 if (ret) { a42055e8 Vakul Garg 2018-09-21 996 trim_both_sgl(sk, rec->sg_plaintext_size); 3c4d7559 Dave Watson 2017-06-14 997 goto sendpage_end; 3c4d7559 Dave Watson 2017-06-14 998 } 3c4d7559 Dave Watson 2017-06-14 999 3c4d7559 Dave Watson 2017-06-14 1000 goto alloc_payload; 3c4d7559 Dave Watson 2017-06-14 1001 } 3c4d7559 Dave Watson 2017-06-14 1002 a42055e8 Vakul Garg 2018-09-21 1003 if (num_async) { a42055e8 Vakul Garg 2018-09-21 1004 /* Transmit if any encryptions have completed */ a42055e8 Vakul Garg 2018-09-21 1005 if (test_and_clear_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask)) { a42055e8 Vakul Garg 2018-09-21 1006 cancel_delayed_work(&ctx->tx_work.work); a42055e8 Vakul Garg 2018-09-21 1007 tls_tx_records(sk, flags); a42055e8 Vakul Garg 2018-09-21 1008 } a42055e8 Vakul Garg 2018-09-21 1009 } 3c4d7559 Dave Watson 2017-06-14 1010 sendpage_end: 3c4d7559 Dave Watson 2017-06-14 1011 if (orig_size > size) 3c4d7559 Dave Watson 2017-06-14 1012 ret = orig_size - size; 3c4d7559 Dave Watson 2017-06-14 1013 else 3c4d7559 Dave Watson 2017-06-14 @1014 ret = sk_stream_error(sk, flags, ret); 3c4d7559 Dave Watson 2017-06-14 1015 3c4d7559 Dave Watson 2017-06-14 1016 release_sock(sk); 3c4d7559 Dave Watson 2017-06-14 1017 return ret; 3c4d7559 Dave Watson 2017-06-14 1018 } 3c4d7559 Dave Watson 2017-06-14 1019 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation _______________________________________________ kbuild mailing list kbuild@lists.01.org https://lists.01.org/mailman/listinfo/kbuild