Eric Biggers c9cc8d01fb 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: 311fc65c9fb9 ("pty: Repair TIOCGPTPEER")
Reported-by: syzbot <syzkaller@googlegroups.com>
Cc: <stable@vger.kernel.org> # v4.13+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-01-31 08:48:37 -08:00
..
2018-01-29 06:42:20 -05:00
2018-01-29 13:33:53 -08:00
2018-01-29 14:04:23 -08:00
2017-12-17 12:20:58 -08:00
2017-11-27 16:20:05 -05:00
2018-01-29 06:42:20 -05:00
2018-01-29 06:42:20 -05:00
2018-01-29 13:33:53 -08:00
2018-01-30 19:07:32 -08:00
2018-01-29 06:42:20 -05:00
2017-11-16 11:41:22 -08:00
2017-11-17 09:51:57 -08:00
2018-01-24 17:33:57 -05:00
2018-01-30 19:03:48 -08:00
2018-01-29 13:33:53 -08:00
2018-01-01 10:09:33 -05:00
2018-01-29 06:42:21 -05:00
2018-01-29 13:33:53 -08:00
2017-09-04 19:05:15 -04:00
2018-01-06 09:18:00 -07:00
2017-04-17 12:52:27 -04:00
2017-11-27 16:20:05 -05:00
2018-01-03 10:13:36 -08:00
2017-12-09 20:16:33 -05:00
2017-11-27 16:20:05 -05:00
2017-11-27 16:20:05 -05:00
2017-11-27 16:20:05 -05:00