All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Dike <jdike@addtoit.com>
To: Roman Yepishev <roman.yepishev@gmail.com>
Cc: user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] UML crashes when built with _FORTIFY_SOURCE
Date: Fri, 31 Oct 2008 15:14:52 -0400	[thread overview]
Message-ID: <20081031191452.GA10950@c2.user-mode-linux.org> (raw)
In-Reply-To: <f39be10d0810241608i590d13f5p429c02558a1c26cf@mail.gmail.com>

On Sat, Oct 25, 2008 at 02:08:31AM +0300, Roman Yepishev wrote:
> Temporary solution is to fix file declaration to be 108 or less bytes
> but checks should be introduced when socket path is constructed.

I don't really understand what you mean by checks being introduced,
but how do you like the patch below?

			Jeff

-- 
Work email - jdike at linux dot intel dot com

diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 19d579d..cc88ef7 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -785,11 +785,12 @@ static int __init mconsole_init(void)
 	/* long to avoid size mismatch warnings from gcc */
 	long sock;
 	int err;
-	char file[256];
+	char file[UM_UNIX_PATH_MAX];
 
 	if (umid_file_name("mconsole", file, sizeof(file)))
 		return -1;
-	snprintf(mconsole_socket_name, sizeof(file), "%s", file);
+	snprintf(mconsole_socket_name, sizeof(file) - 1, "%s", file);
+	file[sizeof(file) - 1] = '\0';
 
 	sock = os_create_unix_socket(file, sizeof(file), 1);
 	if (sock < 0) {
diff --git a/arch/um/drivers/mconsole_user.c b/arch/um/drivers/mconsole_user.c
index f8cf4c8..f00735e 100644
--- a/arch/um/drivers/mconsole_user.c
+++ b/arch/um/drivers/mconsole_user.c
@@ -9,7 +9,7 @@
 #include <unistd.h>
 #include <sys/socket.h>
 #include <sys/uio.h>
-#include <sys/un.h>
+#include <linux/un.h>
 #include "kern_constants.h"
 #include "mconsole.h"
 #include "user.h"
@@ -37,7 +37,7 @@ static struct mconsole_command commands[] = {
 };
 
 /* Initialized in mconsole_init, which is an initcall */
-char mconsole_socket_name[256];
+char mconsole_socket_name[UNIX_PATH_MAX];
 
 static int mconsole_reply_v0(struct mc_request *req, char *reply)
 {
diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c
index 5f883bf..5e4ae72 100644
--- a/arch/um/sys-i386/user-offsets.c
+++ b/arch/um/sys-i386/user-offsets.c
@@ -2,8 +2,10 @@
 #include <stddef.h>
 #include <signal.h>
 #include <sys/poll.h>
+#include <sys/socket.h>
 #include <sys/user.h>
 #include <sys/mman.h>
+#include <linux/un.h>
 #include <asm/ptrace.h>
 
 #define DEFINE(sym, val) \
@@ -50,4 +52,6 @@ void foo(void)
 	DEFINE(UM_PROT_READ, PROT_READ);
 	DEFINE(UM_PROT_WRITE, PROT_WRITE);
 	DEFINE(UM_PROT_EXEC, PROT_EXEC);
+
+	DEFINE(UM_UNIX_PATH_MAX, UNIX_PATH_MAX);
 }
diff --git a/arch/um/sys-x86_64/user-offsets.c b/arch/um/sys-x86_64/user-offsets.c
index 9735854..e47b3bd 100644
--- a/arch/um/sys-x86_64/user-offsets.c
+++ b/arch/um/sys-x86_64/user-offsets.c
@@ -4,6 +4,7 @@
 #include <sys/poll.h>
 #include <sys/mman.h>
 #include <sys/user.h>
+#include <linux/un.h>
 #define __FRAME_OFFSETS
 #include <asm/ptrace.h>
 #include <asm/types.h>
@@ -62,4 +63,6 @@ void foo(void)
 	DEFINE(UM_PROT_READ, PROT_READ);
 	DEFINE(UM_PROT_WRITE, PROT_WRITE);
 	DEFINE(UM_PROT_EXEC, PROT_EXEC);
+
+	DEFINE(UM_UNIX_PATH_MAX, UNIX_PATH_MAX);
 }

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

  reply	other threads:[~2008-11-03  4:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-24 23:08 [uml-devel] UML crashes when built with _FORTIFY_SOURCE Roman Yepishev
2008-10-31 19:14 ` Jeff Dike [this message]
2008-11-03 21:35   ` Roman Yepishev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081031191452.GA10950@c2.user-mode-linux.org \
    --to=jdike@addtoit.com \
    --cc=roman.yepishev@gmail.com \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.