From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225gelVv9PWfUOg2hT323EZ8FnxN9YaWFugtCEvleWSCN0N3/jQvMI+PGa4aLVz+VImdX5sX ARC-Seal: i=1; a=rsa-sha256; t=1517256779; cv=none; d=google.com; s=arc-20160816; b=YdOKm4akp6tto2u5oA/SHkbaNmke+2EUX9R3H0uLLSpAT6kquSYlAV+8lzLsCFtQDH X2MreqAZAnnBWqpg/o07hZhdnBqClMcYpxELGxZNRCnCf9e86jcAr6z7BRHzZkl7BSlU 988n/xOEXKcLrFAMtbGeZky4IohuE4L4CgKSjSTRUKRWV2A8/i7fU3pijQ+YwYzdfcvv l5yDmwgtJnORHCrhDORzuzWTPAOifI6332Wz84nX0bWaEs4AnSD/x6zzhlDUSAN9NtlY xUBH4ccMZ5+45gBtmuvhH+b7qiOF21tdCynmQ3B7+nioadnegu9qvyM3bLnlfIxTrtTW YfxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=zhoPXlkXoh40orYDZYYCEos/yv/FsODeeamHvSPeXJM=; b=DWZ34xpTslpEzMb1+Kmqd48MRl9r6On+NArl9LqCD69FwosOyOj98Oay63bFBCtmlq s+gfIqhr/KKy3fUJBJoIB1xnK3jfjiLamsURQk6WLYzwyzlTyk0bdGG1Vv4hG3drcM/c GGVxYVCcZsObG6Y12JBzDeDZ8i9Vno9jiVzMSpDVKRt1SefFGL6PYcF3heqTjkekks/m XuXuIhbpebVXc8yrW0QhaxN12/Sl/Nk8oOtOOygV5XO7Jy9UQFuLoNBMzFd5s+m7YXZP 1HDZ4nQj7rsMKnWn6P8BaiAJTr8gKOOVcGFqo318th0nymhRlmGkdta+f3cUPWVHHxSd Y6mw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sabrina Dubroca , "David S. Miller" Subject: [PATCH 4.14 57/71] tls: reset crypto_info when do_tls_setsockopt_tx fails Date: Mon, 29 Jan 2018 13:57:25 +0100 Message-Id: <20180129123831.413167249@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123827.271171825@linuxfoundation.org> References: <20180129123827.271171825@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590959044801219114?= X-GMAIL-MSGID: =?utf-8?q?1590959044801219114?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sabrina Dubroca [ Upstream commit 6db959c82eb039a151d95a0f8b7dea643657327a ] The current code copies directly from userspace to ctx->crypto_send, but doesn't always reinitialize it to 0 on failure. This causes any subsequent attempt to use this setsockopt to fail because of the TLS_CRYPTO_INFO_READY check, eventhough crypto_info is not actually ready. This should result in a correctly set up socket after the 3rd call, but currently it does not: size_t s = sizeof(struct tls12_crypto_info_aes_gcm_128); struct tls12_crypto_info_aes_gcm_128 crypto_good = { .info.version = TLS_1_2_VERSION, .info.cipher_type = TLS_CIPHER_AES_GCM_128, }; struct tls12_crypto_info_aes_gcm_128 crypto_bad_type = crypto_good; crypto_bad_type.info.cipher_type = 42; setsockopt(sock, SOL_TLS, TLS_TX, &crypto_bad_type, s); setsockopt(sock, SOL_TLS, TLS_TX, &crypto_good, s - 1); setsockopt(sock, SOL_TLS, TLS_TX, &crypto_good, s); Fixes: 3c4d7559159b ("tls: kernel TLS support") Signed-off-by: Sabrina Dubroca Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tls/tls_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -373,7 +373,7 @@ static int do_tls_setsockopt_tx(struct s case TLS_CIPHER_AES_GCM_128: { if (optlen != sizeof(struct tls12_crypto_info_aes_gcm_128)) { rc = -EINVAL; - goto out; + goto err_crypto_info; } rc = copy_from_user( crypto_info, @@ -388,7 +388,7 @@ static int do_tls_setsockopt_tx(struct s } default: rc = -EINVAL; - goto out; + goto err_crypto_info; } ctx->sk_write_space = sk->sk_write_space;