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: <20201025171613.GT26280@localhost>
Date:   Sun, 25 Oct 2020 18:16:13 +0100
From:   Johan Hovold <johan@...nel.org>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        "Ahmed S. Darwish" <a.darwish@...utronix.de>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        Johan Hovold <johan@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-usb@...r.kernel.org,
        Thomas Winischhofer <thomas@...ischhofer.net>,
        Mathias Nyman <mathias.nyman@...el.com>,
        Valentina Manea <valentina.manea.m@...il.com>,
        Shuah Khan <shuah@...nel.org>,
        Alan Stern <stern@...land.harvard.edu>,
        linux-omap@...r.kernel.org, Kukjin Kim <kgene@...nel.org>,
        Krzysztof Kozlowski <krzk@...nel.org>,
        linux-arm-kernel@...ts.infradead.org,
        linux-samsung-soc@...r.kernel.org, Felipe Balbi <balbi@...nel.org>,
        Duncan Sands <duncan.sands@...e.fr>
Subject: Re: [patch V2 04/13] USB: serial: digi_acceleport: Remove
 in_interrupt() usage

On Mon, Oct 19, 2020 at 12:06:33PM +0200, Thomas Gleixner wrote:
> From: Ahmed S. Darwish <a.darwish@...utronix.de>
> 
> The usage of in_interrupt() in drivers is phased out and Linus clearly
> requested that code which changes behaviour depending on context should
> either be separated or the context be conveyed in an argument passed by the
> caller, which usually knows the context.
> 
> The debug printk() in digi_write() prints in_interrupt() as context
> information. TTY writes happen always in preemptible task context and
> console writes can happen from almost any context, so in_interrupt() is not
> really helpful.

The above statement is not correct, TTY writes can and do happen from
other contexts, including soft IRQ (e.g. PPP).

> Aside of that issuing a printk() from a console->write() callback is not a
> really brilliant idea for obvious reasons.

True, but we don't need to sprinkle conditionals for the benefit of
people trying to debug USB serial drivers using a USB serial console.
They get what they deserve. ;)

> Remove the in_interrupt() printout and make the printk() depend on tty.
> 
> Signed-off-by: Ahmed S. Darwish <a.darwish@...utronix.de>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> Cc: Johan Hovold <johan@...nel.org>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Cc: linux-usb@...r.kernel.org
> 
> ---
>  drivers/usb/serial/digi_acceleport.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> --- a/drivers/usb/serial/digi_acceleport.c
> +++ b/drivers/usb/serial/digi_acceleport.c
> @@ -911,9 +911,10 @@ static int digi_write(struct tty_struct
>  	unsigned char *data = port->write_urb->transfer_buffer;
>  	unsigned long flags = 0;
>  
> -	dev_dbg(&port->dev,
> -		"digi_write: TOP: port=%d, count=%d, in_interrupt=%ld\n",
> -		priv->dp_port_num, count, in_interrupt());
> +	if (tty) {
> +		dev_dbg(&port->dev, "digi_write: TOP: port=%d, count=%d\n",
> +			priv->dp_port_num, count);
> +	}

So just drop the in_interrupt() here.

Also note that we already have another unconditional dev_dbg() at the
end of this function.

>  
>  	/* copy user data (which can sleep) before getting spin lock */
>  	count = min(count, port->bulk_out_size-2);
> 

Johan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ