Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp3327758ima; Tue, 23 Oct 2018 04:17:08 -0700 (PDT) X-Google-Smtp-Source: AJdET5eXA8ELvSnmKQr2dKw073fR2+Y+r5VGGdOpc7ojZyfvZPHtNdqi0UIMOkhfI7RDSyO6LPJD X-Received: by 2002:a63:3c19:: with SMTP id j25mr1070153pga.286.1540293428027; Tue, 23 Oct 2018 04:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540293428; cv=none; d=google.com; s=arc-20160816; b=yqFZkp2wl6gURBPSXTLquALLIrMZQ3lLIiUVIKNkg1xtzyi/IPXk7eLsoc/SEE4Gkj B9XKAURzcuPlVdE77NghQ9AiPLqJWcy4w8D12QWU2kzuZkWFgUe8UOr8afk0I9ponCfO /LazX1UVSxkMtHjLsG+oWrVOXp4kzEVJEwVirhvldVw4HSX49EF1R8J04MPAFTZRiK6Q ZBQQTuW2mJcEYN70GjmsQkvdeSOEUCJbZj1WRYyQVatPzbBzBhOd36cpsU+8BCkXSTSw GeY9xKSLfWzhVr37HejyT9x5u1nb3UJ8xb08i916uitcS8oCopxDNAgqxy4hK6INE5wq Bm0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=PuZqUcWhrpKjMtZRA8waNzw+NC5BJe24BJqirFA96OE=; b=s6sxQRviRSP1UADUWJtyVhPTUPg3tJljJqTmCSaihQAw4a043q1E6i/SRaFsbYl8+T wKKv3SZSPNNrV0s7vt1LXCsdTflqsmRbTWo7VMa+VTLLW/Alca1cL8qZRuZA7lR4rLrM 6iipZf9Mm2M7T2UnEPG7DwL6aDSNcI+ks2N6sguGnCzA/KwuJAbbNL2Cf0GK/tQKWh0L OVJ+hFI8/Cv5XKKt5OEir2r9olDwXxClMTfjr9R0oL85PWy0QhD6p1kAQynjpjvxPOd1 mt4V0xSKH2t+k29A1Q7Pmawft5O65nP2dpuQk/bUlTKNuRTonS5P/V38hXX4utXyL1Mj 3FFQ== 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 j3-v6si1047287pfc.57.2018.10.23.04.16.52; Tue, 23 Oct 2018 04:17:07 -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 S1728138AbeJWTiL (ORCPT + 99 others); Tue, 23 Oct 2018 15:38:11 -0400 Received: from mail1.windriver.com ([147.11.146.13]:35144 "EHLO mail1.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726953AbeJWTiK (ORCPT ); Tue, 23 Oct 2018 15:38:10 -0400 Received: from ALA-HCA.corp.ad.wrs.com ([147.11.189.40]) by mail1.windriver.com (8.15.2/8.15.1) with ESMTPS id w9NBEhSZ012091 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Tue, 23 Oct 2018 04:14:43 -0700 (PDT) Received: from [128.224.162.216] (128.224.162.216) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 23 Oct 2018 04:14:42 -0700 Subject: Re: [PATCH] kernel/dma: Fix panic caused by passing swiotlb to command line To: Konrad Rzeszutek Wilk CC: , , , , , References: <1537154831-447363-1-git-send-email-zhe.he@windriver.com> <20181022192921.GA20677@dhcp-10-175-29-12.vpn.oracle.com> From: He Zhe Message-ID: <87ee40fa-7a01-4d4c-7fa3-81aafc93e14f@windriver.com> Date: Tue, 23 Oct 2018 19:14:38 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181022192921.GA20677@dhcp-10-175-29-12.vpn.oracle.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [128.224.162.216] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/10/23 03:29, Konrad Rzeszutek Wilk wrote: > On Sat, Sep 22, 2018 at 08:56:58PM +0800, He Zhe wrote: >> May I have your input? > Alternatively would it make more sense for it to assume some default > value? Maybe, but the original code has no default value and I have no idea what default value is proper here. Zhe >> Thanks, >> Zhe >> >> On 2018年09月17日 11:27, zhe.he@windriver.com wrote: >>> 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 */ >> _______________________________________________ >> iommu mailing list >> iommu@lists.linux-foundation.org >> https://lists.linuxfoundation.org/mailman/listinfo/iommu