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

Fix crash when viewing nat46 kernel module config #43

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

coledishington
Copy link
Contributor

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.

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
Copy link
Owner

ayourtch commented Aug 1, 2024

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

@coledishington
Copy link
Contributor Author

coledishington commented Aug 12, 2024

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 -> torvalds/linux@1da177e
file -> https://github.com/torvalds/linux/blob/1da177e4c3f41524e886b7f1b8a0c1fc7321cac2/fs/seq_file.c#L392

@ayourtch ayourtch merged commit b42c37d into ayourtch:master Aug 12, 2024
1 check passed
@ayourtch
Copy link
Owner

Thanks a lot for the clarification!

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

Successfully merging this pull request may close these issues.

2 participants