Received: by 10.192.165.148 with SMTP id m20csp1792232imm; Thu, 26 Apr 2018 02:16:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx49LkPgKtW/etEQqYWF7285j9eqwrOAlMNcu88qxoCCHQLo4zIH0wMUY25yldqLo/ml+E4Us X-Received: by 2002:a17:902:8f95:: with SMTP id z21-v6mr32806400plo.304.1524734181499; Thu, 26 Apr 2018 02:16:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524734181; cv=none; d=google.com; s=arc-20160816; b=hrCWeNqJbwwFHoAGE4BaeVRjcYflOsjqLwK2pZWCKZ4fKKd7NPIeZkppM0gcimKlWN /ndMz5VyibJVndRbl7SQqglp3/4DWkUVLZkrqTT7Eba2PJLpHmmAUKcRhRZ4xmLHziuw JtUyVYA9afKWQWY/OuKwupLgJrm6ikG97TrN5wma4ajON4aih7O/06jl8xmrZYm8g/JK GMqf0hshlGb+coFk/va07qOmcpLdsUu896/Ek0OL/GILVg41S0lL+OXmocccJ095OJwE DKGSDx46rfB/ewnUUVVx00oq3f1c8lwnA8mMcxldzjBLR7DlQpq7R4Ci25p+5vo/L94w 8qOw== 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:to :from:date:arc-authentication-results; bh=OHuu0a1cFYGITrTPbnejazFgQKzOSUYSZGAHu30jHxA=; b=cGblvxeutLbpcFl78V67OdM4GBLDDUWgXHTq4kp+8Lcj2WIX15S5sZRHeut6F4CoLQ IRLU35dpcFevkPEw0CRBanvNitmxiAc7luGuurmBGbOv+AMmqI+a+75cW6z8xqhw2WcS uCNjdD/etlteE3sYZ72NglQZKHjB4i0y8yItARVbLck/knMzf1Hur2PAIscbSr8UadEI GiYqh7OCZqWCDG7WpDTsW8C/bfk66sbLyCTcwUJrLb1PioEBhEpZsqRvQkvS5TePdOTL waYHg/8bHKI5AWWUgPp/o9PxKDLNLU1WOdWt8Ul4ltzZJdl0q9NEqWxoOVHI2OHKZhVT r6/Q== 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 t3si2113508pgp.375.2018.04.26.02.16.07; Thu, 26 Apr 2018 02:16:21 -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 S1754875AbeDZJN2 (ORCPT + 99 others); Thu, 26 Apr 2018 05:13:28 -0400 Received: from mga11.intel.com ([192.55.52.93]:6876 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754686AbeDZJNX (ORCPT ); Thu, 26 Apr 2018 05:13:23 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2018 02:13:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,330,1520924400"; d="scan'208";a="37179351" Received: from gvt-dell.bj.intel.com (HELO intel.com) ([10.238.154.59]) by orsmga006.jf.intel.com with SMTP; 26 Apr 2018 02:13:21 -0700 Date: Thu, 26 Apr 2018 17:03:27 +0800 From: "Du, Changbin" To: joro@8bytes.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iommu/vt-d: fix shift-out-of-bounds in bug checking Message-ID: <20180426090327.ciune4mldns2a6nl@intel.com> References: <1524202195-4656-1-git-send-email-changbin.du@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1524202195-4656-1-git-send-email-changbin.du@intel.com> User-Agent: NeoMutt/20180323-6-5ca392 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, any reviewer? Thanks! On Fri, Apr 20, 2018 at 01:29:55PM +0800, changbin.du@intel.com wrote: > From: Changbin Du > > It allows to flush more than 4GB of device TLBs. So the mask should be > 64bit wide. UBSAN captured this fault as below. > > [ 3.760024] ================================================================================ > [ 3.768440] UBSAN: Undefined behaviour in drivers/iommu/dmar.c:1348:3 > [ 3.774864] shift exponent 64 is too large for 32-bit type 'int' > [ 3.780853] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G U 4.17.0-rc1+ #89 > [ 3.788661] Hardware name: Dell Inc. OptiPlex 7040/0Y7WYT, BIOS 1.2.8 01/26/2016 > [ 3.796034] Call Trace: > [ 3.798472] > [ 3.800479] dump_stack+0x90/0xfb > [ 3.803787] ubsan_epilogue+0x9/0x40 > [ 3.807353] __ubsan_handle_shift_out_of_bounds+0x10e/0x170 > [ 3.812916] ? qi_flush_dev_iotlb+0x124/0x180 > [ 3.817261] qi_flush_dev_iotlb+0x124/0x180 > [ 3.821437] iommu_flush_dev_iotlb+0x94/0xf0 > [ 3.825698] iommu_flush_iova+0x10b/0x1c0 > [ 3.829699] ? fq_ring_free+0x1d0/0x1d0 > [ 3.833527] iova_domain_flush+0x25/0x40 > [ 3.837448] fq_flush_timeout+0x55/0x160 > [ 3.841368] ? fq_ring_free+0x1d0/0x1d0 > [ 3.845200] ? fq_ring_free+0x1d0/0x1d0 > [ 3.849034] call_timer_fn+0xbe/0x310 > [ 3.852696] ? fq_ring_free+0x1d0/0x1d0 > [ 3.856530] run_timer_softirq+0x223/0x6e0 > [ 3.860625] ? sched_clock+0x5/0x10 > [ 3.864108] ? sched_clock+0x5/0x10 > [ 3.867594] __do_softirq+0x1b5/0x6f5 > [ 3.871250] irq_exit+0xd4/0x130 > [ 3.874470] smp_apic_timer_interrupt+0xb8/0x2f0 > [ 3.879075] apic_timer_interrupt+0xf/0x20 > [ 3.883159] > [ 3.885255] RIP: 0010:poll_idle+0x60/0xe7 > [ 3.889252] RSP: 0018:ffffb1b201943e30 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13 > [ 3.896802] RAX: 0000000080200000 RBX: 000000000000008e RCX: 000000000000001f > [ 3.903918] RDX: 0000000000000000 RSI: 000000002819aa06 RDI: 0000000000000000 > [ 3.911031] RBP: ffff9e93c6b33280 R08: 00000010f717d567 R09: 000000000010d205 > [ 3.918146] R10: ffffb1b201943df8 R11: 0000000000000001 R12: 00000000e01b169d > [ 3.925260] R13: 0000000000000000 R14: ffffffffb12aa400 R15: 0000000000000000 > [ 3.932382] cpuidle_enter_state+0xb4/0x470 > [ 3.936558] do_idle+0x222/0x310 > [ 3.939779] cpu_startup_entry+0x78/0x90 > [ 3.943693] start_secondary+0x205/0x2e0 > [ 3.947607] secondary_startup_64+0xa5/0xb0 > [ 3.951783] ================================================================================ > > Signed-off-by: Changbin Du > --- > drivers/iommu/dmar.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c > index accf5838..e4ae600 100644 > --- a/drivers/iommu/dmar.c > +++ b/drivers/iommu/dmar.c > @@ -1345,7 +1345,7 @@ void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep, > struct qi_desc desc; > > if (mask) { > - BUG_ON(addr & ((1 << (VTD_PAGE_SHIFT + mask)) - 1)); > + BUG_ON(addr & ((1ULL << (VTD_PAGE_SHIFT + mask)) - 1)); > addr |= (1ULL << (VTD_PAGE_SHIFT + mask - 1)) - 1; > desc.high = QI_DEV_IOTLB_ADDR(addr) | QI_DEV_IOTLB_SIZE; > } else > -- > 2.7.4 > -- Thanks, Changbin Du