[Devel] [PATCH] [openvz] printk: Handle global log buffer reallocation

maximilian attems max at stro.at
Tue Oct 19 01:11:21 PDT 2010


From: Ben Hutchings <ben at decadent.org.uk>
Subject: [PATCH] [openvz] printk: Handle global log buffer reallocation
Date: Sun, 17 Oct 2010 02:24:28 +0100

Currently an increase in log_buf_len results in disaster, as
ve0.log_buf is left pointing to the old log buffer.

Update ve0.log_buf when the global log buffer is reallocated.  Also
acquire logbuf_lock before reading ve_log_buf_len, to avoid a race
with reallocation.

Reported-and-tested-by: Tim Small <tim at seoss.co.uk>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
Signed-off-by: maximilian attems <max at stro.at>

---

belows patch fixes http://bugs.debian.org/600299

--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -198,6 +198,9 @@
 		spin_lock_irqsave(&logbuf_lock, flags);
 		log_buf_len = size;
 		log_buf = new_log_buf;
+#ifdef CONFIG_VE
+		ve0.log_buf = log_buf;
+#endif
 
 		offset = start = min(con_start, log_start);
 		dest_idx = 0;
@@ -354,9 +357,9 @@
 		if (ve_log_buf == NULL)
 			goto out;
 		count = len;
+		spin_lock_irq(&logbuf_lock);
 		if (count > ve_log_buf_len)
 			count = ve_log_buf_len;
-		spin_lock_irq(&logbuf_lock);
 		if (count > ve_logged_chars)
 			count = ve_logged_chars;
 		if (do_clear)




More information about the Devel mailing list