landhb / DrawBridge

Layer 4 Single Packet Authentication Linux kernel module utilizing Netfilter hooks and kernel supported Berkeley Packet Filters (BPF)
GNU General Public License v3.0
112 stars 23 forks source link

Error inserting module on linux 6.0.6 #31

Closed c-nixon closed 2 years ago

c-nixon commented 2 years ago

I get the following error in dmesg while trying out drawbridge from the latest master (commit 99376d4aea) on Arch Linux using the distro provided 6.0.6 package.

Command:

insmod drawbridge.ko ports=22,445 

dmesg output:

[-] Could not attach bpf zero filter to socket -12 
[-] drawbridge: Unable to setup child thread

I added a few printk's and it seems like the failure is coming from the refcount check in db_sk_filter_charge.

Is there anything I can do to help debug?

landhb commented 2 years ago

@c-nixon Thanks for the report.

Just curious, what value to you have for:

sudo sysctl net.core.optmem_max

Since that's the value that ends up checked here:

https://github.com/landhb/DrawBridge/blob/master/module/src/sk_filter.c#L70

More information on the configuration value:

https://stackoverflow.com/questions/47723793/in-linux-how-do-i-determine-optimal-value-of-optmem-max

If increasing that value doesn't work we could try running under gdb with nixmodule to see where it's failing.

landhb commented 2 years ago

Didn't have my coffee this morning, just noticing you said it was from the refcount_inc_not_zero. That is more confusing haha. I'll try to take a look

landhb commented 2 years ago

@c-nixon I think https://github.com/landhb/DrawBridge/commit/5386fb917408c2cac2cf9f18382d1f5f4ffaa183 should do it.

Please let me know if that works. Thanks!

c-nixon commented 2 years ago

Success! Thanks for the help!

# uname -r
6.0.6-arch1-2-01033-g2eddb2cf20dd
# insmod drawbridge.ko ports=22,445
# dmesg -t | tail -n1
[+] drawbridge: Loaded module into kernel - monitoring 2 port(s)