mirror of
https://github.com/torvalds/linux.git
synced 2026-11-27 17:02:17 +00:00
ovl_iterate_merged() stores PTR_ERR(cache) in err before checking
IS_ERR(cache). On success err holds the truncated cache pointer and
can be returned as a bogus non-zero error.
The syzbot reproducer reaches this through overlay-on-overlay readdir:
getdents64
iterate_dir(outer overlay file)
ovl_iterate_merged()
ovl_cache_get()
ovl_dir_read_merged()
ovl_dir_read()
iterate_dir(inner overlay file)
ovl_iterate_merged()
Only compute PTR_ERR(cache) on the error path.
Fixes: d25e4b739f ("ovl: refactor ovl_iterate() and port to cred guard")
Reported-by: [email protected]
Closes: https://syzkaller.appspot.com/bug?extid=a16fb0cce329a320661c
Cc: [email protected]
Signed-off-by: Nirmoy Das <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Christian Brauner <[email protected]>