ayourtch / nat46

OpenWRT feed with stateless NAT46 kernel module
34 stars 28 forks source link

Fix crash when viewing nat46 kernel module config #43

Closed coledishington closed 1 month ago

coledishington commented 1 month ago

In the commit 91b8e68 Add network namespace awareness to nat46 the network namespace of the /proc/net file is now passed via single_open() to nat46_proc_show(). However, the priv arg passed to single_open() is accessed via the seq_file, not the second value. When using the second value, the 'network namespace' is invalid and causes a kernel oops.

Access the network namespace in nat46_proc_show from struct seq_file.

ayourtch commented 1 month ago

Is there a way to make the code conditional on the kernel version, so it could work both before and after the change ?

coledishington commented 1 month ago

Is there a way to make the code conditional on the kernel version, so it could work both before and after the change ?

Sorry for the delay in my answer. This was an error in my original patch, from what I can see the data passed to single_open() has been accessed by the (struct seq_file*)->private for a very long time, at least as far back as 2.6.12.

See: commit -> https://github.com/torvalds/linux/commit/1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 file -> https://github.com/torvalds/linux/blob/1da177e4c3f41524e886b7f1b8a0c1fc7321cac2/fs/seq_file.c#L392

ayourtch commented 1 month ago

Thanks a lot for the clarification!