Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp171758pxb; Mon, 25 Oct 2021 06:08:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBxP7QXaJu5+17OLUR4D3P1A1oNT6FDNsK76uASEoIvPyj+CHmeSup/BVSToCqH5pLOo2D X-Received: by 2002:a05:6a00:1686:b0:44d:50e:de9e with SMTP id k6-20020a056a00168600b0044d050ede9emr18637640pfc.4.1635167337711; Mon, 25 Oct 2021 06:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635167337; cv=none; d=google.com; s=arc-20160816; b=NKN34lJyHuObtQI2jK12aYsod8aI4VldwDMztJ9d4C86+HYXacSgEDYvJfDCLrPDwr vJjO1azk3Y0msHPodlLXg/M0YG1R7jqHD6Q1ILGfBZylBgtY/yWT8ONHbJ68K72sjXIW UIlsd+gi6z+JuB///UM75lzFd6TeFb1ccoVyVQCb6juOB/viHzvNsBXxracue9BCuxWY y21BRFQfnhuWcXWzlcbgAE86h2QEFuqql6sxklIAiIVU0ISoQU2K6PdDoa5zxSXXiBFp BcPBQppTG4kqy2Xdgl4/RLbBUMuSbp6v2LIJDEqZSMwPG1WYN82dEsWIPNvKdpKx/Oqm 23bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=sWKK6+n13bckUH1uNYNY+87za2gt6E+v6RAf3hhyCHc=; b=dRVVxL7xDhxlc4bZ4LMP5dnqCrkHM3a7YHibX3bVgg2SS187pqr0tGH3GAcqOsMEBi QV2tIkHVFX86jbfOdk5exO3ogtvt/DPf7dPow1dU48gG2MhwIy99yf75j+pLtks49ln+ 97MkBphno9La8L7+kE5VwmR2i8DgFOpFAzYVQ/QAPi1nwMfW1r3aED/RYExGzSzNJkwo Kamv62ZjFAPppVjulUEOlhVXmYD+N+IiZdMEQeNv+jr9yIRvrpTN9DSnRdqt50N1Imvn rnVMrU/FgQSeQbiucHzzcNc68Mxf/2fJUYXR5ruoNfQv3Zk3oZdnmgRCG53w1Yg+EF3N yH/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si14701632pfu.313.2021.10.25.06.08.43; Mon, 25 Oct 2021 06:08:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233427AbhJYNH2 (ORCPT + 99 others); Mon, 25 Oct 2021 09:07:28 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:60607 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233435AbhJYNHZ (ORCPT ); Mon, 25 Oct 2021 09:07:25 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0UterkeI_1635167100; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0UterkeI_1635167100) by smtp.aliyun-inc.com(127.0.0.1); Mon, 25 Oct 2021 21:05:01 +0800 From: Tianjia Zhang To: "David S. Miller" , Jakub Kicinski , Boris Pismenny , John Fastabend , Daniel Borkmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tianjia Zhang Subject: [PATCH] net/tls: getsockopt supports complete algorithm list Date: Mon, 25 Oct 2021 21:05:00 +0800 Message-Id: <20211025130500.93077-1-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.3.ge56e4f7 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org AES_CCM_128 and CHACHA20_POLY1305 are already supported by tls, similar to setsockopt, getsockopt also needs to support these two algorithms. Signed-off-by: Tianjia Zhang --- net/tls/tls_main.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index d44399efeac6..278192ee133e 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -421,6 +421,48 @@ static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval, rc = -EFAULT; break; } + case TLS_CIPHER_AES_CCM_128: { + struct tls12_crypto_info_aes_ccm_128 *aes_ccm_128 = + container_of(crypto_info, + struct tls12_crypto_info_aes_ccm_128, info); + + if (len != sizeof(*aes_ccm_128)) { + rc = -EINVAL; + goto out; + } + lock_sock(sk); + memcpy(aes_ccm_128->iv, + cctx->iv + TLS_CIPHER_AES_CCM_128_SALT_SIZE, + TLS_CIPHER_AES_CCM_128_IV_SIZE); + memcpy(aes_ccm_128->rec_seq, cctx->rec_seq, + TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE); + release_sock(sk); + if (copy_to_user(optval, aes_ccm_128, sizeof(*aes_ccm_128))) + rc = -EFAULT; + break; + } + case TLS_CIPHER_CHACHA20_POLY1305: { + struct tls12_crypto_info_chacha20_poly1305 *chacha20_poly1305 = + container_of(crypto_info, + struct tls12_crypto_info_chacha20_poly1305, + info); + + if (len != sizeof(*chacha20_poly1305)) { + rc = -EINVAL; + goto out; + } + lock_sock(sk); + memcpy(chacha20_poly1305->iv, + cctx->iv + TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE, + TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE); + memcpy(chacha20_poly1305->rec_seq, cctx->rec_seq, + TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE); + release_sock(sk); + if (copy_to_user(optval, chacha20_poly1305, + sizeof(*chacha20_poly1305))) + rc = -EFAULT; + break; + } case TLS_CIPHER_SM4_GCM: { struct tls12_crypto_info_sm4_gcm *sm4_gcm_info = container_of(crypto_info, -- 2.19.1.3.ge56e4f7