netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] fixes for ktls
@ 2023-12-06 23:27 John Fastabend
  2023-12-06 23:27 ` [PATCH net 1/2] net: tls, update curr on splice as well John Fastabend
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: John Fastabend @ 2023-12-06 23:27 UTC (permalink / raw)
  To: kuba, jannh, daniel; +Cc: john.fastabend, borisp, bpf, netdev

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(+)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net 1/2] net: tls, update curr on splice as well
  2023-12-06 23:27 [PATCH net 0/2] fixes for ktls John Fastabend
@ 2023-12-06 23:27 ` John Fastabend
  2023-12-07 16:51   ` John Fastabend
  2023-12-06 23:27 ` [PATCH net 2/2] bpf: sockmap, updating the sg structure should also update curr John Fastabend
  2023-12-07 18:00 ` [PATCH net 0/2] fixes for ktls patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: John Fastabend @ 2023-12-06 23:27 UTC (permalink / raw)
  To: kuba, jannh, daniel; +Cc: john.fastabend, borisp, bpf, netdev

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")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
---
 net/tls/tls_sw.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 316f76187962..e37b4d2e2acd 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -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;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net 2/2] bpf: sockmap, updating the sg structure should also update curr
  2023-12-06 23:27 [PATCH net 0/2] fixes for ktls John Fastabend
  2023-12-06 23:27 ` [PATCH net 1/2] net: tls, update curr on splice as well John Fastabend
@ 2023-12-06 23:27 ` John Fastabend
  2023-12-07 18:00 ` [PATCH net 0/2] fixes for ktls patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: John Fastabend @ 2023-12-06 23:27 UTC (permalink / raw)
  To: kuba, jannh, daniel; +Cc: john.fastabend, borisp, bpf, netdev

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

Fixes: 7246d8ed4dcce ("bpf: helper to pop data from messages")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
---
 net/core/filter.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index 7e4d7c3bcc84..1737884be52f 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -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;
 }
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH net 1/2] net: tls, update curr on splice as well
  2023-12-06 23:27 ` [PATCH net 1/2] net: tls, update curr on splice as well John Fastabend
@ 2023-12-07 16:51   ` John Fastabend
  0 siblings, 0 replies; 5+ messages in thread
From: John Fastabend @ 2023-12-07 16:51 UTC (permalink / raw)
  To: John Fastabend, kuba, jannh, daniel; +Cc: john.fastabend, borisp, bpf, netdev

John Fastabend wrote:
> 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")
> Signed-off-by: John Fastabend <john.fastabend@gmail.com>
> ---

Reported-by: Jann Horn <jannh@google.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net 0/2] fixes for ktls
  2023-12-06 23:27 [PATCH net 0/2] fixes for ktls John Fastabend
  2023-12-06 23:27 ` [PATCH net 1/2] net: tls, update curr on splice as well John Fastabend
  2023-12-06 23:27 ` [PATCH net 2/2] bpf: sockmap, updating the sg structure should also update curr John Fastabend
@ 2023-12-07 18:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-12-07 18:00 UTC (permalink / raw)
  To: John Fastabend; +Cc: kuba, jannh, daniel, borisp, bpf, netdev

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-12-07 18:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-06 23:27 [PATCH net 0/2] fixes for ktls John Fastabend
2023-12-06 23:27 ` [PATCH net 1/2] net: tls, update curr on splice as well John Fastabend
2023-12-07 16:51   ` John Fastabend
2023-12-06 23:27 ` [PATCH net 2/2] bpf: sockmap, updating the sg structure should also update curr John Fastabend
2023-12-07 18:00 ` [PATCH net 0/2] fixes for ktls patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).