-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpf: Add open-coded style process file iterator and bpf_fget_task() kfunc #8101
Conversation
Upstream branch: 2c8b09a |
6c2b6b1
to
17914af
Compare
Upstream branch: 2c8b09a |
c08aebb
to
63cb5f9
Compare
17914af
to
09004f4
Compare
Upstream branch: 2c8b09a |
63cb5f9
to
d312183
Compare
09004f4
to
d499e8b
Compare
Upstream branch: fc39fb5 |
d312183
to
b77bfa1
Compare
d499e8b
to
251b2b6
Compare
This patch adds the open-coded iterator style process file iterator kfuncs bpf_iter_task_file_{new,next,destroy} that iterates over all files opened by the specified process. bpf_iter_task_file_next returns a pointer to bpf_iter_task_file_item, which currently contains *task, *file, fd. This is an extensible structure that enables compatibility with different versions through CO-RE. The reference to struct file acquired by the previous bpf_iter_task_file_next() is released in the next bpf_iter_task_file_next(), and the last reference is released in the last bpf_iter_task_file_next() that returns NULL. In the bpf_iter_task_file_destroy(), if the iterator does not iterate to the end, then the last struct file reference is released at this time. Signed-off-by: Juntong Deng <[email protected]>
This patch adds test cases for open-coded style process file iterator. Test cases related to process files are run in the newly created child process. Close all opened files inherited from the parent process in the child process to avoid the files opened by the parent process affecting the test results. In addition, this patch adds failure test cases where bpf programs cannot pass the verifier due to uninitialized or untrusted arguments, or not in RCU CS, etc. Signed-off-by: Juntong Deng <[email protected]>
This patch adds bpf_fget_task() kfunc. bpf_fget_task() is used to get a pointer to the struct file corresponding to the task file descriptor. Note that this function acquires a reference to struct file. Signed-off-by: Juntong Deng <[email protected]>
Currently fs kfuncs are only available for LSM program type, but fs kfuncs are generic and useful for scenarios other than LSM. This patch makes fs kfuncs available for SYSCALL and TRACING program types. Signed-off-by: Juntong Deng <[email protected]>
This patch adds test cases for bpf_fget_task() kfunc. test_bpf_fget_task is used to test obtaining struct file based on the file descriptor in the current process. bpf_fget_task_null_task and bpf_fget_task_untrusted_task are used to test the failure cases of passing NULL or untrusted pointer as argument. Signed-off-by: Juntong Deng <[email protected]>
Upstream branch: fc39fb5 |
b77bfa1
to
4e69be8
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=911034 expired. Closing PR. |
Pull request for series with
subject: bpf: Add open-coded style process file iterator and bpf_fget_task() kfunc
version: 4
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=911034