Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
devpts: fix error handling in devpts_mntget()
If devpts_ptmx_path() returns an error code, then devpts_mntget() dereferences an ERR_PTR(): BUG: unable to handle kernel paging request at fffffffffffffff5 IP: devpts_mntget+0x13f/0x280 fs/devpts/inode.c:173 Fix it by returning early in the error paths. Reproducer: #define _GNU_SOURCE #include <fcntl.h> #include <sched.h> #include <sys/ioctl.h> #define TIOCGPTPEER _IO('T', 0x41) int main() { for (;;) { int fd = open("/dev/ptmx", 0); unshare(CLONE_NEWNS); ioctl(fd, TIOCGPTPEER, 0); } } Fixes: 311fc65 ("pty: Repair TIOCGPTPEER") Reported-by: syzbot <[email protected]> Cc: <[email protected]> # v4.13+ Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
- Loading branch information