* [PATCH] tty: serial: return appropriate error on failure
@ 2021-12-07 22:17 Vihas Mak
2021-12-08 5:44 ` Jiri Slaby
2021-12-08 5:44 ` Greg KH
0 siblings, 2 replies; 4+ messages in thread
From: Vihas Mak @ 2021-12-07 22:17 UTC (permalink / raw)
To: gregkh, jirislaby; +Cc: linux-serial, linux-kernel, Vihas Mak
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
Signed-off-by: Vihas Mak <makvihas@gmail.com>
---
drivers/tty/serial/serial_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 61e3dd022..c204bdecc 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -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)) {
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tty: serial: return appropriate error on failure
2021-12-07 22:17 [PATCH] tty: serial: return appropriate error on failure Vihas Mak
@ 2021-12-08 5:44 ` Jiri Slaby
2021-12-08 5:44 ` Greg KH
1 sibling, 0 replies; 4+ messages in thread
From: Jiri Slaby @ 2021-12-08 5:44 UTC (permalink / raw)
To: Vihas Mak, gregkh; +Cc: linux-serial, linux-kernel
On 07. 12. 21, 23:17, Vihas Mak wrote:
> 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
>
> Signed-off-by: Vihas Mak <makvihas@gmail.com>
> ---
> drivers/tty/serial/serial_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 61e3dd022..c204bdecc 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -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
> if (uport->type == PORT_UNKNOWN)
> goto exit;
> if (tty_port_initialized(port)) {
>
--
js
suse labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tty: serial: return appropriate error on failure
2021-12-07 22:17 [PATCH] tty: serial: return appropriate error on failure Vihas Mak
2021-12-08 5:44 ` Jiri Slaby
@ 2021-12-08 5:44 ` Greg KH
2021-12-08 14:12 ` Vihas Mak
1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2021-12-08 5:44 UTC (permalink / raw)
To: Vihas Mak; +Cc: jirislaby, linux-serial, linux-kernel
On Wed, Dec 08, 2021 at 03:47:41AM +0530, Vihas Mak wrote:
> 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
>
> Signed-off-by: Vihas Mak <makvihas@gmail.com>
> ---
> drivers/tty/serial/serial_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 61e3dd022..c204bdecc 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tty: serial: return appropriate error on failure
2021-12-08 5:44 ` Greg KH
@ 2021-12-08 14:12 ` Vihas Mak
0 siblings, 0 replies; 4+ messages in thread
From: Vihas Mak @ 2021-12-08 14:12 UTC (permalink / raw)
To: Greg KH; +Cc: jirislaby, linux-serial, linux-kernel
>> 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
On Wed, Dec 8, 2021 at 11:15 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Dec 08, 2021 at 03:47:41AM +0530, Vihas Mak wrote:
> > 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
> >
> > Signed-off-by: Vihas Mak <makvihas@gmail.com>
> > ---
> > drivers/tty/serial/serial_core.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> > index 61e3dd022..c204bdecc 100644
> > --- a/drivers/tty/serial/serial_core.c
> > +++ b/drivers/tty/serial/serial_core.c
> > @@ -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
--
Thanks,
Vihas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-08 14:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 22:17 [PATCH] tty: serial: return appropriate error on failure Vihas Mak
2021-12-08 5:44 ` Jiri Slaby
2021-12-08 5:44 ` Greg KH
2021-12-08 14:12 ` Vihas Mak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).