From patchwork Fri Mar 24 13:24:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 95934 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp43755qgd; Fri, 24 Mar 2017 06:24:44 -0700 (PDT) X-Received: by 10.98.91.130 with SMTP id p124mr9441307pfb.165.1490361884220; Fri, 24 Mar 2017 06:24:44 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w15si2862053plk.292.2017.03.24.06.24.44; Fri, 24 Mar 2017 06:24:44 -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 S934839AbdCXNYd (ORCPT + 2 others); Fri, 24 Mar 2017 09:24:33 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:35707 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935546AbdCXNY2 (ORCPT ); Fri, 24 Mar 2017 09:24:28 -0400 Received: by mail-wm0-f47.google.com with SMTP id u132so12996379wmg.0 for ; Fri, 24 Mar 2017 06:24:22 -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=YX0YdgpM2s2V63l4UNRz7PpnJc0/k7yca3tZUytQInDmTsWyzrevrfy4mwh/x3BL8B UIhVk6wwxdKcPP8Iz90cWjHwPgfJ/IYZteQZd5yQGkwWlN1xH6BvX6jEtQ5a2BmKYGoZ LEbQVOzg6q+QeyblvWmWvI8GEmMcgb0b6yd9s= 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=SgZQfNjeCWz0nUn1jm3lA69bPjOSZ+DeYrsZqNkug3p1yxQFDRvstRjJr79cmzYBvL kIsIelUEdt6+YWOFu+bnu0jdfJ/8+W2T9GUbg6tsClsod0xSPkGeJyHtOzbB6Esn6bjo nw8Bap2WvvLQOmtb4VtNNCslnJGEEEYtlbz7t3MhOfPhnB8KsmuaervhD8n88rvm9bwJ RufPWZsrNAWIH76xDvt7ONYQbzl676W+H2xCnf6Bc4PdYigKSCIYPP0AL7kp6P9UPZ0w jX+DdbI+6p6zWgKZSOIryIH1goLqDDBa97/sk7jjML0lDzjq7ofe7Y7kKRSs4Tlug4gp HyHQ== X-Gm-Message-State: AFeK/H0QVwYrDWzXZSoYOjhHl/Fr/iQf85I9vhb2VNvAIQM03lEJ4q7aNGfQ6EYmObo+jCkh X-Received: by 10.28.173.193 with SMTP id w184mr3188956wme.106.1490361861392; Fri, 24 Mar 2017 06:24:21 -0700 (PDT) Received: from localhost.localdomain ([196.67.95.24]) by smtp.gmail.com with ESMTPSA id 92sm2924626wrh.8.2017.03.24.06.24.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Mar 2017 06:24:20 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, matt@codeblueprint.co.uk, leif.lindholm@linaro.org, rfranz@cavium.com, mingo@kernel.org, bp@alien8.de, mark.rutland@arm.com, kernel-hardening@lists.openwall.com, Ard Biesheuvel Subject: [PATCH 1/4] efi/libstub: fix harmless command line parsing bug Date: Fri, 24 Mar 2017 13:24:07 +0000 Message-Id: <20170324132410.16628-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170324132410.16628-1-ard.biesheuvel@linaro.org> References: <20170324132410.16628-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 == ',')