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: <YkxqGDsURPpkDM5W@smile.fi.intel.com>
Date:   Tue, 5 Apr 2022 19:11:04 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
Cc:     linux-serial@...r.kernel.org, Greg KH <gregkh@...uxfoundation.org>,
        Jiri Slaby <jirislaby@...nel.org>,
        linux-kernel@...r.kernel.org,
        Gilles Buloz <gilles.buloz@...tron.com>,
        Johan Hovold <johan@...nel.org>
Subject: Re: [PATCH 2/2] tty: Implement lookahead to process XON/XOFF timely

On Tue, Apr 05, 2022 at 01:24:37PM +0300, Ilpo Järvinen wrote:
> When tty is not read from, XON/XOFF may get stuck into an
> intermediate buffer. As those characters are there to do software
> flow-control, it is not very useful. In the case where neither end
> reads from ttys, the receiving ends might not be able receive the
> XOFF characters and just keep sending more data to the opposite
> direction. This problem is almost guaranteed to occur with DMA
> which sends data in large chunks.
> 
> If TTY is slow to process characters, that is, eats less than given
> amount in receive_buf, invoke lookahead for the rest of the chars
> to process potential XON/XOFF characters.
> 
> The guards necessary for ensuring the XON/XOFF character are
> processed only once were added by the previous patch. All this patch
> needs to do on that front is to pass the lookahead count (that can
> now be non-zero) into port->client_ops->receive_buf().

...

> +static bool __n_tty_receive_char_special(struct tty_struct *tty, unsigned char c,
> +					 bool lookahead_done)
> +{
> +	if (!I_IXON(tty))
> +		return false;
> +
> +	if (c == START_CHAR(tty)) {
> +		if (!lookahead_done) {
> +			start_tty(tty);
> +			process_echoes(tty);
> +		}
> +		return true;
> +	}
> +	if (c == STOP_CHAR(tty)) {
> +		if (!lookahead_done)
> +			stop_tty(tty);
> +		return true;
> +	}
> +	return false;
> +}

Looking into this I would first make a preparatory patch that splits out
current code into something like

static bool __n_tty_receive_char_special_no_lookahead(struct tty_struct *tty, unsigned char c)
{
	...current code...
}

Then in the patch 1 you add

static bool __n_tty_receive_char_special_lookahead(struct tty_struct *tty, unsigned char c)
{
	...
}

static bool __n_tty_receive_char_special(struct tty_struct *tty, unsigned char c,
					 bool lookahead_done)
{
	if (!I_IXON(tty))
		return false;

	if (lookahead_done)
		return _lookahead();

	return _no_lookahead();
}

?

...

/*
 * Also start multi-line comments with
 * capital letter and finish with
 * grammar period.
 */

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ