Skip to contentSkip to conversation

Clean console safely

PATCH In review Petr Písař 7 participants 15 messages Apr 13, 2011 – Jul 21, 2016 TTY layer and serial drivers

lore
Share & tools
lore
#1 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 4bea1ef..fe96a1f 100644
@@ -1197,6 +1197,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.4
#2 lore raw
Quoted 11 lines · Petr Písař

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(-)

You forgot to "Signed-off-by:" it.

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
#3 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 4bea1ef..fe96a1f 100644
@@ -1197,6 +1197,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.4
#4 lore raw
Quoted 8 lines · Petr Písař

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.

Is this also documented somewhere so that people know about it?

thanks,

greg k-h

author
#5 lore raw
Quoted 5 lines · Greg KH
Quoted 4 lines · Petr Písař

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.

Quoted 8 lines
Quoted 4 lines

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.

Is this also documented somewhere so that people know about it?

Not yet as this is fresh feature. I'd like to put few words into console_codes(4). I guess manual sources are not part of Linux.

-- Petr

#6 lore raw
Quoted 11 lines · Petr Pisar
Quoted 10 lines · Greg KH
Quoted 8 lines · Petr Písař

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.

Quoted 5 lines
Quoted 3 lines

Is this also documented somewhere so that people know about it?

Not yet as this is fresh feature. I'd like to put few words into console_codes(4). I guess manual sources are not part of Linux.

No they are not, they have their own maintainer and release schedule.

thanks,

greg k-h

#7 lore raw
In reply to Petr Písař

Hi,

Quoted 21 lines · Petr Písař

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 +0 -0
index 4bea1ef..fe96a1f 100644
@@ -1197,6 +1197,12 @@ static void csi_J(struct vc_data *vc, int vpar)
 					      vc->vc_x + 1);
 			}

drivers/tty/vt/vt.c static void csi_J(struct vc_data *vc, int vpar) · line 1208

Quoted 10 lines
drivers/tty/vt/vt.c +6 -0
 			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;

Nitpick: the cases were ordered before -- 3 should go after 2.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
author
#8 lore raw
Quoted 27 lines · Chris Ball
Quoted 25 lines · Petr Písař

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 +3 -0
index 4bea1ef..fe96a1f 100644
@@ -1197,6 +1197,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);
Quoted 9 lines

drivers/tty/vt/vt.c static void csi_J(struct vc_data *vc, int vpar) · line 1208

Quoted 6 lines
drivers/tty/vt/vt.c +3 -0
+			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;

Nitpick: the cases were ordered before -- 3 should go after 2.

This is on purpose to continue with code for case 2 as it prepares variables for cleaning visible part of display after the switch block.

-- Petr

#9 lore raw

Hi,

Quoted 37 lines · Petr Pisar
Quoted 27 lines · Chris Ball
Quoted 25 lines · Petr Písař

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 +3 -0
index 4bea1ef..fe96a1f 100644
@@ -1197,6 +1197,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);
Quoted 9 lines

drivers/tty/vt/vt.c static void csi_J(struct vc_data *vc, int vpar) · line 1208

Quoted 6 lines
drivers/tty/vt/vt.c +3 -0
+			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;

Nitpick: the cases were ordered before -- 3 should go after 2.

Quoted 2 lines

This is on purpose to continue with code for case 2 as it prepares variables for cleaning visible part of display after the switch block.

Oops, sorry; I saw an imaginary break statement there.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#10 lore raw
Quoted 53 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Chris Ball
Sent: Wednesday, April 13, 2011 8:45 AM
To: Greg Kroah-Hartman
Cc: Alan Cox; [email protected]; Artem Bityutskiy
Subject: Re: [PATCH] Clean console safely

Hi,

Quoted 17 lines · Petr Pisar
Quoted 16 lines · Chris Ball
Quoted 14 lines · Petr Písař

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(-)
Quoted 5 lines
Quoted 5 lines

drivers/tty/vt/vt.c static void csi_J(struct vc_data

Quoted 5 lines
drivers/tty/vt/vt.c +0 -0
index 4bea1ef..fe96a1f 100644
@@ -1197,6 +1197,12 @@ static void csi_J(struct vc_data 

*vc, int vpar)

Quoted 4 lines
Quoted 4 lines

drivers/tty/vt/vt.c static void csi_J(struct vc_data *vc, int vpar)

Quoted 4 lines
drivers/tty/vt/vt.c +1 -0
 					      vc->vc_x + 1);
 			}
 			break;
+		case 3: /* erase scroll-back buffer 

(and whole display) */

Quoted 1 line
Quoted 1 line

drivers/tty/vt/vt.c static void csi_J(struct vc_data · line 1201

Quoted 1 line
drivers/tty/vt/vt.c +1 -0
+			scr_memsetw(vc->vc_screenbuf, 

vc->vc_video_erase_char,

Quoted 10 lines
Quoted 10 lines

drivers/tty/vt/vt.c static void csi_J(struct vc_data *vc, int vpar) · line 1208

Quoted 7 lines
drivers/tty/vt/vt.c +4 -0
+				    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;

Nitpick: the cases were ordered before -- 3 should go after 2.

Quoted 5 lines
Quoted 1 line

This is on purpose to continue with code for case 2 as it

prepares variables

Quoted 1 line

for cleaning visible part of display after the switch block.

Oops, sorry; I saw an imaginary break statement there.

Shouldn't there be a "/* fall through */", or similar, comment, or all of the existing ones in the kernel extraneous? Personally, I prefer to see clearly that the missing "break" is intentional.

Quoted 12 lines

- Chris.

Signature · 8 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
--
To unsubscribe from this list: send the line "unsubscribe 
linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#11 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 |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/tty/vt/vt.c +7 -0
index 4bea1ef..cb661ca 100644
@@ -1197,6 +1197,13 @@ 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);
+			/* fall through */
 		case 2: /* erase whole display */
 			count = vc->vc_cols * vc->vc_rows;
 			start = (unsigned short *)vc->vc_origin;
Signature · 1 line
1.7.4.4
#12 lore raw
Quoted 19 lines · Petr Písař

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 |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/tty/vt/vt.c +0 -0
index 4bea1ef..cb661ca 100644

drivers/tty/vt/vt.c static void csi_J(struct vc_data *vc, int vpar) · line 1202

Quoted 6 lines
drivers/tty/vt/vt.c +3 -0
@@ -1197,6 +1197,13 @@ 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);

Why is here the division? I suppose this is superfluous, given scr_memsetw proper divides the size, hm?

Quoted 8 lines
drivers/tty/vt/vt.c +4 -0
+			set_origin(vc);
+			if (CON_IS_VISIBLE(vc))
+				update_screen(vc);
+			/* fall through */
 		case 2: /* erase whole display */
 			count = vc->vc_cols * vc->vc_rows;
 			start = (unsigned short *)vc->vc_origin;
Signature · 1 line
js
#13 lore raw
In reply to Chris Ball

Hi,

Quoted 34 lines · On Wednesday 13 April 2011, 17:18:04 Chris Ball wrote:
Quoted 33 lines · Petr Písař

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 4bea1ef..fe96a1f 100644
@@ -1197,6 +1197,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);
Quoted 6 lines

drivers/tty/vt/vt.c static void csi_J(struct vc_data *vc, int vpar) · line 1208

Quoted 4 lines
drivers/tty/vt/vt.c +0 -0
 		case 2: /* erase whole display */
 
 			count = vc->vc_cols * vc->vc_rows;
 			start = (unsigned short *)vc->vc_origin;

Nitpick: the cases were ordered before -- 3 should go after 2.

Not if the fall-through is intended.

Alexander