Lock down TIOCSSERIAL
authorDavid Howells <dhowells@redhat.com>
Wed, 8 Nov 2017 15:11:35 +0000 (15:11 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 19 Apr 2018 10:13:03 +0000 (11:13 +0100)
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 <gregkh@linuxfoundation.org>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jiri Slaby <jslaby@suse.com>

Gbp-Pq: Topic features/all/lockdown
Gbp-Pq: Name 0021-Lock-down-TIOCSSERIAL.patch

drivers/tty/serial/serial_core.c

index 6e0ab3333f62a3c3a55f2529ca4a924410be0636..c8e17c74e2e7eb880c5e34046f56f2b4dd378bc5 100644 (file)
@@ -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 ||