Skip to content
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

Some questions about attach_lsm #5164

Open
wyEumenides opened this issue Dec 5, 2024 · 1 comment
Open

Some questions about attach_lsm #5164

wyEumenides opened this issue Dec 5, 2024 · 1 comment

Comments

@wyEumenides
Copy link

I would like to know how to use the attach_lsm and detach_lsm methods, what should be passed as the "fn_name" parameter, and whether it is possible to pass the kernel call as event and the custom trace function name as fn_name, just like attach_kprobe.

@wyEumenides
Copy link
Author

wyEumenides commented Dec 5, 2024

I wrote the following code:

from bpfcc import BPF

BLOCKED_INODE = 2930240  // test 

bpf_program = (
    """
#include <uapi/linux/ptrace.h>
#include <linux/fs.h>
#include <linux/dcache.h>

#define BLOCKED_INODE %d



LSM_PROBE(file_open, struct file *file) {
    struct inode *inode = file->f_inode;
    if (inode->i_ino == BLOCKED_INODE) {
        return -1; 
    }
    return 0;

}

"""
    % BLOCKED_INODE
)

if not BPF.support_lsm():
    print("do not spport LSM!")
b = BPF(text=bpf_program)

It's in line with expectations, but how to change to use attach_lsm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant