Alexandre SIMON
fed286bde4
printk: fix buffer overflow when calling log_prefix function from call_console_drivers
...
This patch corrects a buffer overflow in kernels from 3.0 to 3.4 when calling
log_prefix() function from call_console_drivers().
This bug existed in previous releases but has been revealed with commit
162a7e7500 (2.6.39 => 3.0) that made changes
about how to allocate memory for early printk buffer (use of memblock_alloc).
It disappears with commit 7ff9554bb5 (3.4 => 3.5)
that does a refactoring of printk buffer management.
In log_prefix(), the access to "p[0]", "p[1]", "p[2]" or
"simple_strtoul(&p[1], &endp, 10)" may cause a buffer overflow as this
function is called from call_console_drivers by passing "&LOG_BUF(cur_index)"
where the index must be masked to do not exceed the buffer's boundary.
The trick is to prepare in call_console_drivers() a buffer with the necessary
data (PRI field of syslog message) to be safely evaluated in log_prefix().
This patch can be applied to stable kernel branches 3.0.y, 3.2.y and 3.4.y.
Without this patch, one can freeze a server running this loop from shell :
$ export DUMMY=`cat /dev/urandom | tr -dc '12345AZERTYUIOPQSDFGHJKLMWXCVBNazertyuiopqsdfghjklmwxcvbn' | head -c255`
$ while true do ; echo $DUMMY > /dev/kmsg ; done
The "server freeze" depends on where memblock_alloc does allocate printk buffer :
if the buffer overflow is inside another kernel allocation the problem may not
be revealed, else the server may hangs up.
Signed-off-by: Alexandre SIMON <Alexandre.Simon@univ-lorraine.fr >
Signed-off-by: Ben Hutchings <ben@decadent.org.uk >
2013-02-06 04:33:57 +00:00
..
2011-11-04 18:02:25 -07:00
2011-10-31 19:32:32 -04:00
2011-10-17 19:22:46 -04:00
2011-11-11 09:50:19 -08:00
2011-11-03 09:40:51 -07:00
2012-08-19 18:15:34 +01:00
2012-08-19 18:15:33 +01:00
2011-11-01 10:51:38 -07:00
2012-09-19 15:04:40 +01:00
2012-10-30 23:26:28 +00:00
2012-10-30 23:26:26 +00:00
2011-11-01 09:19:52 +01:00
2011-11-09 15:07:40 +01:00
2011-10-31 17:30:55 -07:00
2011-11-06 19:44:47 -08:00
2011-10-31 17:30:54 -07:00
2011-10-31 19:32:32 -04:00
2012-11-16 16:46:48 +00:00
2012-06-19 23:18:25 +01:00
2011-10-31 19:32:32 -04:00
2012-07-12 04:32:18 +01:00
2011-10-26 15:43:26 -04:00
2011-10-26 15:43:25 -04:00
2011-10-31 17:30:54 -07:00
2011-10-31 00:33:36 +08:00
2013-01-03 03:33:45 +00:00
2011-11-16 09:21:50 +01:00
2012-02-20 12:46:20 -08:00
2011-10-24 16:11:30 +02:00
2012-08-02 14:37:54 +01:00
2011-10-31 17:30:54 -07:00
2011-10-17 19:22:46 -04:00
2011-10-20 18:21:36 -04:00
2013-01-03 03:32:56 +00:00
2011-09-27 09:25:02 +01:00
2011-10-13 14:36:58 +01:00
2011-10-03 09:34:16 +02:00
2011-12-19 11:41:40 +01:00
2011-09-28 13:41:50 -04:00
2011-10-31 17:30:49 -07:00
2012-03-12 12:31:21 -07:00
2013-01-16 01:13:23 +00:00
2011-09-23 12:05:29 +05:30
2012-08-02 14:37:51 +01:00
2011-11-07 10:13:52 -08:00
2012-08-02 14:37:36 +01:00
2012-01-25 16:13:22 -08:00
2011-11-06 19:44:47 -08:00
2011-10-21 14:24:07 +02:00
2012-10-10 03:30:48 +01:00
2011-11-07 23:54:53 +01:00
2011-10-31 19:32:26 -04:00
2011-10-31 20:19:04 +00:00
2011-11-21 20:36:26 -08:00
2011-10-31 20:19:04 +00:00
2011-10-31 20:18:58 +00:00
2011-10-31 20:21:24 +00:00
2011-12-16 08:49:57 -08:00
2011-11-06 17:12:03 -08:00
2011-11-06 19:44:47 -08:00
2011-10-31 17:30:44 -07:00
2011-10-04 13:08:18 -07:00
2011-10-31 17:30:54 -07:00
2011-10-31 15:10:04 -02:00
2013-02-06 04:33:50 +00:00
2011-10-19 14:33:08 +02:00
2011-10-30 15:16:43 +01:00
2011-11-04 18:37:23 -04:00
2012-02-29 16:31:24 -08:00
2011-10-31 09:20:11 -04:00
2011-10-10 18:25:59 +02:00
2011-11-02 10:06:20 -07:00
2012-04-02 09:52:45 -07:00
2011-10-19 19:35:51 -04:00
2011-10-31 19:32:32 -04:00
2013-01-03 03:32:56 +00:00
2012-08-02 14:37:32 +01:00
2011-10-31 17:30:54 -07:00
2011-10-05 01:10:12 +00:00
2011-12-05 13:28:45 -05:00
2011-10-31 19:32:32 -04:00
2011-11-06 19:44:47 -08:00
2012-05-31 00:43:15 +01:00
2011-10-24 16:04:06 +02:00
2012-10-10 03:31:16 +01:00
2012-10-10 03:31:16 +01:00
2013-01-03 03:32:57 +00:00
2012-07-25 04:11:36 +01:00
2011-10-31 17:30:48 -07:00
2012-08-10 00:25:10 +01:00
2011-11-08 09:28:27 +02:00
2011-10-11 09:51:22 -06:00
2011-10-29 09:37:09 +01:00
2011-11-23 11:33:07 +01:00
2011-09-30 15:57:07 -04:00
2011-10-11 15:35:42 -04:00
2012-11-16 16:46:52 +00:00
2011-10-21 02:53:07 -04:00
2011-10-03 14:03:48 -04:00
2012-10-30 23:26:34 +00:00
2011-11-14 01:08:49 -05:00
2012-08-10 00:11:14 +01:00
2011-10-28 14:25:01 -07:00
2011-10-26 16:17:32 +02:00
2011-10-17 11:42:49 +02:00
2011-10-28 05:54:23 -07:00
2011-10-21 14:38:55 +02:00
2011-10-31 19:32:32 -04:00
2011-10-31 19:32:32 -04:00
2011-10-04 12:43:49 +02:00
2011-10-31 19:32:35 -04:00
2011-10-31 19:32:35 -04:00
2011-10-31 14:03:23 +01:00
2011-09-27 18:08:04 +02:00
2011-10-27 04:38:18 -04:00
2011-10-27 04:38:18 -04:00
2011-10-27 04:38:18 -04:00
2011-10-25 11:55:15 -07:00
2011-10-31 17:30:54 -07:00
2012-07-25 04:11:19 +01:00
2011-10-31 17:30:54 -07:00
2012-06-10 14:42:10 +01:00
2012-04-13 08:33:50 -07:00
2011-10-31 17:46:07 -07:00
2012-04-13 08:33:48 -07:00
2011-10-31 17:30:54 -07:00
2012-09-19 15:05:16 +01:00
2011-10-31 17:30:54 -07:00
2012-09-19 15:04:59 +01:00
2012-05-31 00:43:10 +01:00
2011-12-26 13:27:44 +02:00
2011-12-22 02:02:20 -05:00
2011-10-31 17:30:54 -07:00
2011-10-31 17:30:52 -07:00
2011-10-31 17:30:57 -07:00
2011-09-28 21:36:37 -07:00
2011-12-12 22:06:55 -08:00
2011-11-04 17:22:14 -07:00
2011-11-02 16:06:59 -07:00
2012-04-02 09:52:34 -07:00
2011-10-31 19:32:32 -04:00
2011-10-31 17:30:47 -07:00
2012-01-25 16:13:23 -08:00
2012-10-10 03:30:45 +01:00
2013-01-03 03:32:54 +00:00
2012-08-02 14:37:32 +01:00
2011-10-31 19:32:29 -04:00
2011-11-02 16:06:57 -07:00
2011-12-09 07:50:27 -08:00
2011-10-31 17:30:54 -07:00
2012-08-02 14:37:31 +01:00
2011-10-31 09:20:11 -04:00
2011-10-31 09:20:11 -04:00
2012-09-19 15:04:26 +01:00
2011-11-02 12:53:42 +01:00
2011-10-19 17:00:35 -04:00
2012-09-19 15:04:55 +01:00
2012-06-10 14:42:03 +01:00
2011-11-01 09:24:41 -07:00
2011-10-19 11:52:12 -04:00
2012-09-19 15:05:06 +01:00
2011-10-19 13:58:38 -07:00
2012-02-29 16:30:55 -08:00
2011-10-14 14:48:23 -04:00
2011-10-31 14:03:22 +01:00
2011-10-31 19:32:27 -04:00
2011-11-06 19:44:47 -08:00
2011-10-31 17:30:45 -07:00
2011-11-04 22:28:13 +01:00
2013-01-16 01:13:13 +00:00
2011-10-31 19:32:32 -04:00
2013-01-16 01:13:13 +00:00
2012-01-25 16:13:17 -08:00
2012-02-06 09:41:06 -08:00
2011-10-31 10:23:57 -07:00
2012-07-25 04:11:13 +01:00
2012-09-19 15:05:06 +01:00
2011-10-24 02:54:50 -04:00
2012-05-11 13:14:43 +01:00
2011-11-22 16:37:01 -05:00
2011-10-29 07:28:36 -07:00
2011-09-26 20:22:02 +02:00
2012-02-13 11:16:55 -08:00
2011-11-17 21:39:33 +01:00
2011-11-28 22:14:55 +01:00
2011-11-02 16:07:02 -07:00
2011-10-31 17:30:54 -07:00
2012-02-20 12:46:16 -08:00
2011-11-17 12:58:07 -08:00
2011-09-29 00:32:03 -04:00
2012-12-06 11:20:18 +00:00
2011-10-31 17:30:54 -07:00
2012-08-10 00:24:46 +01:00
2011-09-28 21:38:35 -07:00
2011-09-28 21:38:20 -07:00
2011-09-28 21:36:42 -07:00
2011-10-31 19:32:32 -04:00
2012-03-12 12:31:24 -07:00
2011-10-03 15:19:19 -04:00
2011-11-02 16:07:01 -07:00
2012-04-02 09:53:10 -07:00
2012-11-16 16:46:52 +00:00
2012-08-10 00:11:14 +01:00
2012-01-03 16:12:19 -08:00
2011-11-02 16:07:01 -07:00
2011-10-31 17:30:54 -07:00
2012-05-11 13:14:50 +01:00
2013-02-06 04:33:36 +00:00
2011-09-22 15:50:38 -07:00
2011-11-11 16:16:25 +09:00
2011-11-15 12:13:44 -08:00
2011-10-31 19:32:32 -04:00
2011-11-11 16:11:41 +09:00
2011-09-28 13:41:51 -04:00
2011-11-11 16:45:35 +09:00
2012-01-25 16:13:59 -08:00
2011-12-09 07:50:27 -08:00
2011-11-29 11:59:50 +00:00
2012-02-29 16:31:23 -08:00
2012-07-25 04:11:40 +01:00
2011-09-27 23:03:30 +03:00
2013-01-16 01:13:25 +00:00
2012-05-11 13:14:17 +01:00
2012-07-12 04:31:59 +01:00
2011-10-31 19:32:28 -04:00
2011-10-31 17:30:47 -07:00
2011-10-16 23:28:51 +02:00
2012-01-25 16:13:59 -08:00
2012-06-19 23:18:28 +01:00
2011-10-31 17:30:44 -07:00
2011-11-02 16:07:02 -07:00
2011-10-31 19:32:24 -04:00
2011-10-19 19:24:14 -04:00
2013-02-06 04:33:57 +00:00
2011-10-03 14:01:21 -04:00
2011-10-31 19:32:32 -04:00
2012-09-19 15:05:00 +01:00
2012-07-25 04:11:32 +01:00
2011-10-31 17:30:54 -07:00
2011-10-26 15:11:09 +02:00
2011-09-28 21:36:38 -07:00
2011-10-12 21:13:11 -07:00
2011-10-31 19:32:32 -04:00
2012-09-12 03:36:54 +01:00
2011-11-02 16:07:02 -07:00
2011-10-31 19:32:31 -04:00
2011-10-31 19:32:23 -04:00
2012-01-25 16:13:29 -08:00
2011-11-24 13:04:48 +10:30
2011-11-24 13:04:47 +10:30
2011-11-02 11:40:59 +10:30
2011-11-02 11:40:59 +10:30
2011-10-31 19:32:32 -04:00
2011-11-16 12:13:08 -05:00
2012-03-19 09:02:34 -07:00
2011-10-31 00:33:36 +08:00
2012-10-10 03:31:25 +01:00