From patchwork Wed Nov 5 15:04:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 40191 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 27B142404A for ; Wed, 5 Nov 2014 15:04:59 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id c41sf995349eek.0 for ; Wed, 05 Nov 2014 07:04:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=OBgLNltSrioplp/j+wbr9QT0snw3A9oinvbF1QqOe0Y=; b=hRN7B8GdP1cvg3lit7sbVPElYyTAzZ2t0BRMwUAOGSq+U8m6O/kjCezv82GnwigIov PrnATipxL1tn5WLJN1vNyeWlJwuHUuBzxSrdZxcHng/p3wRGe3MNi982bhtdTeXfWCwO Csn1P9IQ4Q0KczPSTMFSV2dFV76VPsbWMgJJXVoWn4HfpGa/v6gk+ZdgM56UA1/Q4B4B Aa04t4Od+/5fEGeMmiBDsZrA3fBScIYlomjXMCXrCLLeuPhSrM7JSf3LW863ctvo0MzU czDw91F70ET5DbdfiHg8T76xfsSunt4yr7dO2UuK1UGIgtrQ183GZMxNEXFSgQA+7vZ/ yarA== X-Gm-Message-State: ALoCoQn2ATC12mRPoQS02KCKwoiMrkvQuS65pOmWaujzS1nUtuQJR2l3IjEuUa6jCufYt9IlwLAs X-Received: by 10.112.166.102 with SMTP id zf6mr497912lbb.12.1415199898335; Wed, 05 Nov 2014 07:04:58 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.67 with SMTP id z3ls1043169lag.74.gmail; Wed, 05 Nov 2014 07:04:58 -0800 (PST) X-Received: by 10.112.171.6 with SMTP id aq6mr20830573lbc.28.1415199898130; Wed, 05 Nov 2014 07:04:58 -0800 (PST) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id x8si6496215laj.107.2014.11.05.07.04.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Nov 2014 07:04:58 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by mail-lb0-f170.google.com with SMTP id z12so800432lbi.29 for ; Wed, 05 Nov 2014 07:04:57 -0800 (PST) X-Received: by 10.152.29.8 with SMTP id f8mr68461329lah.56.1415199897801; Wed, 05 Nov 2014 07:04:57 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp294729lbc; Wed, 5 Nov 2014 07:04:57 -0800 (PST) X-Received: by 10.180.79.196 with SMTP id l4mr33672798wix.72.1415199897130; Wed, 05 Nov 2014 07:04:57 -0800 (PST) Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com. [209.85.212.176]) by mx.google.com with ESMTPS id ei1si5695202wib.71.2014.11.05.07.04.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Nov 2014 07:04:57 -0800 (PST) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.212.176 as permitted sender) client-ip=209.85.212.176; Received: by mail-wi0-f176.google.com with SMTP id h11so12671675wiw.9 for ; Wed, 05 Nov 2014 07:04:56 -0800 (PST) X-Received: by 10.180.14.231 with SMTP id s7mr33382823wic.0.1415199896740; Wed, 05 Nov 2014 07:04:56 -0800 (PST) Received: from sundance.lan (cpc4-aztw19-0-0-cust157.18-1.cable.virginm.net. [82.33.25.158]) by mx.google.com with ESMTPSA id cu9sm4417403wjb.0.2014.11.05.07.04.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Nov 2014 07:04:56 -0800 (PST) From: Daniel Thompson To: Rusty Russell Cc: Daniel Thompson , Andrew Morton , linux-kernel@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org, John Stultz , Sumit Semwal , stable@vger.kernel.org Subject: [PATCH v3.18-rc3] param: fix crash on bad kernel arguments Date: Wed, 5 Nov 2014 15:04:50 +0000 Message-Id: <1415199890-32413-1-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.3 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.thompson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently if the user passes an invalid value on the kernel command line then the kernel will crash during argument parsing. On most systems this is very hard to debug because the console hasn't been initialized yet. This is a regression due to commit 51e158c12aca ("param: hand arguments after -- straight to init") which, in response to the systemd debug controversy, made it possible to explicitly pass arguments to init. To achieve this parse_args() was extended from simply returning an error code to returning a pointer. Regretably the new init args logic does not perform a proper validity check on the pointer resulting in a crash. This patch fixes the validity check. Should the check fail then no arguments will be passed to init. This is reasonable and matches how the kernel treats its own arguments (i.e. no error recovery). Signed-off-by: Daniel Thompson Cc: stable@vger.kernel.org --- init/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.9.3 diff --git a/init/main.c b/init/main.c index 800a0da..321d0ce 100644 --- a/init/main.c +++ b/init/main.c @@ -544,7 +544,7 @@ asmlinkage __visible void __init start_kernel(void) static_command_line, __start___param, __stop___param - __start___param, -1, -1, &unknown_bootoption); - if (after_dashes) + if (!IS_ERR_OR_NULL(after_dashes)) parse_args("Setting init args", after_dashes, NULL, 0, -1, -1, set_init_arg);