aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/printk
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.cz>2014-04-03 17:48:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-03 19:21:07 -0400
commit39b25109b400ea397e64c417d8b965a53e2ee0f0 (patch)
tree228213814478431701cd6bb53460c6da890b6797 /kernel/printk
parente8c42d36ab86cf45f88c3a0e344233b1032fbf3d (diff)
printk: use also the last bytes in the ring buffer
It seems that we have newer used the last byte in the ring buffer. In fact, we have newer used the last 4 bytes because of padding. First problem is in the check for free space. The exact number of free bytes is enough to store the length of data. Second problem is in the check where the ring buffer is rotated. The left side counts the first unused index. It is unused, so it might be the same as the size of the buffer. Note that the first problem has to be fixed together with the second one. Otherwise, the buffer is rotated even when there is enough space on the end of the buffer. Then the beginning of the buffer is rewritten and valid entries get corrupted. Signed-off-by: Petr Mladek <pmladek@suse.cz> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jan Kara <jack@suse.cz> Cc: Michal Hocko <mhocko@suse.cz> Cc: Kay Sievers <kay@vrfy.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/printk')
-rw-r--r--kernel/printk/printk.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 012f3e40671d..b3a1790f9e05 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -319,7 +319,7 @@ static void log_store(int facility, int level,
319 else 319 else
320 free = log_first_idx - log_next_idx; 320 free = log_first_idx - log_next_idx;
321 321
322 if (free > size + sizeof(struct printk_log)) 322 if (free >= size + sizeof(struct printk_log))
323 break; 323 break;
324 324
325 /* drop old messages until we have enough contiuous space */ 325 /* drop old messages until we have enough contiuous space */
@@ -327,7 +327,7 @@ static void log_store(int facility, int level,
327 log_first_seq++; 327 log_first_seq++;
328 } 328 }
329 329
330 if (log_next_idx + size + sizeof(struct printk_log) >= log_buf_len) { 330 if (log_next_idx + size + sizeof(struct printk_log) > log_buf_len) {
331 /* 331 /*
332 * This message + an additional empty header does not fit 332 * This message + an additional empty header does not fit
333 * at the end of the buffer. Add an empty header with len == 0 333 * at the end of the buffer. Add an empty header with len == 0