From: Seung-Woo Kim Date: Wed, 2 Dec 2020 04:35:32 +0000 (+0900) Subject: Revert "fs/proc: make cmdline writable" X-Git-Tag: accepted/tizen/unified/20201211.124320~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=755516e8c0f4865be933e64f0f2890c1bcb226b2;p=platform%2Fkernel%2Flinux-amlogic.git Revert "fs/proc: make cmdline writable" This reverts commit 341b13d1ba7f5d10830a7236b257bed780602917 and commit 7970fede1d941cbda83ac6f875b1f99b9af5a8f9 and commit 129e951a369446eb40d23264caf20bddcd1929e3. Writing /proc/cmdline is not required and the feature causes too much stack frame usage. To remove the FRAME_WARN issue for frame-larger-than, revert writing /proc/cmdline feature commits. Signed-off-by: Seung-Woo Kim --- diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 708e27f..4471e0b 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1140,12 +1140,20 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, p = of_get_flat_dt_prop(node, "bootargs", &l); if (p != NULL && l > 0) { - strlcpy(cmdline, p, min((int)l, COMMAND_LINE_SIZE)); + if (concat_cmdline) { + int cmdline_len; + int copy_len; + strlcat(cmdline, " ", COMMAND_LINE_SIZE); + cmdline_len = strlen(cmdline); + copy_len = COMMAND_LINE_SIZE - cmdline_len - 1; + copy_len = min((int)l, copy_len); + strncpy(cmdline + cmdline_len, p, copy_len); + cmdline[cmdline_len + copy_len] = '\0'; + } else { + strlcpy(cmdline, p, min((int)l, COMMAND_LINE_SIZE)); + } } - if (concat_cmdline) - strlcat(cmdline, config_cmdline, COMMAND_LINE_SIZE); - pr_debug("Command line is: %s\n", (char*)data); /* break now */ diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c index c59ed26..cbd82df 100644 --- a/fs/proc/cmdline.c +++ b/fs/proc/cmdline.c @@ -3,14 +3,9 @@ #include #include -#include /* for COMMAND_LINE_SIZE */ -#include /* copy_from_user */ - -char proc_cmdline[COMMAND_LINE_SIZE]; - static int cmdline_proc_show(struct seq_file *m, void *v) { - seq_printf(m, "%s\n", proc_cmdline); + seq_printf(m, "%s\n", saved_command_line); return 0; } @@ -19,31 +14,15 @@ static int cmdline_proc_open(struct inode *inode, struct file *file) return single_open(file, cmdline_proc_show, NULL); } -static ssize_t cmdline_proc_write(struct file *file, const char __user *buf, - size_t len, loff_t *ppos) -{ - char str[COMMAND_LINE_SIZE]; - if (copy_from_user(str, buf, len)) { - printk( KERN_INFO "[cmdline] copy_from_user failed.\n"); - return -EFAULT; - } - str[len] = '\0'; - strlcpy(proc_cmdline, str, min((int)len, COMMAND_LINE_SIZE)); - - return len; -} - static const struct file_operations cmdline_proc_fops = { .open = cmdline_proc_open, .read = seq_read, - .write = cmdline_proc_write, .llseek = seq_lseek, .release = single_release, }; static int __init proc_cmdline_init(void) { - strcpy(proc_cmdline, saved_command_line); proc_create("cmdline", 0, NULL, &cmdline_proc_fops); return 0; }