Skip to content

Commit f8df13e

Browse files
ppisargregkh
authored andcommitted
tty: 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. Signed-off-by: Petr Písař <ppisar@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent d942060 commit f8df13e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/tty/vt/vt.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,13 @@ static void csi_J(struct vc_data *vc, int vpar)
11931193
vc->vc_x + 1);
11941194
}
11951195
break;
1196+
case 3: /* erase scroll-back buffer (and whole display) */
1197+
scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char,
1198+
vc->vc_screenbuf_size >> 1);
1199+
set_origin(vc);
1200+
if (CON_IS_VISIBLE(vc))
1201+
update_screen(vc);
1202+
/* fall through */
11961203
case 2: /* erase whole display */
11971204
count = vc->vc_cols * vc->vc_rows;
11981205
start = (unsigned short *)vc->vc_origin;

0 commit comments

Comments
 (0)