tty: serial: return appropriate error on failure
PATCH 1/1 tty: serial: return appropriate error on failure
when a user with CAP_SYS_ADMIN disabled calls ioctl (TIOCSSERIAL), uart_set_info() returns 0 instead of -EPERM and the user remains unware about what went wrong. Fix this.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215205
--- drivers/tty/serial/serial_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/serial_core.c +1 -1
@@ -960,7 +960,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, uport->fifosize = new_info->xmit_fifo_size; check_and_exit: - retval =0 ; + retval = retval <0 ? retval :0 ;if (uport->type ==PORT_UNKNOWN ) goto exit;if (tty_port_initialized (port)) {
Signature · 1 line
2.30.2
Jiri Slaby
maintainerQuoted 16 lines · Vihas Mak
when a user with
CAP_SYS_ADMINdisabled calls ioctl (TIOCSSERIAL),uart_set_info()returns 0 instead of-EPERMand the user remains unware about what went wrong. Fix this.Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215205
Signed-off-by Vihas Mak <[email protected]>--- drivers/tty/serial/serial_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/tty/serial/serial_core.c +0
-0
drivers/tty/serial/serial_core.c static int uart_set_info(struct tty_struct *tty, struct tty_port *port, · line 963
Quoted 5 lines
drivers/tty/serial/serial_core.c +1
-1@@ -960,7 +960,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, uport->fifosize = new_info->xmit_fifo_size; check_and_exit: - retval =0 ; + retval = retval <0 ? retval :0 ;
This is wrong IMO. See:
https://bugzilla.kernel.org/show_bug.cgi?id=215205#c1
Quoted 4 lines
drivers/tty/serial/serial_core.c +0
-0if (uport->type ==PORT_UNKNOWN ) goto exit;if (tty_port_initialized (port)) {
Signature · 2 lines
js suse labs
Greg KH
maintainerQuoted 16 lines · Vihas Mak
when a user with
CAP_SYS_ADMINdisabled calls ioctl (TIOCSSERIAL),uart_set_info()returns 0 instead of-EPERMand the user remains unware about what went wrong. Fix this.Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215205
Signed-off-by Vihas Mak <[email protected]>--- drivers/tty/serial/serial_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/tty/serial/serial_core.c +0
-0
drivers/tty/serial/serial_core.c static int uart_set_info(struct tty_struct *tty, struct tty_port *port, · line 963
Quoted 5 lines
drivers/tty/serial/serial_core.c +1
-1@@ -960,7 +960,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, uport->fifosize = new_info->xmit_fifo_size; check_and_exit: - retval =0 ; + retval = retval <0 ? retval :0 ;
Please no, do not use ? : unless you have to. Spell it out and use a real if statement.
thanks,
greg k-h
Quoted 2 lines
Quoted 2 lines
Please no, do not use ? : unless you have to. Spell it out and use a real if statement.
Okay. But I don't think it's required anymore, as Jiri pointed out in
https://bugzilla.kernel.org/show_bug.cgi?id=215205#c1
Quoted 30 lines · Greg KH
Quoted 16 lines · Vihas Mak
when a user with
CAP_SYS_ADMINdisabled calls ioctl (TIOCSSERIAL),uart_set_info()returns 0 instead of-EPERMand the user remains unware about what went wrong. Fix this.Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215205
Signed-off-by Vihas Mak <[email protected]>--- drivers/tty/serial/serial_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/tty/serial/serial_core.c +0
-0drivers/tty/serial/serial_core.c static int uart_set_info(struct tty_struct *tty, struct tty_port *port, · line 963
Quoted 5 lines
drivers/tty/serial/serial_core.c +1
-1@@ -960,7 +960,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, uport->fifosize = new_info->xmit_fifo_size; check_and_exit: - retval =0 ; + retval = retval <0 ? retval :0 ;Please no, do not use ? : unless you have to. Spell it out and use a real if statement.
thanks,
greg k-h
Signature · 2 lines
Thanks, Vihas