Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp251928ybt; Fri, 19 Jun 2020 00:45:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcEwceITe+7Lm+YDfQWFuDQspw+G6PiRbFf7y7tQmEXYPLtpzpWpEioMpI2xxLMmre3Nql X-Received: by 2002:a17:906:cede:: with SMTP id si30mr2490483ejb.315.1592552717997; Fri, 19 Jun 2020 00:45:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592552717; cv=none; d=google.com; s=arc-20160816; b=WXJS1i3o806hWor9Lm+VySs5vB0RS2FJPyM6VfxCnX+H3c4B7/1GRsyk18f8R72UO3 PQ7/Ffl25CBBgpfJmLnTwDgMnfgBcLCHRrxfqqJeVDA9WTuu95deouKaZkPB7CmfnkFa AYdDWiwKz0LgM9GqkkC+t+r+bdDHJuTBD94GmaiaYcCk4x6KNc5pRhraRisuUH//TG9Y X7Z51eTOnHyawmZyIvb41rFdx+/FVYPFX8zuCFlScfmC+3jvlot3L8kPmwloK4KYhIar zXmTGrF2wc2HYvsySU1fpylWWRiklab7E+mf1sJ0D5NrbU4DfJOESUsHkrnRKgRAD7t+ OMxA== 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=QT/PyCjdLYXZcHsCoj0llYPqHP/pvvD5mrqRv6emzpA=; b=EvrMXfsmF0O7hQLxSw2xV86J5+b4+7bLhYALrOYEZw5oqyyVqPj33BWPmwST3zzYGf ocdM97l8jWqM7BwA7Hbstyz9GhfbaNHlU/TLnIoG4Z0FKjsfL01nK/RKQDfGav+0sIFU iX5Lu61bJ2QYVVjFiLc4WUalKudO4ScZffnCJ/zo3htF+Lp+jhl+Dm8rHCQokkHZSLF8 OSGA/ok5JpuAIOcfpmdZIs4Ov1KPU/lRBVNsmt5hN+gVofM8IVncYqGcU35FuktOlHIx kjAWNrY5wWgvYl8r4l0rTGyuZMG8lg99HDYCL31H1iS6reAY1vEUsePcVNOinSGNbjSG UuNg== 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 bu21si3460745ejb.675.2020.06.19.00.44.55; Fri, 19 Jun 2020 00:45:17 -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 S1730861AbgFSHmh (ORCPT + 99 others); Fri, 19 Jun 2020 03:42:37 -0400 Received: from verein.lst.de ([213.95.11.211]:52332 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729548AbgFSHmg (ORCPT ); Fri, 19 Jun 2020 03:42:36 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 0A2F568AFE; Fri, 19 Jun 2020 09:42:34 +0200 (CEST) Date: Fri, 19 Jun 2020 09:42:33 +0200 From: Christoph Hellwig To: "Kenneth R. Crudup" Cc: Christoph Hellwig , Linus Torvalds , linux-kernel@vger.kernel.org Subject: Re: Commit 25f12ae45fc1 ("maccess: rename probe_kernel_address to get_kernel_nofault") causing several OOPSes Message-ID: <20200619074233.GA3723@lst.de> References: <20200619065007.GA3041@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Jun 18, 2020 at 11:57:27PM -0700, Kenneth R. Crudup wrote: > > On Fri, 19 Jun 2020, Christoph Hellwig wrote: > > > That is indeed really strange, as that commit is just a rename. > > Well, Linus also added swapping of the argument order, but again it > > shouldn't change much. > > Thing is, there's other examples of the previous version in the kernel tree- any > chance there's a usage conflict (Thunderbolt has a ROM in it, maybe something in > "probe_roms.c"? (Just guessing, no idea): Maybe. But nothing looks strange there. Just to re-reconfirm, you had to revert "maccess: rename probe_kernel_address to get_kernel_nofault", "maccess: make get_kernel_nofault() check for minimal type compatibility" wasn't enough? Below is a patch to do a "partial revert" for probe_roms.c. I'd be totally surprised if it changes anything from staring at it for while, but anyway.. diff --git a/arch/x86/kernel/probe_roms.c b/arch/x86/kernel/probe_roms.c index 9e1def3744f220..70ff3267b4f373 100644 --- a/arch/x86/kernel/probe_roms.c +++ b/arch/x86/kernel/probe_roms.c @@ -22,6 +22,9 @@ #include #include +#define probe_kernel_address(addr, retval) \ + copy_from_kernel_nofault(&retval, addr, sizeof(retval)) + static struct resource system_rom_resource = { .name = "System ROM", .start = 0xf0000, @@ -99,7 +102,7 @@ static bool probe_list(struct pci_dev *pdev, unsigned short vendor, unsigned short device; do { - if (get_kernel_nofault(device, rom_list) != 0) + if (probe_kernel_address(rom_list, device) != 0) device = 0; if (device && match_id(pdev, vendor, device)) @@ -125,13 +128,13 @@ static struct resource *find_oprom(struct pci_dev *pdev) break; rom = isa_bus_to_virt(res->start); - if (get_kernel_nofault(offset, rom + 0x18) != 0) + if (probe_kernel_address(rom + 0x18, offset) != 0) continue; - if (get_kernel_nofault(vendor, rom + offset + 0x4) != 0) + if (probe_kernel_address(rom + offset + 0x4, vendor) != 0) continue; - if (get_kernel_nofault(device, rom + offset + 0x6) != 0) + if (probe_kernel_address(rom + offset + 0x6, device) != 0) continue; if (match_id(pdev, vendor, device)) { @@ -139,8 +142,8 @@ static struct resource *find_oprom(struct pci_dev *pdev) break; } - if (get_kernel_nofault(list, rom + offset + 0x8) == 0 && - get_kernel_nofault(rev, rom + offset + 0xc) == 0 && + if (probe_kernel_address(rom + offset + 0x8, list) == 0 && + probe_kernel_address(rom + offset + 0xc, rev) == 0 && rev >= 3 && list && probe_list(pdev, vendor, rom + offset + list)) { oprom = res; @@ -183,14 +186,14 @@ static int __init romsignature(const unsigned char *rom) const unsigned short * const ptr = (const unsigned short *)rom; unsigned short sig; - return get_kernel_nofault(sig, ptr) == 0 && sig == ROMSIGNATURE; + return probe_kernel_address(ptr, sig) == 0 && sig == ROMSIGNATURE; } static int __init romchecksum(const unsigned char *rom, unsigned long length) { unsigned char sum, c; - for (sum = 0; length && get_kernel_nofault(c, rom++) == 0; length--) + for (sum = 0; length && probe_kernel_address(rom++, c) == 0; length--) sum += c; return !length && !sum; } @@ -211,7 +214,7 @@ void __init probe_roms(void) video_rom_resource.start = start; - if (get_kernel_nofault(c, rom + 2) != 0) + if (probe_kernel_address(rom + 2, c) != 0) continue; /* 0 < length <= 0x7f * 512, historically */ @@ -249,7 +252,7 @@ void __init probe_roms(void) if (!romsignature(rom)) continue; - if (get_kernel_nofault(c, rom + 2) != 0) + if (probe_kernel_address(rom + 2, c) != 0) continue; /* 0 < length <= 0x7f * 512, historically */