net: tls: fix marking packets as decrypted
Subsystems (3)
Jakub Kicinski
maintainerPATCH 1/1 net: tls: fix marking packets as decrypted
For TLS offload we mark packets with skb->decrypted to make sure they don't escape the host without getting encrypted first. The crypto state lives in the socket, so it may get detached by a call to skb_orphan(). As a safety check - the egress path drops all packets with skb->decrypted and no "crypto-safe" socket.
The skb marking was added to sendpage only (and not sendmsg), because tls_device injected data into the TCP stack using sendpage. This special case was missed when sendpage got folded into sendmsg.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- net/ipv4/tcp.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv4/tcp.c +3 -0
@@ -1165,6 +1165,9 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size) process_backlog++; +#ifdef CONFIG_SKB_DECRYPTED + skb->decrypted = !!(flags &MSG_SENDPAGE_DECRYPTED ); +#endif tcp_skb_entail (sk, skb); copy = size_goal;
Signature · 1 line
2.45.1
Jakub Kicinski
maintainerQuoted 6 lines · On Thu, 30 May 2024 16:26:07 -0700 Jakub Kicinski wrote:
For TLS offload we mark packets with
skb->decryptedto make sure they don't escape the host without getting encrypted first. The crypto state lives in the socket, so it may get detached by a call toskb_orphan(). As a safety check - the egress path drops all packets withskb->decryptedand no "crypto-safe" socket.
Quoted 6 lines
The skb marking was added to sendpage only (and not sendmsg), because
tls_deviceinjected data into the TCP stack using sendpage. This special case was missed when sendpage got folded into sendmsg.Fixes c5c37af6ecad ("tcp: Convert do_tcp_sendpages() to use MSG_SPLICE_PAGES")Signed-off-by Jakub Kicinski <[email protected]>
Forgot to mention - compile tested only, ENODEV :(
Eric Dumazet
Reviewed-byQuoted 8 lines · Jakub Kicinski
Quoted 6 lines · On Thu, 30 May 2024 16:26:07 -0700 Jakub Kicinski wrote:
For TLS offload we mark packets with
skb->decryptedto make sure they don't escape the host without getting encrypted first. The crypto state lives in the socket, so it may get detached by a call toskb_orphan(). As a safety check - the egress path drops all packets withskb->decryptedand no "crypto-safe" socket.
Quoted 8 lines
Quoted 6 lines
The skb marking was added to sendpage only (and not sendmsg), because
tls_deviceinjected data into the TCP stack using sendpage. This special case was missed when sendpage got folded into sendmsg.Fixes c5c37af6ecad ("tcp: Convert do_tcp_sendpages() to use MSG_SPLICE_PAGES")Signed-off-by Jakub Kicinski <[email protected]>Forgot to mention - compile tested only, ENODEV :(
In net-next, we could probably move skb_cmp_decrypted(), skb_is_decrypted(), skb_copy_decrypted() to a new include file, and define skb_set_decrypted() helper there.
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 11 lines · On Thu, 30 May 2024 16:26:07 -0700 you wrote:
For TLS offload we mark packets with
skb->decryptedto make sure they don't escape the host without getting encrypted first. The crypto state lives in the socket, so it may get detached by a call toskb_orphan(). As a safety check - the egress path drops all packets withskb->decryptedand no "crypto-safe" socket.The skb marking was added to sendpage only (and not sendmsg), because
tls_deviceinjected data into the TCP stack using sendpage. This special case was missed when sendpage got folded into sendmsg.[...]
Here is the summary with links:
- [net] net: tls: fix marking packets as decrypted
https://git.kernel.org/netdev/net/c/a535d5943237
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html