Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp979666pxa; Sat, 22 Aug 2020 06:49:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA08IoVmBvT9FXIeMY1LkvUECtEtyjLSvPDhqYnpSNdfqHEonmMyvhes6maH6WPsZdGT8c X-Received: by 2002:a17:906:388b:: with SMTP id q11mr7937213ejd.100.1598104154342; Sat, 22 Aug 2020 06:49:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598104154; cv=none; d=google.com; s=arc-20160816; b=L3DOI+bbBQB196YW89W2CyhZI+PKYOs7aONOtulJy/c+1d8+Olpu9cc6t3qHmJXNv9 5AqShLG27sW92jyOBRuepqKNTyoYCNtGcZZnbscgzKWfxm+VJTSxZdn0zsPDNWfvEiXo C6XmFy2FHU5LJ5Xewak8SqEjJhk+Lb2R2/FBbDfJ5NS27nBLnzBDRwXviKHrdYPOdfld Zj6kzBmUd9rrryRrh8iyTqiO0JHvoEckuQgnzG1E/WQKP50nD5dG/n+BvdXD1MQA4iOJ Fb7yNSxWO7rCoBtiouHgDClYdr29XmYGKf810PdBPdgyD69ASIEW90UETfVg1evGiQCY ruYw== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:dkim-signature :dkim-signature:date; bh=nxClsAni8MetG2l9vr8TLwbGulfmhd4lEpWk5Z1JUTQ=; b=dOiNZbXeq0K61JJmNFDAblP+DqKQrcN/7mqk6ZQQf6dfbiDPBsllbQhMneBEcr9bhE QSZDOjbzSa1PrTAYvpMq+3xaJQQ/N3UT8Dp5fC9AG0tGX5U1GJf2dyA4gJo3BdKEB10O yTeDXk378M6tOyFs2ARI1P9bsKyYdkhVDb6cZIKXw5SCI6l1MrmbgcJ/xBVu8muBwkOk tGM5FtuP6wu9K8TzXrU3e7Ex0fLGpGqQ8whjP04fjL6wqz6PpMfJxqqksz+mCgaA5JMu 4ss4dvXHMN2PuQ1X5++LJiWpieL96iA+33ItDeAU8mFVSIdBp8L2vmtwO9t6BlL6g62m OxCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=jtirZxsY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ZTEQV6Fy; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d3si3437259edo.152.2020.08.22.06.48.49; Sat, 22 Aug 2020 06:49:14 -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=fail header.i=@linutronix.de header.s=2020 header.b=jtirZxsY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ZTEQV6Fy; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728169AbgHVNjd (ORCPT + 99 others); Sat, 22 Aug 2020 09:39:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728086AbgHVNjC (ORCPT ); Sat, 22 Aug 2020 09:39:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2291C061574; Sat, 22 Aug 2020 06:39:01 -0700 (PDT) Date: Sat, 22 Aug 2020 13:38:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1598103539; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nxClsAni8MetG2l9vr8TLwbGulfmhd4lEpWk5Z1JUTQ=; b=jtirZxsYI1DdtlnxSehiV4xiRa9IVm3XCEoREQZK34bEmZqM13Ql1Qc8QXLc/4YOXn38j9 vcyfs7CWsEwQbul1NBy+fPIKx0BVaETemn7SQRRrWqAVNrEegazhjF0LjAHc8iwU+RLaMF L89Jq6kJsoYZFh4feOYYpwaSYTW9F5TiDuN71Be6PSE+6WJ373eycLXvWd218XUVcOuVcu YaX5xMxsDUOFikkQ1hBe3LtOa4Ob3XHmJKSY02OMa/Y1uUWKzfITpYY6+K21q6zfSohd41 48fPVgjmYczQsp73OA2xHVwyB/pB+nuuQgplXSWeWe94Mn7VvazyHCHTowQ2ww== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1598103539; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nxClsAni8MetG2l9vr8TLwbGulfmhd4lEpWk5Z1JUTQ=; b=ZTEQV6FyCpbCJS3euPNcdYUBZJbBW6LGiEh/JQOI9efZC3Z4ioMnj0J0L2zsw5mOkrwZc2 sxJBEuXOx3JcywCw== From: "tip-bot2 for Arvind Sankar" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: efi/urgent] efi/libstub: Handle unterminated cmdline Cc: , Arvind Sankar , Ard Biesheuvel , x86 , LKML In-Reply-To: <20200813185811.554051-4-nivedita@alum.mit.edu> References: <20200813185811.554051-4-nivedita@alum.mit.edu> MIME-Version: 1.0 Message-ID: <159810353887.3192.8959117951765134192.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the efi/urgent branch of tip: Commit-ID: 8a8a3237a78cbc0557f0eb16a89f16d616323e99 Gitweb: https://git.kernel.org/tip/8a8a3237a78cbc0557f0eb16a89f16d616323e99 Author: Arvind Sankar AuthorDate: Thu, 13 Aug 2020 14:58:11 -04:00 Committer: Ard Biesheuvel CommitterDate: Thu, 20 Aug 2020 11:18:58 +02:00 efi/libstub: Handle unterminated cmdline Make the command line parsing more robust, by handling the case it is not NUL-terminated. Use strnlen instead of strlen, and make sure that the temporary copy is NUL-terminated before parsing. Cc: Signed-off-by: Arvind Sankar Link: https://lore.kernel.org/r/20200813185811.554051-4-nivedita@alum.mit.edu Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/efi-stub-helper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index f53652a..f735db5 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -194,12 +194,14 @@ efi_status_t efi_parse_options(char const *cmdline) if (!cmdline) return EFI_SUCCESS; - len = strlen(cmdline) + 1; + len = strnlen(cmdline, COMMAND_LINE_SIZE - 1) + 1; status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, len, (void **)&buf); if (status != EFI_SUCCESS) return status; - str = skip_spaces(memcpy(buf, cmdline, len)); + memcpy(buf, cmdline, len - 1); + buf[len - 1] = '\0'; + str = skip_spaces(buf); while (*str) { char *param, *val;