Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3426722yba; Tue, 7 May 2019 00:40:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuR3Ya4qpM6waYq4zDBNUlhrsN6YVaUGAarqJ7I4HD++gIJYe70YzprPjaVtf7yZ1mIP8U X-Received: by 2002:a63:1706:: with SMTP id x6mr4998658pgl.280.1557214814962; Tue, 07 May 2019 00:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557214814; cv=none; d=google.com; s=arc-20160816; b=sqEaSWNgi8SZpoqwi4AFt5yyA7FNLUfTorMXIPysBdkjQtVd53hhS5rf4D8KAYA3na jPerHVCFYs6aWlWrWSbspdGZiZQGNcqA4+yJlsofxEeOM5V4ZCYYsE22O83yuXEuNRVH BsKKPWOBdlWBECHstdyL2Bafq6eAfmo37T+Jo4T0vSWryoOfiO4Pu0f9HIHA5BhVLBh/ QcHjuFtBJYsp0mXz8xcIm4klwW4J3BamPqQ/tOmdPLX2hGaq8agZO7+1fUShaGnhD8wF dtc57l8T+Zt79sATZtPL1rV3Xn4yMQrgBnReQDdDGmRugOCk675GGErUAZkC2s1Ttuu+ ELpg== 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=y2Wc1HQxQrsO+O4XhpOBwsmXCI4U6/ocXXVYMShtfY8=; b=jSO+NqG8rLIFQ+RH/94GiNH2wtMHctMY1HXTCDxF4A/xRekAPqzb9GAVYZoEomE0OV mqUtpV7PkNg17Sdy1OIdZem8xJAQmGJN8j9ruxW4iA3hLCP0nnCqj9rI6jSAXHOb8ghh OTuox8cQDwUWVLmKPhcw7PKo4cMM1J1hBfzS6h88qQswmBw0LzTyjE7EhHfKiyMRcxIW crEhyL8ApOvnAN0bCrPVeWpIfR3rO3XRTm060EuKX/kdi95DF5EqosTAyTmEGbuZWwWU 9NlvnoPlNbzEf8/2OWpZj+Anz0BsLqFwCmVUQieIm8TyPE39xmJuWE5ZxPzmNGfc/MeW gLzg== 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 e15si17953873pfn.31.2019.05.07.00.39.59; Tue, 07 May 2019 00:40:14 -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 S1726875AbfEGHjE (ORCPT + 99 others); Tue, 7 May 2019 03:39:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:57288 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726175AbfEGHjE (ORCPT ); Tue, 7 May 2019 03:39:04 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 92B9EAEC6; Tue, 7 May 2019 07:39:03 +0000 (UTC) Date: Tue, 7 May 2019 09:39:01 +0200 From: Joerg Roedel To: Qian Cai Cc: tmurphy@arista.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -next v2] iommu/amd: fix a null-ptr-deref in map_sg() Message-ID: <20190507073901.GC3486@suse.de> References: <20190506164440.37399-1-cai@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190506164440.37399-1-cai@lca.pw> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Qian, On Mon, May 06, 2019 at 12:44:40PM -0400, Qian Cai wrote: > The commit 1a1079011da3 ("iommu/amd: Flush not present cache in > iommu_map_page") added domain_flush_np_cache() in map_sg() which > triggered a crash below during boot. sg_next() could return NULL if > sg_is_last() is true, so after for_each_sg(sglist, s, nelems, i), "s" > could be NULL which ends up deferencing a NULL pointer later here, > > domain_flush_np_cache(domain, s->dma_address, s->dma_length); > > so move domain_flush_np_cache() call inside for_each_sg() to loop over > each sg element. Thanks for the fix, but it is too late to merge it into the tree. I am going to revert commit 1a1079011da3 for now and we can try again in the next cycle. Thanks, Joerg