Skip to contentSkip to conversation

Why CAP_SYS_ADMIN can open non-started port?

UART New Jiri Slaby 3 participants 3 messages Aug 17, 2011 TTY layer and serial drivers

lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

Hi,

while I was in the process of uart cleanup, I found this:
static int uart_startup(...) {
...
retval = port->ops->startup(port);
...
if (retval && capable(CAP_SYS_ADMIN))

    retval = 0;

return retval;
}

Why CAP_SYS_ADMIN should not see the failing port startup? Does anybody from you remember if it is for some kind of possibility to later re-autoconfigure the port or something like that?

thanks,

Signature · 1 line
js
#1 lore raw
Quoted 8 lines · On Wed, 17 Aug 2011 11:25:27 +0200 Jiri Slaby <[email protected]> wrote:

Hi,

while I was in the process of uart cleanup, I found this:
static int uart_startup(...) {
...
retval = port->ops->startup(port);
...
if (retval && capable(CAP_SYS_ADMIN))

Quoted 8 lines
    retval = 0;

return retval;
}

Why CAP_SYS_ADMIN should not see the failing port startup? Does anybody from you remember if it is for some kind of possibility to later re-autoconfigure the port or something like that?

In a word - setserial

Alan

#2 lore raw

PATCH 1/1 TTY: serial, document ignoring of uart->ops->startup error

When a user has SYS_ADMIN capabilities and uart->ops->startup returns an error in uart_startup, we silently drop the error. We then return 0 and behave as if it didn't fail. (Not quite, since we set TTY_IO_ERROR bit and leave ASYNC_INITIALIZED bit cleared.)

This all is to allow setserial to work with improperly configured or unconfigured ports. User can thus set port properties and reconfigure properly.

This patch only documents this behavior.

Cc Alan Cox <[email protected]>
Cc Greg KH <[email protected]>
Cc Russel King <[email protected]>

---

Quoted 13 lines · Alan Cox
Quoted 10 lines · On Wed, 17 Aug 2011 11:25:27 +0200 Jiri Slaby <[email protected]> wrote:

Hi,

while I was in the process of uart cleanup, I found this:
static int uart_startup(...) {
...
retval = port->ops->startup(port);
...
if (retval && capable(CAP_SYS_ADMIN))

    retval = 0;
Quoted 8 lines
Quoted 6 lines

return retval;
}

Why CAP_SYS_ADMIN should not see the failing port startup? Does anybody from you remember if it is for some kind of possibility to later re-autoconfigure the port or something like that?

In a word - setserial

Yes, thanks. So I assume especially for the configuration of port/irq/type. So this is why this is special to tty/serial and USB serials don't need to support this.

 drivers/tty/serial/serial_core.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/tty/serial/serial_core.c +5 -0
index db7912c..a3efbea 100644
@@ -200,6 +200,11 @@ static int uart_startup(struct tty_struct *tty, struct uart_state *state, int in
 		clear_bit(TTY_IO_ERROR, &tty->flags);
 	}
 
+	/*
+	 * This is to allow setserial on this port. People may want to set
+	 * port/irq/type and then reconfigure the port properly if it failed
+	 * now.
+	 */
 	if (retval && capable(CAP_SYS_ADMIN))
 		retval = 0;
 
Signature · 1 line
1.7.6