Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp129281pxk; Tue, 15 Sep 2020 23:21:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNr7JSp7Mc3ZUgfdPBnVoiFF14qlKlSGdpkKQn7ak3WrmuPH1JVIxMT17XSni0JpLwOWZ7 X-Received: by 2002:a17:906:a251:: with SMTP id bi17mr23287704ejb.526.1600237313268; Tue, 15 Sep 2020 23:21:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600237313; cv=none; d=google.com; s=arc-20160816; b=EUmuEg7fDID59E7H3XW2cvj849eylgiLKjg4XoS/0R2ci8i++tUcR2Y9dWUFQIbd/x yRe2XfiA5J+AJh2+VDLnxyP6OYLCtzBXjrWY1pRXhMXiAnZzQDgRCOw3pDrbuwSZWbAr Mb05YSAIvS5DRmSsylr5kqN2ExGcXUCyAixMWxtqcLxcci9Odanaj1CM1MiK3shluvn+ f+J4WZObAbAmhKhh6uz1tOeByhpN6xZOTDrbW57jsiduaUXLFCKJpnwu2TjohhH2cGTc 5TCNb0hXOb0riVC2xzsxylVWYzsMs5Q1chUwhxuVdmbjmJkyegxOKvCDsfMHwKODHPGP 8vXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=uGAbM8kl25llF1bQ7PnN0oqJtVRniQ9TOX1GYeCMKks=; b=l1fVdEoKs+ivq4U236vnTNzO5pWVbC2N2ghwk+qPZOlv3JgQAWLam1inIFOsqO11PE rbWMCMbMQ2G6i9NB4CQWrOOanQeBD89kulJtctvor+5NBAVwMGTYXEVmvld+JUC3O8FO z46bTDVXg8fmlQyhQ4UnkxpBICj/07Kxy0MZ4uQXXNKPm220Iut3uUs2/QymO4vgYyCu H407x1aVVYR82Jtxv/UIJLHYZ61dlQMYFSMCUfN4VeS3WMHPlvCUda+Tnu+KU9KyecmJ kKYBDI/3qXV2w1hHDf9Lhge5RtPg+fmJ+dE8amqlBlPdjGMA2lmlwQjtJplPf72qTfCb 8sjw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce16si5396447edb.302.2020.09.15.23.21.30; Tue, 15 Sep 2020 23:21:53 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726416AbgIPGUC (ORCPT + 99 others); Wed, 16 Sep 2020 02:20:02 -0400 Received: from verein.lst.de ([213.95.11.211]:51054 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbgIPGTx (ORCPT ); Wed, 16 Sep 2020 02:19:53 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 209C268B05; Wed, 16 Sep 2020 08:19:50 +0200 (CEST) Date: Wed, 16 Sep 2020 08:19:49 +0200 From: Christoph Hellwig To: Thomas Tai Cc: Christoph Hellwig , konrad.wilk@oracle.com, m.szyprowski@samsung.com, robin.murphy@arm.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dma-direct: Fix potential NULL pointer dereference Message-ID: <20200916061949.GA8599@lst.de> References: <1600178594-22801-1-git-send-email-thomas.tai@oracle.com> <20200915140719.GA14831@lst.de> <20200915142624.GA16005@lst.de> <20200915150929.GA19770@lst.de> <5136ed8d-d37d-8144-a6f3-c23f272d8926@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5136ed8d-d37d-8144-a6f3-c23f272d8926@oracle.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 15, 2020 at 04:46:17PM -0400, Thomas Tai wrote: > I tried out the suggested changes, and it successfully warned the null > pointer without panic. I notice that there are some places outside the > dma-direct, which calls dma_capable(). > > https://elixir.bootlin.com/linux/v5.9-rc5/source/arch/x86/kernel/amd_gart_64.c#L187 > > https://elixir.bootlin.com/linux/v5.9-rc5/source/drivers/xen/swiotlb-xen.c#L387 All of these still come in throught the wrappers in kernel/dma/mapping.c. > Given that the WARN_ON_ONCE already did the intended warning, would you be > ok that I keep the null checking in dma_capable()? No, the generic dma mapping layer is the right place.