fs/exec: Test patch for syzkaller crash
Subsystems (3)
PATCH 1/1 fs/exec: Test patch for syzkaller crash
From: Ira Weiny <[email protected]>
Kees reported that it looked like the kmap_local_page() conversion in fs/exec.c was causing a crash with the syzkaller.[1]
At first glance it appeared this was due to the lack of pagefaults not being disabled as was done by kmap_atomic().
Unfortunately, after deeper investigation we don't see how this is a problem. The crash does not appear to be happening in the memcpy_to_page() call.[2]
For testing, add back pagefault disable in copy_string_kernel() to see if it makes syzkaller happy. If so more investigation will need to be done to understand exactly what is happening.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c6e8e36c6ae4b11bed5643317afb66b6c3cadba8
[2] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/fs/exec.c?id=40d43a7507e1547dd45cb02af2e40d897c591870#n616
--- fs/exec.c | 2 ++ 1 file changed, 2 insertions(+)
fs/exec.c +2 -0
@@ -640,7 +640,9 @@ int copy_string_kernel(const char *arg, struct linux_binprm *bprm)if (!page)return -E2BIG ;flush_arg_page (bprm, pos &PAGE_MASK , page); +pagefault_disable ();memcpy_to_page (page,offset_in_page (pos), arg, bytes_to_copy); +pagefault_enable ();put_arg_page (page); }
Signature · 1 line
2.35.3
Quoted 16 lines · On Thu, Aug 11, 2022 at 05:09:19PM -0700, [email protected] wrote:
From: Ira Weiny <[email protected]>
Kees reported that it looked like the
kmap_local_page()conversion infs/exec.cwas causing a crash with the syzkaller.[1]At first glance it appeared this was due to the lack of pagefaults not being disabled as was done by
kmap_atomic().Unfortunately, after deeper investigation we don't see how this is a problem. The crash does not appear to be happening in the
memcpy_to_page()call.[2]For testing, add back pagefault disable in
copy_string_kernel()to see if it makes syzkaller happy. If so more investigation will need to be done to understand exactly what is happening.
Quoted 6 lines
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c6e8e36c6ae4b11bed5643317afb66b6c3cadba8
[2] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/fs/exec.c?id=40d43a7507e1547dd45cb02af2e40d897c591870#n616Cc Kees Cook <[email protected]>Reported-by [email protected]Signed-off-by Ira Weiny <[email protected]>
Thanks for spinning this. As noted in the other thread, I'm going to wait and see if the crashes return. It looks like it may have been an unrelated problem that got fix in -next (no crashes for a day now...)
But we'll have this in our back pocket if we need it. :)
-Kees
Signature · 1 line
Kees Cook