Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750929AbdHRJmQ (ORCPT ); Fri, 18 Aug 2017 05:42:16 -0400 Received: from 8bytes.org ([81.169.241.247]:53482 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750807AbdHRJmO (ORCPT ); Fri, 18 Aug 2017 05:42:14 -0400 Date: Fri, 18 Aug 2017 11:42:09 +0200 From: Joerg Roedel To: Robin Murphy Cc: iommu@lists.linux-foundation.org, shawn.lin@rock-chips.com, marc.zyngier@arm.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iommu: Avoid NULL group dereference Message-ID: <20170818094209.GA16257@8bytes.org> References: <59a6c4f0a790eea40e2b2f2be840b63317dd44e4.1502966326.git.robin.murphy@arm.com> <20170817154101.GL16908@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1070 Lines: 27 On Thu, Aug 17, 2017 at 05:56:23PM +0100, Robin Murphy wrote: > On 17/08/17 16:41, Joerg Roedel wrote: > > Okay, so just to check I got it right: Drivers do the above to check > > whether a device is managed by an IOMMU, and that crashes now because > > the 'group == NULL' check was removed? > > Indeed - the typical context is network descriptors that don't have > space to store the CPU virtual address of the buffer, so when a packet > arrives the driver has to work backwards from the DMA address, in this > sort of pattern: > > addr = desc[idx]->addr; > domain = iommu_get_domain_for_dev(dev); > if (domain) > addr = iommu_iova_to_phys(domain, addr) > buf = phys_to_virt(addr) > > (the GIC thing is similar but in reverse, with a physical address which > may or may not need replacing with an IOVA). Unless we were to change > the interface to be iommu_get_domain_for_group(), I think it makes sense > for it to remain valid to call for any device. Okay, we should find a better solution for this at some point, but I applied the patch for now. Joerg