Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3492769imu; Sun, 11 Nov 2018 16:20:07 -0800 (PST) X-Google-Smtp-Source: AJdET5eL55aSgBc3TJMDH5qCArLOcaIRbLLxb3dClFkSXmd4urCL7NB6KY8fnbO5u8DwG+r9vVrm X-Received: by 2002:a62:c42:: with SMTP id u63-v6mr18122485pfi.43.1541982007742; Sun, 11 Nov 2018 16:20:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541982007; cv=none; d=google.com; s=arc-20160816; b=gmjPWW8Q1VZRUqy8yQMHlXGfprkppLiCGsMXnA/FpBAFuwRhDg0GKq7cXCskMlG82P iCloeHJAneIifV/Af+9BJWlIluCOUYPWB70qpbc3xt/PGOHtKiFTnUbuAJ+aVWE1bjxR fHHR8sCC8kC7vN4gfIhC0KQtw8b9ThGJa7yMbjhRlzfmGMrUck7wmdRXHwA+zMSpc2Gp 6onMCUDdqygzE2nsU/DNa1Xg8k2tRbpN6xv0gvwBLCWdPdlMKMbB/J3NtWdLK8oel0jm hujGn2EQA0GV+2EP2NeUlaAPTUvKPdVaD2dvS/NQPldhEfRYDFJtKHj+jDUt1nO1BPsq dhIw== 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=aZ/CMpqRRc07H5avYdEe0SrMC1WxyTLlb8Jp8DRIeTc=; b=lcp1o+BbBdKjbqWyt96X5y19BMBxYi+jpGxR0CpyXJhNBdmM38Fi1uq+tnDOWTfGtd e+ggsCIfP2dx+JYgGeDBLRrYee9D/oxZgUYzxelaGe7vD2z+uz/Sg6vW2zep0469fwQr aYsncqA+Z9E1AD7CfhCQ7rR2egy8aFSafp/uXwGAwoO0MVZmbeenMGVOIuSr8EaB0C/3 o5h6Spm9wDKnqXxmLSNCgh+w/t347OKMzVxoFamG+WpI2Ldddjxpi3q4IYxkahofeUo1 G/TquPQGmdRzHpPVe6HnK2uYFnsjsCY4RGrKbI7ik6Z0NvlbDzoqN9Ylc1PAZoNKJqPJ iciw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XTgrJw6p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e2si13956243pgs.94.2018.11.11.16.19.52; Sun, 11 Nov 2018 16:20:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XTgrJw6p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730114AbeKLKKB (ORCPT + 99 others); Mon, 12 Nov 2018 05:10:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:58670 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726816AbeKLIQz (ORCPT ); Mon, 12 Nov 2018 03:16:55 -0500 Received: from localhost (unknown [206.108.79.134]) (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 DA63A214F1; Sun, 11 Nov 2018 22:26:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975219; bh=4RvXGiniDsyIXDx3U2bRoPLeQEzcTUuXUnIg+NybqrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XTgrJw6pvof3iKBQuMuy2/pgjtd8gPNvKI+yXX6L4u7zBx3lmXH3O+KOp9NOxMIWT JOFz6l2/hJY6ufREegdT5bCpPynYxgf7LR+td3TW27IXfGqyrMp6Xx/wpN5vjL1Awr Q+4rXSxQqCKahUFnjhwf8KSoNhHBwVPDn8BB0gbg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, He Zhe , Marek Szyprowski , Christoph Hellwig Subject: [PATCH 4.19 022/361] dma-mapping: fix panic caused by passing empty cma command line argument Date: Sun, 11 Nov 2018 14:16:09 -0800 Message-Id: <20181111221622.775105965@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: He Zhe commit a3ceed87b07769fb80ce9dc6b604e515dba14c4b upstream. early_cma does not check input argument before passing it to simple_strtoull. The argument would be a NULL pointer if "cma", without its value, is set in command line and thus causes the following panic. PANIC: early exception 0xe3 IP 10:ffffffffa3e9db8d error 0 cr2 0x0 [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.0-rc3-yocto-standard+ #7 [ 0.000000] RIP: 0010:_parse_integer_fixup_radix+0xd/0x70 ... [ 0.000000] Call Trace: [ 0.000000] simple_strtoull+0x29/0x70 [ 0.000000] memparse+0x26/0x90 [ 0.000000] early_cma+0x17/0x6a [ 0.000000] do_early_param+0x57/0x8e [ 0.000000] parse_args+0x208/0x320 [ 0.000000] ? rdinit_setup+0x30/0x30 [ 0.000000] parse_early_options+0x29/0x2d [ 0.000000] ? rdinit_setup+0x30/0x30 [ 0.000000] parse_early_param+0x36/0x4d [ 0.000000] setup_arch+0x336/0x99e [ 0.000000] start_kernel+0x6f/0x4e6 [ 0.000000] x86_64_start_reservations+0x24/0x26 [ 0.000000] x86_64_start_kernel+0x6f/0x72 [ 0.000000] secondary_startup_64+0xa4/0xb0 This patch adds a check to prevent the panic. Signed-off-by: He Zhe Reviewed-by: Marek Szyprowski Cc: stable@vger.kernel.org Signed-off-by: Christoph Hellwig Signed-off-by: Greg Kroah-Hartman --- kernel/dma/contiguous.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/kernel/dma/contiguous.c +++ b/kernel/dma/contiguous.c @@ -49,7 +49,11 @@ static phys_addr_t limit_cmdline; static int __init early_cma(char *p) { - pr_debug("%s(%s)\n", __func__, p); + if (!p) { + pr_err("Config string not provided\n"); + return -EINVAL; + } + size_cmdline = memparse(p, &p); if (*p != '@') return 0;