ChangeSet 1.2231.1.106, 2005/03/28 19:45:58-08:00, [EMAIL PROTECTED]
[PATCH] uml: extend cmd line limits
From: "Catalin(ux aka Dino) BOIE" <[EMAIL PROTECTED]>, Paolo
'Blaisorblade'
Giarrusso <[EMAIL PROTECTED]>, Jeff Dike <[EMAIL PROTECTED]> Increase
UML
command line size. And fix a crash from passing an overly-long command
line
to UML.
XXX: check that init can handle 128 params and 128 env. var. The
original
patch set this limit to 256, but it seems me too much. Think!
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
arch/um/include/user_util.h | 2 +-
arch/um/kernel/um_arch.c | 34 ++++++++++++++++++++--------------
arch/um/kernel/user_util.c | 15 ---------------
include/asm-um/setup.h | 5 ++++-
init/Kconfig | 8 ++++++++
init/main.c | 4 ++--
6 files changed, 35 insertions(+), 33 deletions(-)
diff -Nru a/arch/um/include/user_util.h b/arch/um/include/user_util.h
--- a/arch/um/include/user_util.h 2005-03-28 21:29:47 -08:00
+++ b/arch/um/include/user_util.h 2005-03-28 21:29:47 -08:00
@@ -67,7 +67,7 @@
extern int switcheroo(int fd, int prot, void *from, void *to, int size);
extern void setup_machinename(char *machine_out);
extern void setup_hostinfo(void);
-extern void add_arg(char *cmd_line, char *arg);
+extern void add_arg(char *arg);
extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int));
extern void init_new_thread_signals(int altstack);
extern void do_exec(int old_pid, int new_pid);
diff -Nru a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
--- a/arch/um/kernel/um_arch.c 2005-03-28 21:29:47 -08:00
+++ b/arch/um/kernel/um_arch.c 2005-03-28 21:29:47 -08:00
@@ -25,6 +25,7 @@
#include "asm/user.h"
#include "ubd_user.h"
#include "asm/current.h"
+#include "asm/setup.h"
#include "user_util.h"
#include "kern_util.h"
#include "kern.h"
@@ -40,6 +41,20 @@
#define DEFAULT_COMMAND_LINE "root=98:0"
+/* Changed in linux_main and setup_arch, which run before SMP is started */
+char command_line[COMMAND_LINE_SIZE] = { 0 };
+
+void add_arg(char *arg)
+{
+ if (strlen(command_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) {
+ printf("add_arg: Too much command line!\n");
+ exit(1);
+ }
+ if(strlen(command_line) > 0)
+ strcat(command_line, " ");
+ strcat(command_line, arg);
+}
+
struct cpuinfo_um boot_cpu_data = {
.loops_per_jiffy = 0,
.ipi_pipe = { -1, -1 }
@@ -314,9 +329,11 @@
if((i == 1) && (argv[i][0] == ' ')) continue;
add = 1;
uml_checksetup(argv[i], &add);
- if(add) add_arg(saved_command_line, argv[i]);
+ if (add)
+ add_arg(argv[i]);
}
- if(have_root == 0) add_arg(saved_command_line, DEFAULT_COMMAND_LINE);
+ if(have_root == 0)
+ add_arg(DEFAULT_COMMAND_LINE);
mode_tt = force_tt ? 1 : !can_do_skas();
#ifndef CONFIG_MODE_TT
@@ -432,7 +449,7 @@
{
notifier_chain_register(&panic_notifier_list, &panic_exit_notifier);
paging_init();
- strcpy(command_line, saved_command_line);
+ strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
*cmdline_p = command_line;
setup_hostinfo();
}
@@ -448,14 +465,3 @@
void apply_alternatives(void *start, void *end)
{
}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -Nru a/arch/um/kernel/user_util.c b/arch/um/kernel/user_util.c
--- a/arch/um/kernel/user_util.c 2005-03-28 21:29:47 -08:00
+++ b/arch/um/kernel/user_util.c 2005-03-28 21:29:47 -08:00
@@ -31,21 +31,6 @@
#include "ptrace_user.h"
#include "uml-config.h"
-#define COMMAND_LINE_SIZE _POSIX_ARG_MAX
-
-/* Changed in linux_main and setup_arch, which run before SMP is started */
-char command_line[COMMAND_LINE_SIZE] = { 0 };
-
-void add_arg(char *cmd_line, char *arg)
-{
- if (strlen(cmd_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) {
- printf("add_arg: Too much command line!\n");
- exit(1);
- }
- if(strlen(cmd_line) > 0) strcat(cmd_line, " ");
- strcat(cmd_line, arg);
-}
-
void stop(void)
{
while(1) sleep(1000000);
diff -Nru a/include/asm-um/setup.h b/include/asm-um/setup.h
--- a/include/asm-um/setup.h 2005-03-28 21:29:47 -08:00
+++ b/include/asm-um/setup.h 2005-03-28 21:29:47 -08:00
@@ -1,6 +1,9 @@
#ifndef SETUP_H_INCLUDED
#define SETUP_H_INCLUDED
-#define COMMAND_LINE_SIZE 512
+/* POSIX mandated with _POSIX_ARG_MAX that we can rely on 4096 chars in the
+ * command line, so this choice is ok.*/
+
+#define COMMAND_LINE_SIZE 4096
#endif /* SETUP_H_INCLUDED */
diff -Nru a/init/Kconfig b/init/Kconfig
--- a/init/Kconfig 2005-03-28 21:29:47 -08:00
+++ b/init/Kconfig 2005-03-28 21:29:47 -08:00
@@ -55,6 +55,14 @@
depends on SMP || PREEMPT
default y
+config INIT_ENV_ARG_LIMIT
+ int
+ default 32 if !USERMODE
+ default 128 if USERMODE
+ help
+ This is the value of the two limits on the number of argument and of
+ env.var passed to init from the kernel command line.
+
endmenu
menu "General setup"
diff -Nru a/init/main.c b/init/main.c
--- a/init/main.c 2005-03-28 21:29:47 -08:00
+++ b/init/main.c 2005-03-28 21:29:47 -08:00
@@ -110,8 +110,8 @@
/*
* Boot command-line arguments
*/
-#define MAX_INIT_ARGS 32
-#define MAX_INIT_ENVS 32
+#define MAX_INIT_ARGS CONFIG_INIT_ENV_ARG_LIMIT
+#define MAX_INIT_ENVS CONFIG_INIT_ENV_ARG_LIMIT
extern void time_init(void);
/* Default late time init is NULL. archs can override this later. */
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html