uml: boot broken due to buffer overrun
authorBalbir Singh <[email protected]>
Tue, 9 Dec 2008 21:14:07 +0000 (13:14 -0800)
committerLinus Torvalds <[email protected]>
Wed, 10 Dec 2008 16:01:52 +0000 (08:01 -0800)
mconsole_init() passed 256 bytes as length in os_create_unix_socket, while
the sizeof UNIX_PATH_MAX is 108. This patch fixes that problem and avoids
a big overrun bug reported on UML bootup.

sockaddr_un.sun_path is UNIX_PATH_MAX long which causes the problem.
Reported-by: Vikas K Managutte <[email protected]>
Reported-by: Sarvesh Kumar Lal Das <[email protected]>
Signed-off-by: Balbir Singh <[email protected]>
Reviewed-by: Pekka Enberg <[email protected]>
Reviewed-by: WANG Cong <[email protected]>
Cc: Jeff Dike <[email protected]>
Cc: <[email protected]> [please check with Jeff]
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
arch/um/drivers/mconsole_kern.c

index 19d579d74d27f18ae67bb1b5c9adcf93f963a288..8f44ebb0dec82286e85838369d8fdfd9de929ae6 100644 (file)
@@ -16,6 +16,8 @@
 #include <linux/slab.h>
 #include <linux/syscalls.h>
 #include <linux/utsname.h>
+#include <linux/socket.h>
+#include <linux/un.h>
 #include <linux/workqueue.h>
 #include <linux/mutex.h>
 #include <asm/uaccess.h>
@@ -785,7 +787,7 @@ static int __init mconsole_init(void)
        /* long to avoid size mismatch warnings from gcc */
        long sock;
        int err;
-       char file[256];
+       char file[UNIX_PATH_MAX];
 
        if (umid_file_name("mconsole", file, sizeof(file)))
                return -1;