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>] [day] [month] [year] [list]
Date:   Tue, 25 Jul 2017 16:57:26 +0800
From:   Jeremy Kerr <jk@...abs.org>
To:     linux-kernel@...r.kernel.org
Cc:     openbmc@...ts.ozlabs.org, Jeremy Kerr <jk@...abs.org>,
        Peter Hurley <peter@...leysoftware.com>
Subject: [PATCH RFC] tty: don't force !TTYB_NORMAL flip buffers if not required

In change acc0f67f30, we introduced flip buffers that skipped allocation
of the flags buffer for characters received with TTY_NORMAL flags.

However, the slow path of tty_insert_flip_char() calls
tty_insert_flip_string_flags() (providing a flag buffer pointer), which
forces the buffer code to allocate a !TTYB_NORMAL buffer. If we took the
slow path due to running out of buffer space, rather than seeing
!TTY_NORMAL flags, we've needlessly allocated a flags buffer.

This change uses tty_insert_flip_string_fixed_flag instead, which will
allocate TTYB_NORMAL buffers if flag == TTY_NORMAL. Since we're only
inserting one character, it's fine for the flag to be "fixed".

Signed-off-by: Jeremy Kerr <jk@...abs.org>
CC: Peter Hurley <peter@...leysoftware.com>

---
RFC: I'm certainly no expert on the tty layer, and perhaps there's a
good reason to always allocate a flags buffer. However, this seems to
relieve buffer pressure in my tests.

---
 include/linux/tty_flip.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
index c28dd52..15d03a1 100644
--- a/include/linux/tty_flip.h
+++ b/include/linux/tty_flip.h
@@ -26,7 +26,7 @@ static inline int tty_insert_flip_char(struct tty_port *port,
 		*char_buf_ptr(tb, tb->used++) = ch;
 		return 1;
 	}
-	return tty_insert_flip_string_flags(port, &ch, &flag, 1);
+	return tty_insert_flip_string_fixed_flag(port, &ch, flag, 1);
 }
 
 static inline int tty_insert_flip_string(struct tty_port *port,
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ