Skip to contentSkip to conversation

fixes for ktls

PATCH Applied John Fastabend 2 participants 5 messages Dec 6, 2023 – Dec 7, 2023

Subsystems (5)
lore
Share & tools
lore

John Fastabend

author maintainer
#0 lore raw

cover fixes for ktls

Couple fixes for TLS and BPF interactions.

John Fastabend (2):
net: tls, update curr on splice as well
bpf: sockmap, updating the sg structure should also update curr

 net/core/filter.c | 19 +++++++++++++++++++
 net/tls/tls_sw.c  |  2 ++
 2 files changed, 21 insertions(+)
Signature · 1 line
2.33.0
author maintainer
#1 lore raw

PATCH 1/2 net: tls, update curr on splice as well

The curr pointer must also be updated on the splice similar to how we do this for other copy types.

Fixes d829e9c4112b ("tls: convert to generic sk_msg interface")
---
 net/tls/tls_sw.c | 2 ++
 1 file changed, 2 insertions(+)
net/tls/tls_sw.c +2 -0
index 316f76187962..e37b4d2e2acd 100644
@@ -952,6 +952,8 @@ static int tls_sw_sendmsg_splice(struct sock *sk, struct msghdr *msg,
 		}
 
 		sk_msg_page_add(msg_pl, page, part, off);
+		msg_pl->sg.copybreak = 0;
+		msg_pl->sg.curr = msg_pl->sg.end;
 		sk_mem_charge(sk, part);
 		*copied += part;
 		try_to_copy -= part;
Signature · 1 line
2.33.0
author maintainer
#3 lore raw

PATCH 2/2 bpf: sockmap, updating the sg structure should also update curr

In reply to John Fastabend

Curr pointer should be updated when the sg structure is shifted.

Fixes 7246d8ed4dcce ("bpf: helper to pop data from messages")
---
 net/core/filter.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
net/core/filter.c +19 -0
index 7e4d7c3bcc84..1737884be52f 100644
@@ -2602,6 +2602,22 @@ BPF_CALL_2(bpf_msg_cork_bytes, struct sk_msg *, msg, u32, bytes)
 	return 0;
 }
 
+static void sk_msg_reset_curr(struct sk_msg *msg)
+{
+	u32 i = msg->sg.start;
+	u32 len = 0;
+
+	do {
+		len += sk_msg_elem(msg, i)->length;
+		sk_msg_iter_var_next(i);
+		if (len >= msg->sg.size)
+			break;
+	} while (i != msg->sg.end);
+
+	msg->sg.curr = i;
+	msg->sg.copybreak = 0;
+}
+
 static const struct bpf_func_proto bpf_msg_cork_bytes_proto = {
 	.func           = bpf_msg_cork_bytes,
 	.gpl_only       = false,
@@ -2721,6 +2737,7 @@ BPF_CALL_4(bpf_msg_pull_data, struct sk_msg *, msg, u32, start,
 		      msg->sg.end - shift + NR_MSG_FRAG_IDS :
 		      msg->sg.end - shift;
 out:
+	sk_msg_reset_curr(msg);
 	msg->data = sg_virt(&msg->sg.data[first_sge]) + start - offset;
 	msg->data_end = msg->data + bytes;
 	return 0;
@@ -2857,6 +2874,7 @@ BPF_CALL_4(bpf_msg_push_data, struct sk_msg *, msg, u32, start,
 		msg->sg.data[new] = rsge;
 	}
 
+	sk_msg_reset_curr(msg);
 	sk_msg_compute_data_pointers(msg);
 	return 0;
 }
@@ -3025,6 +3043,7 @@ BPF_CALL_4(bpf_msg_pop_data, struct sk_msg *, msg, u32, start,
 
 	sk_mem_uncharge(msg->sk, len - pop);
 	msg->sg.size -= (len - pop);
+	sk_msg_reset_curr(msg);
 	sk_msg_compute_data_pointers(msg);
 	return 0;
 }
Signature · 1 line
2.33.0
#4 lore raw
In reply to John Fastabend
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Wed, 6 Dec 2023 15:27:04 -0800 you wrote:

Couple fixes for TLS and BPF interactions.

John Fastabend (2):
net: tls, update curr on splice as well
bpf: sockmap, updating the sg structure should also update curr

 net/core/filter.c | 19 +++++++++++++++++++
 net/tls/tls_sw.c  |  2 ++
 2 files changed, 21 insertions(+)

Here is the summary with links:
- [net,1/2] net: tls, update curr on splice as well

    https://git.kernel.org/netdev/net/c/c5a595000e26

- [net,2/2] bpf: sockmap, updating the sg structure should also update curr
https://git.kernel.org/netdev/net/c/bb9aefde5bba

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html