summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorSabrina Dubroca <sd@queasysnail.net>2025-10-14 11:16:58 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-29 13:59:57 +0100
commit12027b09906464de63fa956103fe2c773552df6d (patch)
treebe250a28e4bc01b71b81785c86708ef596847d8b /net
parente06a8f2ff7c16fc552dbc4f1436974bee3eaf37b (diff)
downloadlinux-12027b09906464de63fa956103fe2c773552df6d.tar.gz
linux-12027b09906464de63fa956103fe2c773552df6d.tar.bz2
linux-12027b09906464de63fa956103fe2c773552df6d.zip
tls: always set record_type in tls_process_cmsg
[ Upstream commit b6fe4c29bb51cf239ecf48eacf72b924565cb619 ] When userspace wants to send a non-DATA record (via the TLS_SET_RECORD_TYPE cmsg), we need to send any pending data from a previous MSG_MORE send() as a separate DATA record. If that DATA record is encrypted asynchronously, tls_handle_open_record will return -EINPROGRESS. This is currently treated as an error by tls_process_cmsg, and it will skip setting record_type to the correct value, but the caller (tls_sw_sendmsg_locked) handles that return value correctly and proceeds with sending the new message with an incorrect record_type (DATA instead of whatever was requested in the cmsg). Always set record_type before handling the open record. If tls_handle_open_record returns an error, record_type will be ignored. If it succeeds, whether with synchronous crypto (returning 0) or asynchronous (returning -EINPROGRESS), the caller will proceed correctly. Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption of records for performance") Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Link: https://patch.msgid.link/0457252e578a10a94e40c72ba6288b3a64f31662.1760432043.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/tls/tls_main.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index cb51a2f46b11..5bf809b09034 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -181,12 +181,9 @@ int tls_proccess_cmsg(struct sock *sk, struct msghdr *msg,
if (msg->msg_flags & MSG_MORE)
return -EINVAL;
- rc = tls_handle_open_record(sk, msg->msg_flags);
- if (rc)
- return rc;
-
*record_type = *(unsigned char *)CMSG_DATA(cmsg);
- rc = 0;
+
+ rc = tls_handle_open_record(sk, msg->msg_flags);
break;
default:
return -EINVAL;