Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3307798imu; Sun, 11 Nov 2018 12:04:11 -0800 (PST) X-Google-Smtp-Source: AJdET5dRZyXOrYuCjVxHhTJisiJ2DNs1A8DP9ERSS5iyHBrKfR0nQL/q5a6ON+C4otiQpnhtWDRc X-Received: by 2002:a63:495b:: with SMTP id y27mr14958348pgk.32.1541966651113; Sun, 11 Nov 2018 12:04:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966651; cv=none; d=google.com; s=arc-20160816; b=flihOd3Hxs+zGDgpVD5h7pkO3tjQl+j9f8s3zOYmkNsGeqKH3+jeLGVgFSyDXVj2BO i8O9ApVJ13zmPPSzvnuTjOo+jMxzONSI+uuwF631tgiEJ307FwE8jB7x0dXIlzbRxR7n Bf/ll/IQ/SnFjXzgmc22vD10FssJDuNBnAqduiwG2Wlwimi7kIWaDEvqtoyTAmaE/KRT blHwJtiEKMCnYXiiy/0pytu7EeI901ubS8ncifbTpEPSoIhTBzaCZ33JVJkJfHoFI/pg 8YaDkBSjPR/S7lzwleIb8OshSENak+3at62Rr0v6AknoODAKsYcFzdhGiDt2fgDQvDSo hOwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=Ntnnfa+nsi1z/ctNgoDO4nns+JMI2GxHh+6G69SNLjs=; b=LyXNoxNIkxhSsPET8CP+nIbu3fL1pIYFPnGOlEI8pKzdfgn0x+hbJDY7qJQsP5wYvI ALemLsMuC1f1N9WeQSQLVfIfi/w2kUgxNMW6DcnFl3/fGQoWVGduVAgzpu9qzgjVimAd B8ZXxQPOSbLSTe0oII2JmeNUjBgV8yNI37yUJjMIy8FvpJnqDawIj0kggx2XMWjlME2P zkXPw+lBzeznC/ljurTdIwDvi++/u3mPJfRu3wiqkubqrI1k1JA+Ul1yITrZ8HbgteJZ P/k35gllyDq20KUTaOQD6B3kR/gFylPDtE0eqxrMCW4g0reJkO0a6SqRJ8ibcED885xo rTOQ== 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 u9-v6si15158295pls.150.2018.11.11.12.03.56; Sun, 11 Nov 2018 12:04:11 -0800 (PST) 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 S1731013AbeKLFwR (ORCPT + 99 others); Mon, 12 Nov 2018 00:52:17 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:51166 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730713AbeKLFsb (ORCPT ); Mon, 12 Nov 2018 00:48:31 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsq-0000oN-Jo; Sun, 11 Nov 2018 19:59:00 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsW-0001js-ST; Sun, 11 Nov 2018 19:58:40 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Paul Burton" , "Rui Wang" , "Ralf Baechle" , "James Hogan" , "Wolfgang Grandegger" , linux-mips@linux-mips.org Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 261/366] MIPS: Fix off-by-one in pci_resource_to_user() In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Paul Burton commit 38c0a74fe06da3be133cae3fb7bde6a9438e698b upstream. The MIPS implementation of pci_resource_to_user() introduced in v3.12 by commit 4c2924b725fb ("MIPS: PCI: Use pci_resource_to_user to map pci memory space properly") incorrectly sets *end to the address of the byte after the resource, rather than the last byte of the resource. This results in userland seeing resources as a byte larger than they actually are, for example a 32 byte BAR will be reported by a tool such as lspci as being 33 bytes in size: Region 2: I/O ports at 1000 [disabled] [size=33] Correct this by subtracting one from the calculated end address, reporting the correct address to userland. Signed-off-by: Paul Burton Reported-by: Rui Wang Fixes: 4c2924b725fb ("MIPS: PCI: Use pci_resource_to_user to map pci memory space properly") Cc: James Hogan Cc: Ralf Baechle Cc: Wolfgang Grandegger Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/19829/ [bwh: Backported to 3.16: adjust filename] Signed-off-by: Ben Hutchings --- arch/mips/include/asm/pci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/mips/include/asm/pci.h +++ b/arch/mips/include/asm/pci.h @@ -87,7 +87,7 @@ static inline void pci_resource_to_user( phys_t size = resource_size(rsrc); *start = fixup_bigphys_addr(rsrc->start, size); - *end = rsrc->start + size; + *end = rsrc->start + size - 1; } /*