Bug 684261

Summary: RFE: command to clear scrollback buffer in linux terminal
Product: [Fedora] Fedora Reporter: Miroslav Lichvar <mlichvar>
Component: kernelAssignee: Kernel Maintainer List <kernel-maint>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: gansalmon, itamar, jirislaby, jonathan, kernel-maint, madhu.chinakonda, ppisar, psabata
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
URL: http://thread.gmane.org/gmane.linux.kernel/1117336
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 714684 (view as bug list) Environment:
Last Closed: 2011-07-19 14:46:28 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 683733, 691406    
Attachments:
Description Flags
Proposed fix none

Description Miroslav Lichvar 2011-03-11 15:58:50 UTC
Description of problem:
In some situations it would be good to clear the terminal's scrollback buffer, for example on new login or when the terminal is locked so someone else won't be able to see the previous content with shift-pgup. (bug #683733)

There are hacks can be used to force clearing the buffer, like switching to another console and back, or changing the size of the terminal, but all seem to have some drawbacks.

This is a request to add a new command like \E[3J which would reset the scrollback buffer and which could be added to the linux terminfo entry, either to the clear sequence or as a new string capability.

Comment 1 Petr Pisar 2011-03-23 15:47:52 UTC
Created attachment 487076 [details]
Proposed fix

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.

Tested on VGA and FB_VGA16 console in qemu.

Comment 2 Dave Jones 2011-03-24 03:38:16 UTC
post it to linux-kernel.org

We'll pick it up when we rebase if it gets merged.

Comment 4 Miroslav Lichvar 2011-07-19 14:46:28 UTC
This seems to work with current kernels.

Comment 5 Jiri Slaby 2016-07-21 12:37:43 UTC
(In reply to Petr Pisar from comment #1)
> Created attachment 487076 [details]
> Proposed fix

Why do you divide the size by 2? This results in erasure of only half of the buffer... (Note scr_memsetw proper divides the size by 2.)

Comment 6 Petr Pisar 2016-07-21 12:53:49 UTC
I'm sorry, I don't recall after 5 years. Maybe this was not true at that time. Or there were some differences between text mode and frame buffer backed virtual console. I don't know.

Comment 7 Jiri Slaby 2016-07-21 13:08:52 UTC
scr_memsetw always accepted size, not count. So I assume it is a bug and I will fix it.