microsoft / microsoft/ebpf-for-windows
Support BPF dynamic pointers
- Dominant language
- C
- Stars
- 3.6k
- Forks
- 311
- Avg merge
- 6d 10h
- Merged PRs (30d)
- 21
Description
### Describe the feature you'd like supported
Linux supports memory allocation, access, and release via helper functions.
```
struct bpf_dynptr_kern {
void *data;
u32 size;
u32 offset;
} __aligned(8);
/* Dynamically allocate memory */
bpf_dynptr_alloc(size, 0, &ptr);
/* Get a dynptr to __sk_buff data */
bpf_dynptr_from_skb(skb, &skb_ptr);
/* Get a dynptr to xdp_md data */
bpf_dynptr_from_xdp(ctx, &xdp_ptr);
/* Advance the ptr into skb->data */
bpf_dynptr_advance(&skb_ptr, sizeof(struct ethhdr));
/* Write into the memory */
bpf_dynptr_write(&ptr, 0, buf, sizeof(buf));
/* Release the memory allocation */
bpf_dynptr_put(&ptr);
```
References:
* [BPF: Dynamic pointers [LWN.net]](https://lwn.net/Articles/895885/)
* http://vger.kernel.org/bpfconf2022_material/lsfmmbpf2022-dynptr.pdf
Support is blocked on https://github.com/vbpf/ebpf-verifier/issues/273
### Proposed solution
Support the same helper functions that Linux supports
### Additional context
_No response_
Contributor guide
Research direction
Start by reviewing the linked verifier blocker, vbpf/ebpf-verifier#273, and the Linux dynamic-pointer helper behavior described in this issue. Identify the corresponding support boundary in ebpf-for-windows before implementing anything. Done means the Linux-supported dynamic-pointer helper functions listed here are supported and covered by suitable verification and behavior checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, linux
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100