[PATCH] Use kzfree in tty buffer management to enforce datasanitization

From: Larry H.
Date: Sat May 30 2009 - 21:58:23 EST

[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@xxxxxxxxxxxxxx>

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);
- kfree(buf->data);
- else
+ kzfree(buf->data);
+ } else {
+ memset(buf->data, 0, PAGE_SIZE);
free_page((unsigned long)buf->data);
+ }

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/