linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Use kzfree in tty buffer management to enforce data sanitization
@ 2009-05-31  1:55 Larry H.
  2009-05-31  2:04 ` Linus Torvalds
  0 siblings, 1 reply; 10+ messages in thread
From: Larry H. @ 2009-05-31  1:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-mm, Rik van Riel, Alan Cox, Linus Torvalds

[PATCH] Use kzfree in tty buffer management to enforce data sanitization

This patch replaces the kfree() calls within the tty buffer management API
with kzfree(), to enforce sanitization of the buffer contents.

It also takes care of handling buffers larger than PAGE_SIZE, which are
allocated via the page allocator directly.

This prevents such information from persisting on memory, potentially
leaking sensitive data like access credentials, or being leaked to other
kernel users after re-allocation of the memory by the LIFO allocators.

This patch doesn't affect fastpaths.

Signed-off-by: Larry Highsmith <research@subreption.com>

Index: linux-2.6/drivers/char/tty_audit.c
===================================================================
--- linux-2.6.orig/drivers/char/tty_audit.c
+++ linux-2.6/drivers/char/tty_audit.c
@@ -54,10 +54,12 @@ err:
 static void tty_audit_buf_free(struct tty_audit_buf *buf)
 {
 	WARN_ON(buf->valid != 0);
-	if (PAGE_SIZE != N_TTY_BUF_SIZE)
-		kfree(buf->data);
-	else
+	if (PAGE_SIZE != N_TTY_BUF_SIZE) {
+		kzfree(buf->data);
+	} else {
+		memset(buf->data, 0, PAGE_SIZE);
 		free_page((unsigned long)buf->data);
+	}
 	kfree(buf);
 }
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-06-03 16:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-31  1:55 [PATCH] Use kzfree in tty buffer management to enforce data sanitization Larry H.
2009-05-31  2:04 ` Linus Torvalds
2009-05-31  2:35   ` Larry H.
2009-05-31  6:27     ` Pekka Enberg
2009-05-31  6:24   ` Pekka Enberg
2009-05-31 10:26     ` Alan Cox
2009-05-31 17:05       ` Linus Torvalds
2009-05-31 17:10         ` Alan Cox
2009-05-31 17:17         ` Pekka Enberg
2009-06-02 15:05         ` Christoph Lameter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox