lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8c65bc42-438e-bf3e-fb76-2a4cbc7296c0@kernel.org>
Date:   Tue, 22 Feb 2022 07:52:36 +0100
From:   Jiri Slaby <jirislaby@...nel.org>
To:     Lino Sanfilippo <LinoSanfilippo@....de>,
        gregkh@...uxfoundation.org, u.kleine-koenig@...gutronix.de
Cc:     linux@...linux.org.uk, richard.genoud@...il.com,
        nicolas.ferre@...rochip.com, alexandre.belloni@...tlin.com,
        ludovic.desroches@...rochip.com, shawnguo@...nel.org,
        s.hauer@...gutronix.de, kernel@...gutronix.de, festevam@...il.com,
        linux-imx@....com, mcoquelin.stm32@...il.com,
        alexandre.torgue@...s.st.com, linux-serial@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-stm32@...md-mailman.stormreply.com, lukas@...ner.de,
        p.rosenberger@...bus.com
Subject: Re: [PATCH v3 1/9] serial: core: move RS485 configuration tasks from
 drivers into core

On 22. 02. 22, 7:51, Jiri Slaby wrote:
> On 22. 02. 22, 2:14, Lino Sanfilippo wrote:
>> Several drivers that support setting the RS485 configuration via 
>> userspace
>> implement one or more of the following tasks:
>>
>> - in case of an invalid RTS configuration (both RTS after send and RTS on
>>    send set or both unset) fall back to enable RTS on send and disable 
>> RTS
>>    after send
>>
>> - nullify the padding field of the returned serial_rs485 struct
>>
>> - copy the configuration into the uart port struct
>>
>> - limit RTS delays to 100 ms
>>
>> Move these tasks into the serial core to make them generic and to provide
>> a consistent behaviour among all drivers.
>>
>> Signed-off-by: Lino Sanfilippo <LinoSanfilippo@....de>
>> ---
>>   drivers/tty/serial/serial_core.c | 29 +++++++++++++++++++++++++++++
>>   1 file changed, 29 insertions(+)
>>
>> diff --git a/drivers/tty/serial/serial_core.c 
>> b/drivers/tty/serial/serial_core.c
>> index 846192a7b4bf..2b3afe038c1c 100644
>> --- a/drivers/tty/serial/serial_core.c
>> +++ b/drivers/tty/serial/serial_core.c
>> @@ -42,6 +42,11 @@ static struct lock_class_key port_lock_key;
>>   #define HIGH_BITS_OFFSET    ((sizeof(long)-sizeof(int))*8)
>> +/*
>> + * Max time with active RTS before/after data is sent.
>> + */
>> +#define RS485_MAX_RTS_DELAY    100 /* msecs */
>> +
>>   static void uart_change_speed(struct tty_struct *tty, struct 
>> uart_state *state,
>>                       struct ktermios *old_termios);
>>   static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
>> @@ -1282,8 +1287,32 @@ static int uart_set_rs485_config(struct 
>> uart_port *port,
>>       if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user)))
>>           return -EFAULT;
>> +    /* pick sane settings if the user hasn't */
>> +    if (!(rs485.flags & SER_RS485_RTS_ON_SEND) ==
>> +        !(rs485.flags & SER_RS485_RTS_AFTER_SEND)) {
>> +        pr_warn("invalid RTS setting, using RTS_ON_SEND instead\n");
> 
> Can't we have a device prefix here, so that everyone knows what device 
> is affected? Without that, it's not that useful. At least port->name & 
> port->line could be printed. The uart core uses dev_* prints, but prints 
> also line as uport->dev can be NULL sometimes.

And this comes from userspace, so should be ratelimited.

-- 
js
suse labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ