Skip to contentSkip to conversation

tracing: Fixes for 5.6

PATCH New Steven Rostedt 1 participant 5 messages Feb 10, 2020

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: Fixes for 5.6

Gustavo A. R. Silva (1):
tracing/kprobe: Fix uninitialized variable bug

Masami Hiramatsu (2):
tools/bootconfig: Fix wrong __VA_ARGS__ usage
bootconfig: Remove unneeded CONFIG_LIBXBC

Steven Rostedt (VMware) (1):
bootconfig: Use parse_args() to find bootconfig and '--'

----

 init/Kconfig                            |  1 -
 init/main.c                             | 37 ++++++++++++++++++++++++++-------
 kernel/trace/trace_kprobe.c             |  2 +-
 lib/Kconfig                             |  3 ---
 lib/Makefile                            |  2 +-
 tools/bootconfig/include/linux/printk.h |  2 +-
 6 files changed, 33 insertions(+), 14 deletions(-)
author maintainer
#1 lore raw

PATCH 1/4 tools/bootconfig: Fix wrong __VA_ARGS__ usage

From: Masami Hiramatsu <[email protected]>

Since printk() wrapper macro uses __VA_ARGS__ without "##" prefix, it causes a build error if there is no variable arguments (e.g. only fmt is specified.) To fix this error, use ##__VA_ARGS__ instead of __VAR_ARGS__.

Fixes 950313ebf79c ("tools: bootconfig: Add bootconfig command")
---
 tools/bootconfig/include/linux/printk.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bootconfig/include/linux/printk.h +1 -1
index 017bcd6912a5..e978a63d3222 100644
@@ -7,7 +7,7 @@
 /* controllable printf */
 extern int pr_output;
 #define printk(fmt, ...)	\
-	(pr_output ? printf(fmt, __VA_ARGS__) : 0)
+	(pr_output ? printf(fmt, ##__VA_ARGS__) : 0)
 
 #define pr_err printk
 #define pr_warn	printk
Signature · 1 line
2.24.1
author maintainer
#2 lore raw

PATCH 2/4 bootconfig: Remove unneeded CONFIG_LIBXBC

In reply to Steven Rostedt

From: Masami Hiramatsu <[email protected]>

Since there is no user except CONFIG_BOOT_CONFIG and no plan to use it from other functions, CONFIG_LIBXBC can be removed and we can use CONFIG_BOOT_CONFIG directly.

---
 init/Kconfig | 1 -
 lib/Kconfig  | 3 ---
 lib/Makefile | 2 +-
 3 files changed, 1 insertion(+), 5 deletions(-)
init/Kconfig +0 -1
index 9506299a53e3..4a672c6629d0 100644
@@ -1218,7 +1218,6 @@ endif
 config BOOT_CONFIG
 	bool "Boot config support"
 	depends on BLK_DEV_INITRD
-	select LIBXBC
 	default y
 	help
 	  Extra boot config allows system admin to pass a config file as
lib/Kconfig +0 -3
index 10012b646009..6e790dc55c5b 100644
@@ -566,9 +566,6 @@ config DIMLIB
 config LIBFDT
 	bool
 
-config LIBXBC
-	bool
-
 config OID_REGISTRY
 	tristate
 	help
lib/Makefile +1 -1
index 75a64d2552a2..74c1223828c1 100644
@@ -228,7 +228,7 @@ $(foreach file, $(libfdt_files), \
 	$(eval CFLAGS_$(file) = -I $(srctree)/scripts/dtc/libfdt))
 lib-$(CONFIG_LIBFDT) += $(libfdt_files)
 
-lib-$(CONFIG_LIBXBC) += bootconfig.o
+lib-$(CONFIG_BOOT_CONFIG) += bootconfig.o
 
 obj-$(CONFIG_RBTREE_TEST) += rbtree_test.o
 obj-$(CONFIG_INTERVAL_TREE_TEST) += interval_tree_test.o
Signature · 1 line
2.24.1
author maintainer
#3 lore raw

PATCH 3/4 tracing/kprobe: Fix uninitialized variable bug

In reply to Steven Rostedt

From: "Gustavo A. R. Silva" <[email protected]>

There is a potential execution path in which variable *ret* is returned without being properly initialized, previously.

Fix this by initializing variable *ret* to 0.

Addresses-Coverity-ID: 1491142 ("Uninitialized scalar variable")

Fixes 2a588dd1d5d6 ("tracing: Add kprobe event command generation functions")
---
 kernel/trace/trace_kprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_kprobe.c +1 -1
index 51efc790aea8..21bafd48f2ac 100644
@@ -1012,7 +1012,7 @@ int __kprobe_event_add_fields(struct dynevent_cmd *cmd, ...)
 {
 	struct dynevent_arg arg;
 	va_list args;
-	int ret;
+	int ret = 0;
 
 	if (cmd->type != DYNEVENT_TYPE_KPROBE)
 		return -EINVAL;
Signature · 1 line
2.24.1
author maintainer
#4 lore raw

PATCH 4/4 bootconfig: Use parse_args() to find bootconfig and --

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

The current implementation does a naive search of "bootconfig" on the kernel command line. But this could find "bootconfig" that is part of another option in quotes (although highly unlikely). But it also needs to find '--' on the kernel command line to know if it should append a '--' or not when a bootconfig in the initrd file has an "init" section. The check uses the naive strstr() to find to see if it exists. But this can return a false positive if it exists in an option and then the "init" section in the initrd will not be appended properly.

Using parse_args() to find both of these will solve both of these problems.

Fixes 7495e0926fdf3 ("bootconfig: Only load bootconfig if "bootconfig" is on the kernel cmdline")
Fixes 1319916209ce8 ("bootconfig: init: Allow admin to use bootconfig for init command line")
---
 init/main.c | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)
init/main.c +30 -7
index 491f1cdb3105..59248717c925 100644
@@ -142,6 +142,15 @@ static char *extra_command_line;
 /* Extra init arguments */
 static char *extra_init_args;
 
+#ifdef CONFIG_BOOT_CONFIG
+/* Is bootconfig on command line? */
+static bool bootconfig_found;
+static bool initargs_found;
+#else
+# define bootconfig_found false
+# define initargs_found false
+#endif
+
 static char *execute_command;
 static char *ramdisk_execute_command;
 
@@ -336,17 +345,30 @@ u32 boot_config_checksum(unsigned char *p, u32 size)
 	return ret;
 }
 
+static int __init bootconfig_params(char *param, char *val,
+				    const char *unused, void *arg)
+{
+	if (strcmp(param, "bootconfig") == 0) {
+		bootconfig_found = true;
+	} else if (strcmp(param, "--") == 0) {
+		initargs_found = true;
+	}
+	return 0;
+}
+
 static void __init setup_boot_config(const char *cmdline)
 {
+	static char tmp_cmdline[COMMAND_LINE_SIZE] __initdata;
 	u32 size, csum;
 	char *data, *copy;
-	const char *p;
 	u32 *hdr;
 	int ret;
 
-	p = strstr(cmdline, "bootconfig");
-	if (!p || (p != cmdline && !isspace(*(p-1))) ||
-	    (p[10] && !isspace(p[10])))
+	strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
+	parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL,
+		   bootconfig_params);
+
+	if (!bootconfig_found)
 		return;
 
 	if (!initrd_end)
@@ -563,11 +585,12 @@ static void __init setup_command_line(char *command_line)
 		 * to init.
 		 */
 		len = strlen(saved_command_line);
-		if (!strstr(boot_command_line, " -- ")) {
+		if (initargs_found) {
+			saved_command_line[len++] = ' ';
+		} else {
 			strcpy(saved_command_line + len, " -- ");
 			len += 4;
-		} else
-			saved_command_line[len++] = ' ';
+		}
 
 		strcpy(saved_command_line + len, extra_init_args);
 	}
Signature · 1 line
2.24.1