Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9048153E30 for ; Fri, 15 Mar 2024 20:16:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710533795; cv=none; b=irypgV7a8Vysjp8/ivr4wPDNbD/v9iBWMiLsNZvUbs51tVhlw3vTtXMih8LYlhqtBq6yL/bEdt0ACm+Ac0VwQ8vMV4RmfqGvKz9ilTlbfu/z6t9fqM286qjaWRSEOzDzboOVWAtE1lwbBbXS1bqkmJOC7qKoJW5IcfeWVWX8Z70= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710533795; c=relaxed/simple; bh=wZAN/kS8ksi/icF49t1Jq9jR9Ow44UiS0fNZaDFn2zU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UsYNEFhgZaSUVAeIqdiPFNOY4Gi9Q6bksx2jv/J7fvNLRUaiXyJRqsiNgGJed3KPZxh74SSd6N4+MeKcds2ReePm0FeAA4ZQR829Va7oqZzwhUar9b5QPF02//3mbyt0j400tyZcZISwQ5/vo/5lvj02T+tHoWNaOwHkMjQl8qU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vCmQrPE3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="vCmQrPE3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 624BEC433F1; Fri, 15 Mar 2024 20:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1710533794; bh=wZAN/kS8ksi/icF49t1Jq9jR9Ow44UiS0fNZaDFn2zU=; h=From:To:Cc:Subject:Date:Reply-to:From; b=vCmQrPE3VFKUskLtOXhspGIDVXxuBk78i6oiZbrOX4+BsiNChUnRM6N/aScPh9kUu F2VrJVhwX06d88QURnldDsFkZOglAKgyaOek/Ucdv4R1XwwAtJ6mJOxaCQzfjJS0Me uVDFRFyOEM+g7pEvVw+xW7/M59eZSWcEWCxG1kzo= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2021-47131: net/tls: Fix use-after-free after the TLS device goes down and up Date: Fri, 15 Mar 2024 21:15:21 +0100 Message-ID: <2024031513-CVE-2021-47131-eafc@gregkh> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3302; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=wZAN/kS8ksi/icF49t1Jq9jR9Ow44UiS0fNZaDFn2zU=; b=owGbwMvMwCRo6H6F97bub03G02pJDKlf1gTNeX03K95MomPhtKfv7xUePlsjEnrtg2SlA8PN3 426UxpXdMSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEfh1gWLDBTvskRxLzE/F5 kYqLzpjK/Xg9uYhhrtD/66HzK5pX/pimMcPzDy+/0oEtKgA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: net/tls: Fix use-after-free after the TLS device goes down and up When a netdev with active TLS offload goes down, tls_device_down is called to stop the offload and tear down the TLS context. However, the socket stays alive, and it still points to the TLS context, which is now deallocated. If a netdev goes up, while the connection is still active, and the data flow resumes after a number of TCP retransmissions, it will lead to a use-after-free of the TLS context. This commit addresses this bug by keeping the context alive until its normal destruction, and implements the necessary fallbacks, so that the connection can resume in software (non-offloaded) kTLS mode. On the TX side tls_sw_fallback is used to encrypt all packets. The RX side already has all the necessary fallbacks, because receiving non-decrypted packets is supported. The thing needed on the RX side is to block resync requests, which are normally produced after receiving non-decrypted packets. The necessary synchronization is implemented for a graceful teardown: first the fallbacks are deployed, then the driver resources are released (it used to be possible to have a tls_dev_resync after tls_dev_del). A new flag called TLS_RX_DEV_DEGRADED is added to indicate the fallback mode. It's used to skip the RX resync logic completely, as it becomes useless, and some objects may be released (for example, resync_async, which is allocated and freed by the driver). The Linux kernel CVE team has assigned CVE-2021-47131 to this issue. Affected and fixed versions =========================== Issue introduced in 4.18 with commit e8f69799810c and fixed in 5.10.43 with commit f1d4184f128d Issue introduced in 4.18 with commit e8f69799810c and fixed in 5.12.10 with commit 0f1e6fe66977 Issue introduced in 4.18 with commit e8f69799810c and fixed in 5.13 with commit c55dcdd435aa Please see https://www.kernel.org or a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2021-47131 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: include/net/tls.h net/tls/tls_device.c net/tls/tls_device_fallback.c net/tls/tls_main.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/f1d4184f128dede82a59a841658ed40d4e6d3aa2 https://git.kernel.org/stable/c/0f1e6fe66977a864fe850522316f713d7b926fd9 https://git.kernel.org/stable/c/c55dcdd435aa6c6ad6ccac0a4c636d010ee367a4