On Tue, Jul 22, 2025 at 11:49 AM -07, Eduard Zingerman wrote:
On Mon, 2025-07-21 at 12:52 +0200, Jakub Sitnicki wrote:
[...]
quoted
diff --git a/net/core/filter.c b/net/core/filter.c
index c17b628c08f5..4b787c56b220 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -11978,6 +11978,18 @@ bpf_sk_base_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
return func;
}
+int bpf_skb_meta_load_bytes(const struct sk_buff *skb, u32 offset,
+ void *dst, u32 len)
+{
+ u32 meta_len = skb_metadata_len(skb);
+
+ if (len > meta_len || offset > meta_len - len)
+ return -E2BIG; /* out of bounds */
+
+ memmove(dst, skb_metadata_end(skb) - meta_len + offset, len);
+ return 0;
+}
+
Nit: is it possible to use bpf_skb_meta_pointer() here to avoid
duplicating range check in both bpf_skb_meta_load_bytes()
and bpf_skb_meta_store_bytes()?
This will be a nice refactor. Thanks!