All of lore.kernel.org
 help / color / mirror / Atom feed
* [UART] Why CAP_SYS_ADMIN can open non-started port?
@ 2011-08-17  9:25 Jiri Slaby
  2011-08-17 10:13 ` Alan Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Slaby @ 2011-08-17  9:25 UTC (permalink / raw)
  To: linux-serial; +Cc: Alan Cox, Greg KH, linux

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,
-- 
js

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [UART] Why CAP_SYS_ADMIN can open non-started port?
  2011-08-17  9:25 [UART] Why CAP_SYS_ADMIN can open non-started port? Jiri Slaby
@ 2011-08-17 10:13 ` Alan Cox
  2011-08-17 11:48   ` [PATCH] TTY: serial, document ignoring of uart->ops->startup error Jiri Slaby
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Cox @ 2011-08-17 10:13 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: linux-serial, Greg KH, linux

On Wed, 17 Aug 2011 11:25:27 +0200
Jiri Slaby <jirislaby@gmail.com> 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;
> 
>   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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] TTY: serial, document ignoring of uart->ops->startup error
  2011-08-17 10:13 ` Alan Cox
@ 2011-08-17 11:48   ` Jiri Slaby
  0 siblings, 0 replies; 3+ messages in thread
From: Jiri Slaby @ 2011-08-17 11:48 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, linux-serial, jirislaby, Jiri Slaby, Alan Cox,
	Russel King

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.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Greg KH <gregkh@suse.de>
Cc: Russel King <linux@arm.linux.org.uk>
---
On 08/17/2011 12:13 PM, Alan Cox wrote:
> On Wed, 17 Aug 2011 11:25:27 +0200
> Jiri Slaby <jirislaby@gmail.com> 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;
>>
>>   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(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index db7912c..a3efbea 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -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;
 
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-17 11:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-17  9:25 [UART] Why CAP_SYS_ADMIN can open non-started port? Jiri Slaby
2011-08-17 10:13 ` Alan Cox
2011-08-17 11:48   ` [PATCH] TTY: serial, document ignoring of uart->ops->startup error Jiri Slaby

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.