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] [day] [month] [year] [list]
Message-ID: <a7f55acaba62183586422e0202fa90ef@vanmierlo.com>
Date: Tue, 02 Jan 2024 16:53:52 +0100
From: Maarten Brock <m.brock@...mierlo.com>
To: Lino Sanfilippo <LinoSanfilippo@....de>
Cc: Lino Sanfilippo <l.sanfilippo@...bus.com>, gregkh@...uxfoundation.org,
 jirislaby@...nel.org, ilpo.jarvinen@...ux.intel.com,
 u.kleine-koenig@...gutronix.de, shawnguo@...nel.org, s.hauer@...gutronix.de,
 mcoquelin.stm32@...il.com, alexandre.torgue@...s.st.com,
 cniedermaier@...electronics.com, hugo@...ovil.com,
 linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org, lukas@...ner.de,
 p.rosenberger@...bus.com, stable@...r.kernel.org, Hugo Villeneuve
 <hvilleneuve@...onoff.com>
Subject: Re: [PATCH v6 1/7] serial: Do not hold the port lock when setting
 rx-during-tx GPIO

Lino Sanfilippo wrote on 2023-12-29 16:03:
> Hi,
> 
> On 25.12.23 at 13:31, Maarten Brock wrote:
>> Lino Sanfilippo wrote on 2023-12-25 12:35:
>>> diff --git a/drivers/tty/serial/serial_core.c 
>>> b/drivers/tty/serial/serial_core.c
>>> +static void uart_set_rs485_rx_during_tx(struct uart_port *port,
>>> +                    const struct serial_rs485 *rs485)
>>> +{
>>> +    if (!(rs485->flags & SER_RS485_ENABLED))
>>> +        return;
>> 
>> How about checking port->rs485_rx_during_tx_gpio here against NULL 
>> instead of
>> before every call?
> 
> gpiod_set_value_cansleep() already checks for a NULL pointer, so doing
> this check in the caller is not needed.

Ah, sorry, you're right.

>>> +    gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio,
>>> +                 !!(rs485->flags & SER_RS485_RX_DURING_TX));
>>> +}
>>> +
>>> @@ -1457,6 +1472,7 @@ static int uart_set_rs485_config(struct
>>> tty_struct *tty, struct uart_port *port,
>>>          return ret;
>>>      uart_sanitize_serial_rs485(port, &rs485);
>>>      uart_set_rs485_termination(port, &rs485);
>>> +    uart_set_rs485_rx_during_tx(port, &rs485);
>>> 
>>>      uart_port_lock_irqsave(port, &flags);
>>>      ret = port->rs485_config(port, &tty->termios, &rs485);
>>> @@ -1468,8 +1484,14 @@ static int uart_set_rs485_config(struct
>>> tty_struct *tty, struct uart_port *port,
>>>              port->ops->set_mctrl(port, port->mctrl);
>>>      }
>>>      uart_port_unlock_irqrestore(port, flags);
>>> -    if (ret)
>>> +    if (ret) {
>>> +        /* restore old GPIO settings */
>>> +        gpiod_set_value_cansleep(port->rs485_term_gpio,
>>> +            !!(port->rs485.flags & SER_RS485_TERMINATE_BUS));
>>> +        gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio,
>>> +            !!(port->rs485.flags & SER_RS485_RX_DURING_TX));
>> 
>> This does not look like restoring.
> 
> Hmm. The rx-during-tx and terminate-bus GPIOs may have changed before 
> the
> drivers rs485_config() was called. If that function fails, the GPIOs
> are set back to the values they had before (i.e what is still stored in
> the ports serial_rs485 struct). So what is wrong with the term 
> "restore"?

Oops, I missed that too that port-rs485 is not updated in this case.

Kind Regards,
Maarten Brock


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ