Thread (40 messages) 40 messages, 5 authors, 2020-08-04

Re: [PATCH v6 08/22] bootconfig: init: Allow admin to use bootconfig for init command line

From: Arvind Sankar <hidden>
Date: 2020-08-03 15:30:06
Also in: linux-fsdevel, lkml

On Tue, Aug 04, 2020 at 12:03:45AM +0900, Masami Hiramatsu wrote:
On Sat, 1 Aug 2020 22:33:18 -0400
Arvind Sankar [off-list ref] wrote:
quoted
I came across this as I was poking around some of the command line
parsing. AFAICT, initargs_found will never be set to true here, because
parse_args handles "--" itself by immediately returning: it doesn't
invoke the callback for it. So you'd instead have to check the return of
parse_args("bootconfig"...) to detect the initargs_found case.
Oops, good catch!
Does this fixes the problem?
Note I found the issue by code inspection, I don't have an actual test
case. But the change looks good to me, with one comment below.
 	strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-	parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL,
-		   bootconfig_params);
+	err = parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL,
+			 bootconfig_params);
 
-	if (!bootconfig_found)
+	if (IS_ERR(err) || !bootconfig_found)
 		return;
 
+	/* parse_args() stops at '--' and returns an address */
+	if (!IS_ERR(err) && err)
+		initargs_found = true;
+
I think you can drop the second IS_ERR, since we already checked that.
 	if (!data) {
 		pr_err("'bootconfig' found on command line, but no bootconfig found\n");
 		return;
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help