Commit c5dee337 authored by Jann Horn's avatar Jann Horn Committed by Gerrit - the friendly Code Review server
Browse files

tty: Fix ->pgrp locking in tiocspgrp()



tiocspgrp() takes two tty_struct pointers: One to the tty that userspace
passed to ioctl() (`tty`) and one to the TTY being changed (`real_tty`).
These pointers are different when ioctl() is called with a master fd.

To properly lock real_tty->pgrp, we must take real_tty->ctrl_lock.

This bug makes it possible for racing ioctl(TIOCSPGRP, ...) calls on
both sides of a PTY pair to corrupt the refcount of `struct pid`,
leading to use-after-free errors.

Fixes: 47f86834 ("redo locking of tty->pgrp")
CC: stable@kernel.org
Signed-off-by: default avatarJann Horn <jannh@google.com>
Reviewed-by: default avatarJiri Slaby <jirislaby@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Change-Id: I834ac1d9ee47e8793e4f403ebe2ba4f1881bf263
Git-commit: 54ffccbf
Git-repo: https://android.googlesource.com/kernel/msm


Signed-off-by: default avatarurevanth <urevanth@codeaurora.org>
parent 670504ad
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment