diff mbox series

[SRU,Jammy-OEM-5.17,1/1] net/tls: tls_is_tx_ready() checked list_entry

Message ID 20230728195313.92261-2-yuxuan.luo@canonical.com
State New
Headers show
Series [SRU,Jammy-OEM-5.17,1/1] net/tls: tls_is_tx_ready() checked list_entry | expand

Commit Message

Yuxuan Luo July 28, 2023, 7:53 p.m. UTC
From: Pietro Borrello <borrello@diag.uniroma1.it>

tls_is_tx_ready() checks that list_first_entry() does not return NULL.
This condition can never happen. For empty lists, list_first_entry()
returns the list_entry() of the head, which is a type confusion.
Use list_first_entry_or_null() which returns NULL in case of empty
lists.

Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption of records for performance")
Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it>
Link: https://lore.kernel.org/r/20230128-list-entry-null-check-tls-v1-1-525bbfe6f0d0@diag.uniroma1.it
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(backported from commit ffe2a22562444720b05bdfeb999c03e810d84cbb)
[yuxuan.luo: instead of backporting the previous commit 587903142308, modify
 the `is_tx_ready()` in include/net/tls.h directly.
]
CVE-2023-1075
Signed-off-by: Yuxuan Luo <yuxuan.luo@canonical.com>
---
 include/net/tls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/net/tls.h b/include/net/tls.h
index 7f220e03ebb2d..e6836a5dfb6e2 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -427,7 +427,7 @@  static inline bool is_tx_ready(struct tls_sw_context_tx *ctx)
 {
 	struct tls_rec *rec;
 
-	rec = list_first_entry(&ctx->tx_list, struct tls_rec, list);
+	rec = list_first_entry_or_null(&ctx->tx_list, struct tls_rec, list);
 	if (!rec)
 		return false;