From: David Howells Date: Wed, 8 Nov 2017 15:11:35 +0000 (+0000) Subject: Lock down TIOCSSERIAL X-Git-Tag: archive/raspbian/4.15.17-1+rpi1^2~34 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=34c6fb1b64c1299544e5963748a110ad165f9062;p=linux.git Lock down TIOCSSERIAL Lock down TIOCSSERIAL as that can be used to change the ioport and irq settings on a serial port. This only appears to be an issue for the serial drivers that use the core serial code. All other drivers seem to either ignore attempts to change port/irq or give an error. Reported-by: Greg Kroah-Hartman Signed-off-by: David Howells cc: Jiri Slaby Gbp-Pq: Topic features/all/lockdown Gbp-Pq: Name 0021-Lock-down-TIOCSSERIAL.patch --- diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 6e0ab3333f6..c8e17c74e2e 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -829,6 +829,12 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, new_flags = (__force upf_t)new_info->flags; old_custom_divisor = uport->custom_divisor; + if ((change_port || change_irq) && + kernel_is_locked_down("Using TIOCSSERIAL to change device addresses, irqs and dma channels")) { + retval = -EPERM; + goto exit; + } + if (!capable(CAP_SYS_ADMIN)) { retval = -EPERM; if (change_irq || change_port ||