Comments (8)
@xuanyue0 The code for the map relocation isn't the cleanest but I will push it on the fork I've got of ubpf so you can have a look. Regarding the map themselves, I've got two implementations for the time being, one where the kernel maps are called but in that case the prototype has to be slightly different (the data is copied back and forth user-space and kernel space, it's not the fastest ...) And a second implementation where I just brought the maps (array and hashtable) in userspace so it got nothing to do with the kernel anymore. The code will be on github at some point relatively soon, but I can't right now for some reasons
@rlane I will make a pull request for the stack fix later on today
from ubpf.
First thing is the C code I'm using (compiled to bpf with clang). I modified the loader to do the map relocation from the elf and also added both map functions to the vm.
@simon-jouet That looks like code many of us will need 😃
Would you be willing to contribute it back?
/cc @rlane
from ubpf.
Sorry I missed this before. Please send a pull request if you have a chance.
from ubpf.
The code for the map relocation isn't the cleanest but I will push it on the fork I've got of ubpf so you can have a look.
Thanks!
Regarding the map themselves, I've got two implementations for the time being, one where the kernel maps are called but in that case the prototype has to be slightly different (the data is copied back and forth user-space and kernel space, it's not the fastest ...)
You probably can't share the details but why do need kernel maps if the BPF VM is in userspace??
from ubpf.
You probably can't share the details but why do need kernel maps if the BPF VM is in userspace??
You don't, it was just an easy way to bring the maps in without having to recode them. The proper way to do it is the second way I did it by bringing the code in userspace but it requires slightly more dev. effort :). If you're interested I can discuss what I'm doing in private, just not here for the time being.
from ubpf.
@simon-jouet Sure, I'm xuanyue0 on freenode (I'm usually on the #github chan). You can also join me by mail.
from ubpf.
And a second implementation where I just brought the maps (array and hashtable) in userspace so it got nothing to do with the kernel anymore. The code will be on github at some point relatively soon, but I can't right now for some reasons
@simon-jouet Do you know if you will be able to publish this soon? I have implemented the map relocations and am currently finishing the implementation of the arrays. If I can avoid reimplementing the hash tables from scratch, that'd be 👍
from ubpf.
Hi @xuanyue0, hopefully in a month (I know it's quite a while but not much I can do about it). For the hash table implementation there isn't much point re-implementing it from scratch.
You can't really just reuse the hashtable from the kernel implementation because AFAIK the data structure is not available in userspace, but it's fairly trivial to use an existing hashtable implementation and write the few functions to deal with the lookup/insert ...
The only thing to deal with is the file descriptor, by default every kernel ebpf table is associated a file descriptor which doesn't make sense in a userspace application so you need to have some global index that points to the different instantiated tables.
from ubpf.
Related Issues (20)
- MAX_EXT_FUNCS seems to be too small HOT 1
- Missing support for atomic instructions
- ubpf_load fails to validate immediate offset when computing jump targets
- Memory out-of-bound access in the ubpf_fetch_instruction when executing unterminated eBPF program HOT 1
- Incorrect boundary check leading to the out-of-bound memory access HOT 1
- Missing boundary check for load/store in JIT compiler HOT 1
- Incorrect exit implementation in JIT compiler HOT 1
- Incorrect CALL code generation (emit_local_call) in JIT compiler HOT 1
- uBPF interpreter has incorrect behavior for jump with immediate values > 0x7fffffff HOT 2
- uBPF emits wrong instructions for register to register multiplication/division/modulo operations if immediate != 0
- x64 JIT emit wrong jump target when target is at start of byte code
- 32bit ALU operations fail to truncate target register
- Recursive local call causes uBPF JIT to crash HOT 1
- Jump target for PC 0 is wrong
- Crash if call target is not start of a function HOT 1
- Crash on computing required stack size for inner most nested local-call
- Fix code scanning alert - Wrong type of arguments to formatting function
- Fix code scanning alert - Multiplication result converted to larger type
- LE16 fails to truncate register value HOT 2
- Potential dereference of `nullptr` in libfuzzer harness?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ubpf.