Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
jira VULN-4370
cve CVE-2021-47461
commit-author Nadav Amit [email protected]
commit cb185d5
A race is possible when a process exits, its VMAs are removed by exit_mmap() and at the same time userfaultfd_writeprotect() is called.
The race was detected by KASAN on a development kernel, but it appears to be possible on vanilla kernels as well.
Use mmget_not_zero() to prevent the race as done in other userfaultfd operations.
Link: https://lkml.kernel.org/r/[email protected] Fixes: 63b2d41 ("userfaultfd: wp: add the writeprotect API to userfaultfd ioctl")
Signed-off-by: Nadav Amit [email protected]
Tested-by: Li Wang [email protected]
Reviewed-by: Peter Xu [email protected]
Cc: Andrea Arcangeli [email protected]
Cc: [email protected]
Signed-off-by: Andrew Morton [email protected]
Signed-off-by: Linus Torvalds [email protected]
(cherry picked from commit cb185d5)
Signed-off-by: Greg Rose [email protected]
Boots and runs:
Test Logs:
Before and after kernel selftest logs:
kernel-selftest-before.log
kernel-selftest-after.log
Kernel selftests were run with lockdep and kmemleak enabled and with stress running in the background - some of the usual anomalies popped up but nothing exraordinary.
No changes to the netfilter tables test results which were also run with lockdep, kmemleak and stress running.
nftables-test.log