Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1251402pxa; Thu, 20 Aug 2020 06:48:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRwIv5anPXhSUD4VE3npXtvfw5QwHgHW6g0Jxa84sUZWf+z80GVsM+RTJLqVpB1heHMUfU X-Received: by 2002:a17:906:cb8c:: with SMTP id mf12mr3295313ejb.3.1597931295075; Thu, 20 Aug 2020 06:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597931295; cv=none; d=google.com; s=arc-20160816; b=NfM1Wfg2pUOeNTIvV8BW2mnb22s+ah6VUeYidwPV781frJhSXl+8a1H/nV6h2spHib bVNv1Y+6ie+VPkWS5hvK379MrIAdHhV0WyoXu2kMBXO0ALMFlZUAzIYhfjtR0KD742wX oxnYJhzc6eGWbNHsugw2cyiAlOSR0C2U39QsImuf2N2/leT9n79vezXyBGkddGvt74Ny zJ0Cl1eJ5I5uwNmm73YP0qaT0TpJnd0g+ZFyfaWzwdzSaDnQSmmBWf5MV3SoH+Cu5phr 4M/Y8ZhT27krMpuyosp3PITMyTCHOCQ7cmKdfyTHWe4QWvPZk/593a3Ewtt+l0Jlt2Yg Hc7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ETtzMaB1Sz4J6IkIaVtczABi8g0BQQdgLZB//Hxl6xE=; b=nwB3FIGTyUIHv0nnDyFUxkS38o/3IY9CUEk1ruZZZVsbw2EnV6y9eVKJmJC1epruI8 82KMQhMN8om0aKwkeMX0dRGRyR7qjfYK8+Yf3i+RiOel1XuSKSDnGBy00rzVdue6fG2M 6u52kOJvhbFpYbZrKxrB+Ei/rVpldAaZxKDKlK9HoRSJAwD175dWUiiC3pIkU33fqajU Y6/rRjl4VSsqFo94sdt3v8tRiigu/RU/Z6ZlC+vdEC5o+rdXa3cXSFS7NySkej9n0tPb LFL02DUNdTAxF0FEUrP6u8bfYOt2eNayUzFmfbBcfmCKo6tc/aBlOM226YlRbsRcqx0K ITdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IeJreRrs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce23si1330015edb.306.2020.08.20.06.47.50; Thu, 20 Aug 2020 06:48:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IeJreRrs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729509AbgHTNpW (ORCPT + 99 others); Thu, 20 Aug 2020 09:45:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:34302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727070AbgHTJ2P (ORCPT ); Thu, 20 Aug 2020 05:28:15 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 617F322D2C; Thu, 20 Aug 2020 09:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915688; bh=Q3c3fttEFPNEraViiHJuygJ4IAfzf6gyNW01lwb61AE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IeJreRrsaMx7HAiMzU9ZeQy7xyQo0aTtiaPEZkYRrFtusEwy/A6y3nVEkh1cUQFmQ QXhdFsj6nwyXPwtd/korL6bTHxbH+fFXtagSKqABV+thTs23KHjXJOZGEySi/oeioI q/jaWzMK/UzzJ+pCAoOiTOM4jZt6jAIMNpleAQN4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arvind Sankar , Masami Hiramatsu , "Steven Rostedt (VMware)" Subject: [PATCH 5.8 101/232] bootconfig: Fix to find the initargs correctly Date: Thu, 20 Aug 2020 11:19:12 +0200 Message-Id: <20200820091617.724127174@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu commit 477d08478170469d10b533624342d13701e24b34 upstream. Since the parse_args() stops parsing at '--', bootconfig_params() will never get the '--' as param and initargs_found never be true. In the result, if we pass some init arguments via the bootconfig, those are always appended to the kernel command line with '--' even if the kernel command line already has '--'. To fix this correctly, check the return value of parse_args() and set initargs_found true if the return value is not an error but a valid address. Link: https://lkml.kernel.org/r/159650953285.270383.14822353843556363851.stgit@devnote2 Fixes: f61872bb58a1 ("bootconfig: Use parse_args() to find bootconfig and '--'") Cc: stable@vger.kernel.org Reported-by: Arvind Sankar Suggested-by: Arvind Sankar Signed-off-by: Masami Hiramatsu Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- init/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- a/init/main.c +++ b/init/main.c @@ -387,8 +387,6 @@ static int __init bootconfig_params(char { if (strcmp(param, "bootconfig") == 0) { bootconfig_found = true; - } else if (strcmp(param, "--") == 0) { - initargs_found = true; } return 0; } @@ -399,19 +397,23 @@ static void __init setup_boot_config(con const char *msg; int pos; u32 size, csum; - char *data, *copy; + char *data, *copy, *err; int ret; /* Cut out the bootconfig data even if we have no bootconfig option */ data = get_boot_config_from_initrd(&size, &csum); 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 (err) + initargs_found = true; + if (!data) { pr_err("'bootconfig' found on command line, but no bootconfig found\n"); return;