Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3498237imm; Sun, 16 Sep 2018 20:27:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYIn82Ute6WLTQMpj6WCmo/45PfqxF+WUWkdDC4ylB2POOY6xr3wZyoeo48jWmXEl2M0qOa X-Received: by 2002:a63:5f01:: with SMTP id t1-v6mr19405255pgb.149.1537154870736; Sun, 16 Sep 2018 20:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537154870; cv=none; d=google.com; s=arc-20160816; b=Gm2Z6EqKfBEcZBOc/N0bsvmzuGJBMG9Uqx4hxBNMmW5+BQly8MemA28fIUwXJHFm+3 7ORBZZ3DwNmNBSjvfhYSlODHbqBwmgEh5ATUPQVYNRZIL+1EHHMmS2Xz+25FhmEHGWsj OVCx5HfSM7wlw2K9mTlcJDhULAhgIcXTnnyVBvwjYXTnG1rnfuiUsC6zoeguZybzbBUQ wRfqCQBHxhZ1cVeBqDTsUYl0BttG8MmeMcMqC8Z40lUnk6lvtIde2jk/zpvFeRey/zpm ySVbO5BTfeDVNVDTzamMFvwSVTYB2/Fuv8iGohSfmkujhMbxhpuNXGWXAvR3tuDn8It9 pr0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=ePDK0RXJQmmDo/8aCeZouIw+ALqkf7N2Kr7aZS4xZME=; b=D+swdlThaAwT5HxCi3vyLnvlXzTBjYo3jcf5JnQNHmbc1d1yf3my9fnI44BZuPg6TR 4g4CWwrGO6sV5fEogZH5xi43upwyxkXyrp67uSErd8inDVidhI1Yd9HAB0MR4Jm3N/hc wErUbTp/PdDjRQWvZhISF1IDNjJE+ZNL0aX5PxqCJpMwbDfi5lbIXFKh+rGNO6yF2R9R 48zr6bSnM3m+4jBZSejNXpGuzbKQYNMXg6AsmMO6XOYDLG23bN0+DNmGisvsUVZnK+FL SMmVhStqMvVIW1luGdBukJb0NedkEsE7m3Lim/MlR9JR9m4kjvUn9tPQCpkEyF+gaBBt rW7A== ARC-Authentication-Results: i=1; mx.google.com; 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 b10-v6si16359858plk.302.2018.09.16.20.27.35; Sun, 16 Sep 2018 20:27:50 -0700 (PDT) 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; 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 S1730052AbeIQIwt (ORCPT + 99 others); Mon, 17 Sep 2018 04:52:49 -0400 Received: from mail.windriver.com ([147.11.1.11]:47076 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729640AbeIQIwt (ORCPT ); Mon, 17 Sep 2018 04:52:49 -0400 Received: from ALA-HCB.corp.ad.wrs.com ([147.11.189.41]) by mail.windriver.com (8.15.2/8.15.1) with ESMTPS id w8H3RGDU022301 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Sun, 16 Sep 2018 20:27:16 -0700 (PDT) Received: from pek-lpg-core2.corp.ad.wrs.com (128.224.153.41) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server id 14.3.408.0; Sun, 16 Sep 2018 20:27:15 -0700 From: To: , , , , , CC: Subject: [PATCH] kernel/dma: Fix panic caused by passing swiotlb to command line Date: Mon, 17 Sep 2018 11:27:11 +0800 Message-ID: <1537154831-447363-1-git-send-email-zhe.he@windriver.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: He Zhe setup_io_tlb_npages does not check input argument before passing it to isdigit. The argument would be a NULL pointer if "swiotlb", without its value, is set in command line and thus causes the following panic. PANIC: early exception 0xe3 IP 10:ffffffffbb9b8e9f error 0 cr2 0x0 [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.0-rc3-yocto-standard+ #9 [ 0.000000] RIP: 0010:setup_io_tlb_npages+0xf/0x95 ... [ 0.000000] Call Trace: [ 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 Cc: stable@vger.kernel.org Cc: konrad.wilk@oracle.com Cc: hch@lst.de Cc: m.szyprowski@samsung.com Cc: robin.murphy@arm.com --- kernel/dma/swiotlb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 4f8a6db..46fc34e 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -109,6 +109,11 @@ static int late_alloc; static int __init setup_io_tlb_npages(char *str) { + if (!str) { + pr_err("Config string not provided\n"); + return -EINVAL; + } + if (isdigit(*str)) { io_tlb_nslabs = simple_strtoul(str, &str, 0); /* avoid tail segment of size < IO_TLB_SEGSIZE */ -- 2.7.4