From patchwork Mon Mar 27 17:17:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 96087 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1325040qgd; Mon, 27 Mar 2017 10:17:55 -0700 (PDT) X-Received: by 10.98.218.73 with SMTP id w9mr5533645pfl.100.1490635075579; Mon, 27 Mar 2017 10:17:55 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si1271299plj.119.2017.03.27.10.17.55; Mon, 27 Mar 2017 10:17:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751810AbdC0RR1 (ORCPT + 2 others); Mon, 27 Mar 2017 13:17:27 -0400 Received: from mail-wr0-f179.google.com ([209.85.128.179]:36238 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751651AbdC0RRV (ORCPT ); Mon, 27 Mar 2017 13:17:21 -0400 Received: by mail-wr0-f179.google.com with SMTP id w11so51505776wrc.3 for ; Mon, 27 Mar 2017 10:17:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ff4hQUtQmqYHUaLpVoZ9JEJ65lK1TiqAHW+FNJv26tA=; b=kztDcbM83k8rxjstOV9NC4gVwpr+o7jFM4h2K1SGTf7OKe4Jqo29KssgJAnL5ZtUD1 zgcUHnP4eZk67cesgTNsqAZcpsfz1R+awSqanQexmidiyKUA8SwjeVbNSESgFQgAa0b2 OEAq+BqIe7ms7Sk85MzdAZqL8avkxQRXHhtFU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ff4hQUtQmqYHUaLpVoZ9JEJ65lK1TiqAHW+FNJv26tA=; b=g8SFql8zmGAMb9R7xIPujt/Ps2tEIdXvFQh6yC/Z40oqsYiDueQbtZkvHch0wZ9NUm 8dWyf6Oj1/+GcTy8zKI8AgAaqJCltTjsGmSJg29h8MKZSzedyPMafLlXOi8jJ0fhx+vn Y/8mtactDUQ2Cqb3g9etYeTHYe4vj7IUHqvz5jQv+WmX5HwftFmFWOVN6JEo7f/wRsnb rJZkiNCUOFgzhpY2fIoetALehqUciKHffw9gn3xbuGO6YjNb15bdksr5SHN83CCvyitn ZwEsd7yivWN3CaiLs4bdhRJK9nrcVUUmOZ1aXUxgMKFOrMnkriTYldtLGEIOZp14WzmX Kj4w== X-Gm-Message-State: AFeK/H3xmsVyLpwATtOBph8saEqAac/8X6T1vib1hiEh3GeSZ29H5As5MsRNBcJahDwmrpe5 X-Received: by 10.28.100.196 with SMTP id y187mr10707356wmb.129.1490635034650; Mon, 27 Mar 2017 10:17:14 -0700 (PDT) Received: from localhost.localdomain ([196.81.160.3]) by smtp.gmail.com with ESMTPSA id o31sm1488961wrc.27.2017.03.27.10.17.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 10:17:14 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, matt@codeblueprint.co.uk Cc: Ard Biesheuvel Subject: [PATCH v2 1/4] efi/libstub: fix harmless command line parsing bug Date: Mon, 27 Mar 2017 18:17:00 +0100 Message-Id: <20170327171703.15489-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170327171703.15489-1-ard.biesheuvel@linaro.org> References: <20170327171703.15489-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org When we parse the 'efi=' command line parameter in the stub, we fail to take spaces into account. Currently, the only way this could result in unexpected behavior is when the string 'nochunk' appears as a separate command line argument after 'efi=xxx,yyy,zzz ', so this is harmless in practice. But let's fix it nonetheless. Cc: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/efi-stub-helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index 919822b7773d..3290fae0b38f 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -436,14 +436,14 @@ efi_status_t efi_parse_options(char *cmdline) * Remember, because efi= is also used by the kernel we need to * skip over arguments we don't understand. */ - while (*str) { + while (*str && *str != ' ') { if (!strncmp(str, "nochunk", 7)) { str += strlen("nochunk"); __chunk_size = -1UL; } /* Group words together, delimited by "," */ - while (*str && *str != ',') + while (*str && *str != ' ' && *str != ',') str++; if (*str == ',')