stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] printk: Fix discarding of records
@ 2014-02-14  4:42 Debabrata Banerjee
  2014-02-16 19:28 ` Linus Torvalds
  0 siblings, 1 reply; 17+ messages in thread
From: Debabrata Banerjee @ 2014-02-14  4:42 UTC (permalink / raw)
  To: linux-kernel, Jeff Mahoney, Linus Torvalds
  Cc: dbavatar, johunt, Debabrata Banerjee, stable

Found another buffer overflow in this code that was introduced by
e3756477aec028427fec767957c0d4b6cfb87208 trying to solve a related overflow.

strace still shows a problem:

	syslog(0x3, 0x7fffd65375d0, 0x1000)     = 4107

The first record output was in the middle of a LOG_CONT line:

	<4>[    2.974999] 0x0000000000000500-0x000000000000052f SystemIO conflicts with Region \GPIO 1 (20130328/utaddress-251)

This happens because when discarding records to be less than len, every line it
subtracts should be the first line which means prev should be 0. Otherwise for
example it won't include the prefix len if the last line was a LOG_CONT
record, which however will be printed because there won't be a previous line.
This patch makes sure enough records are discarded to be under len.

CC: stable@vger.kernel.org
Signed-off-by: Debabrata Banerjee <dbanerje@akamai.com>
---
 kernel/printk/printk.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index b1d255f..c1722d5 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1067,7 +1067,6 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
 			struct printk_log *msg = log_from_idx(idx);
 
 			len -= msg_print_text(msg, prev, true, NULL, 0);
-			prev = msg->flags;
 			idx = log_next(idx);
 			seq++;
 		}
@@ -2780,7 +2779,6 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
 		l -= msg_print_text(msg, prev, true, NULL, 0);
 		idx = log_next(idx);
 		seq++;
-		prev = msg->flags;
 	}
 
 	/* last message in next interation */
-- 
1.8.3.4


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

end of thread, other threads:[~2014-03-21 15:33 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-14  4:42 [PATCH] printk: Fix discarding of records Debabrata Banerjee
2014-02-16 19:28 ` Linus Torvalds
2014-02-16 20:47   ` Greg Kroah-Hartman
2014-02-16 23:05     ` Kay Sievers
2014-02-16 23:23   ` Banerjee, Debabrata
2014-02-16 23:59     ` Linus Torvalds
2014-02-17  0:19       ` Banerjee, Debabrata
2014-02-17  0:41         ` Linus Torvalds
2014-02-17  0:50           ` Kay Sievers
2014-02-17  0:57             ` Linus Torvalds
2014-02-17  1:19               ` Kay Sievers
2014-02-17  1:41                 ` Kay Sievers
2014-02-17  2:38           ` Banerjee, Debabrata
2014-03-21 15:18             ` Josh Hunt
2014-03-21 15:33               ` Greg Kroah-Hartman
2014-02-16 23:24   ` [PATCH v2] " Debabrata Banerjee
2014-02-17  0:42   ` [PATCH v3] " Debabrata Banerjee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).