Skip to contentSkip to conversation

Clean console safely

PATCH In review Petr Písař 2 participants 4 messages Mar 24, 2011 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Clean console safely

Traditional \E[2J sequence erases console display but scroll-back buffer and underlying device (frame) buffer keep data that can be accessed by scrolling console back.

This patch introduce new \E[J parameter 3 that allows to scramble scroll-back buffer explicitly. Session locking programs (screen, vlock) can use it to prevent attacker to browse locked console history.

---
 drivers/tty/vt/vt.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/tty/vt/vt.c +6 -0
index 147ede3..c31bf2a 100644
@@ -1198,6 +1198,12 @@ static void csi_J(struct vc_data *vc, int vpar)
 					      vc->vc_x + 1);
 			}
 			break;
+        case 3: /* erase scroll-back buffer (and whole display) */
+            scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char,
+                    vc->vc_screenbuf_size >> 1);
+            set_origin(vc);
+            if (CON_IS_VISIBLE(vc))
+                update_screen(vc);
 		case 2: /* erase whole display */
 			count = vc->vc_cols * vc->vc_rows;
 			start = (unsigned short *)vc->vc_origin;
Signature · 1 line
1.7.4
#1 lore raw
Quoted 11 lines · On Thu, 24 Mar 2011 10:56:51 +0100 Petr Písař <[email protected]> wrote:

Traditional \E[2J sequence erases console display but scroll-back buffer and underlying device (frame) buffer keep data that can be accessed by scrolling console back.

This patch introduce new \E[J parameter 3 that allows to scramble scroll-back buffer explicitly. Session locking programs (screen, vlock) can use it to prevent attacker to browse locked console history.

---
 drivers/tty/vt/vt.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

Looks sensible enough

There are a set of official codes that are probably more relevant, and also deal with the timing of events

See DECSR/DECSRC on a later VT terminal, also DECSTR which

DECSR = secure reset, return to power up state, \E[n+p where n is an optional value from 1-16383 which if provided is replied back from the tty as a DECSRC response (hence 'secure'). It's defined to clear off screen memory, and also other weirdness a user may have set up so could reasonably also be extended a bit if there is other stuff founbd in future that such a reset really ought to clean up - eg for mingetty.

http://www.vt100.net/docs/vt520-rm/ek-vt520-rm.pdf (page 299)

ED 3J looks fine but is a new "made up" extension.

author
#2 lore raw
Quoted 29 lines · Alan Cox
Quoted 11 lines · On Thu, 24 Mar 2011 10:56:51 +0100 Petr Písař <[email protected]> wrote:

Traditional \E[2J sequence erases console display but scroll-back buffer and underlying device (frame) buffer keep data that can be accessed by scrolling console back.

This patch introduce new \E[J parameter 3 that allows to scramble scroll-back buffer explicitly. Session locking programs (screen, vlock) can use it to prevent attacker to browse locked console history.

---
 drivers/tty/vt/vt.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

Looks sensible enough

There are a set of official codes that are probably more relevant, and also deal with the timing of events

See DECSR/DECSRC on a later VT terminal, also DECSTR which

DECSR = secure reset, return to power up state, \E[n+p where n is an optional value from 1-16383 which if provided is replied back from the tty as a DECSRC response (hence 'secure'). It's defined to clear off screen memory, and also other weirdness a user may have set up so could reasonably also be extended a bit if there is other stuff founbd in future that such a reset really ought to clean up - eg for mingetty.

Quoted 4 lines

http://www.vt100.net/docs/vt520-rm/ek-vt520-rm.pdf (page 299)

ED 3J looks fine but is a new "made up" extension.

The problem with DECSRC as well as DECSTR or RIS is they reset terminal font, keyboard layout, unicode mode and other configuration. That's the reason why I rejected enhancing RIS implemented in Linux VT already. In other words, I'm searching for a clear display feature which preserves configuration. I read console_codes(4), console_ioctl(4), and now the VT520 documentation and I did not find any existing control code. The most close seems ED J for me.

-- Petr

#3 lore raw
Quoted 3 lines

I'm searching for a clear display feature which preserves configuration. I read console_codes(4), console_ioctl(4), and now the VT520 documentation and I did not find any existing control code. The most close seems ED J for me.

Seems reasonable to me on that basis.

Quoted 2 lines

-- Petr

Signature · 3 lines
--
	"Alan, I'm getting a bit worried about you."
				-- Linus Torvalds