lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 11 Nov 2013 21:05:59 +0100
From:	Jiri Slaby <jslaby@...e.cz>
To:	gregkh@...uxfoundation.org
Cc:	jirislaby@...il.com, linux-kernel@...r.kernel.org,
	Jiri Slaby <jslaby@...e.cz>
Subject: [PATCH 1/1] TTY: tty_buffer, warn on leaks

When we leak something, warn about that. For that we need to account
the memory used also in the free_all method. It is handled elsewhere
correctly.

Signed-off-by: Jiri Slaby <jslaby@...e.cz>
---
 drivers/tty/tty_buffer.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 5f08c39e76ab..20cb9492dbf8 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -115,21 +115,27 @@ void tty_buffer_free_all(struct tty_port *port)
 	struct tty_bufhead *buf = &port->buf;
 	struct tty_buffer *p, *next;
 	struct llist_node *llist;
+	int zero = 0;
 
 	while ((p = buf->head) != NULL) {
 		buf->head = p->next;
+		atomic_sub(p->size, &buf->memory_used);
 		if (p->size > 0)
 			kfree(p);
 	}
 	llist = llist_del_all(&buf->free);
-	llist_for_each_entry_safe(p, next, llist, free)
+	llist_for_each_entry_safe(p, next, llist, free) {
+		atomic_sub(p->size, &buf->memory_used);
 		kfree(p);
+	}
+
 
 	tty_buffer_reset(&buf->sentinel, 0);
 	buf->head = &buf->sentinel;
 	buf->tail = &buf->sentinel;
 
-	atomic_set(&buf->memory_used, 0);
+	atomic_xchg(&buf->memory_used, zero);
+	WARN_ON(zero != 0);
 }
 
 /**
-- 
1.8.4.2

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ