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]
Date:   Fri, 19 Feb 2021 09:00:38 +0100
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Pavel Machek <pavel@....cz>
Cc:     kernel@...gutronix.de,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org, Johan Hovold <johan@...nel.org>,
        Jacek Anaszewski <jacek.anaszewski@...il.com>,
        linux-serial@...r.kernel.org, Jiri Slaby <jslaby@...e.com>,
        linux-leds@...r.kernel.org, Dan Murphy <dmurphy@...com>
Subject: Re: [PATCH v11] leds: trigger: implement a tty trigger

Hi Pavel,

On Thu, Feb 18, 2021 at 02:37:33PM +0100, Pavel Machek wrote:
> Close, but see below:
> 
> > +static ssize_t ttyname_store(struct device *dev,
> > +			     struct device_attribute *attr, const char *buf,
> > +			     size_t size)
> > +{
> > +	struct ledtrig_tty_data *trigger_data = led_trigger_get_drvdata(dev);
> > +	char *ttyname;
> > +	ssize_t ret = size;
> > +	bool running;
> > +
> > +	if (size > 0 && buf[size - 1] == '\n')
> > +		size -= 1;
> > +
> > +	if (size) {
> > +		ttyname = kmemdup_nul(buf, size, GFP_KERNEL);
> > +		if (!ttyname) {
> > +			ret = -ENOMEM;
> > +			goto out_unlock;
> 
> Unlock without a lock:
> 
> > +out_unlock:
> > +	mutex_unlock(&trigger_data->mutex);

Indeed, I prepare an incremental patch that does return -ENOMEM instead
of goto out_unlock.

> > +
> > +	if (ttyname && !running)
> > +		ledtrig_tty_restart(trigger_data);
> > +
> > +	return ret;
> > +}
> 
> > +
> > +		tty = tty_kopen_shared(devno);
> > +		if (IS_ERR(tty) || !tty)
> > +			/* What to do? retry or abort */
> > +			goto out;
> 
> Abort would make sense to me.

In this case it would IMHO be sensible to already try the
tty_kopen_shared() in ttyname_store() and let that one fail if the tty
doesn't exist. I'll have to go through the history of this patch set, if
I remember correctly it was like that at one point.

> > +	if (icount.rx != trigger_data->rx ||
> > +	    icount.tx != trigger_data->tx) {
> > +		led_set_brightness(trigger_data->led_cdev, LED_ON);
> 
> Please use _sync version.

OK, there are too many variants for me. I'll just believe you that
led_set_brightness_sync is the right one. (Hmm, on the other hand I'll
have to understand the difference for a good commit log. I'll dig into
that. "Pavel said so" probably isn't good enough :-))

Best regards and thanks for your review,
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ