Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp722805pxj; Thu, 13 May 2021 15:33:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRaD1zrPK6Q/f7ttum/DBcoFwHYD6QzX+2k1QGGf0TmVHDrolV5x17rFPWKOSAqxGQ/k/P X-Received: by 2002:a05:6402:3546:: with SMTP id f6mr53012377edd.267.1620945231259; Thu, 13 May 2021 15:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620945231; cv=none; d=google.com; s=arc-20160816; b=HKODXA0BSiko9Yk4WrOa30PJjo0c14MjLquQnQBnNJnxUUSBSre3qYF7UJ4Y7TY2S7 v5nHauTx0Jz7LdpciFv68Uk46oIxP5ZZGnAVcOBY5T55pY2jjlhaFqMYsmoBcu/Ht+Yc wyckVTcbZENri+oe4c7uhf+N29uiXZH1VmxyFWXSr4L9ws3aZPxvrZxTKn7bdV2nszeN gYXma0GcMIGGfPxR6FtG20eOplT3YIlw8q2Hn3mXRddImlUDEw+LmQ6CX0IshSOKXYp3 hJ1FcvTY56evqhaPzrVdbbe4S8SLlIA2WKjhXuP/esJflgWl2lTUgxImI/R8j7jSu81P fvuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=hdpFzlw0w4/uVzT3jAhrSWNr+fsmMmecEBNQv5uklac=; b=ynHzO4zMEqZGKmkuFsKT7jATqnplc8Oe6m3+Hp8kkZ+7VVe4KfaReDqt97YVFVUOE6 OS3TXJHxGotS8b0Gd1v3BBiG4fBZC0TjE64q7SbwFxuMsUiSoz2OWa5MjzudsKDlyQjF 38DrPqGDMXBImYM00BR/nqifUZMKEIfUN4ycFhWJOieUNPA0eTX4YWFCyWwQP+I+lG/x gUx4yL0C95N/GfXVm6imvyz7axeCEM5+8Y43iG6pWkMr4YOBImYMUMGYvAFHwDogri9X VJKUGwGaoDBYqNURqUKS8Qg4MEYJb6k2cwttegUX6kliOEPi2US/NiLODP0Mip8JENJf /3hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FptvlGyS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dv19si791067ejb.195.2021.05.13.15.33.23; Thu, 13 May 2021 15:33:51 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FptvlGyS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234665AbhEMOq4 (ORCPT + 99 others); Thu, 13 May 2021 10:46:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41691 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234680AbhEMOpP (ORCPT ); Thu, 13 May 2021 10:45:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620917045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hdpFzlw0w4/uVzT3jAhrSWNr+fsmMmecEBNQv5uklac=; b=FptvlGySt6L+VmIxv70Gtb+R+a7gfIEfqS2D2B1+a/Jl1Bv8CgG1Hz6Eola3cR6EHeirqk 2+aWk0VTKwgl2tPaFHSumrKloKyUM8K+C0BnZekzZYZiEN7EDpkKY65mY0mtDvhGPQiqYn n8zpnL+SF99zTQyuHwaM8A2/34cI65I= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-219-l3dFiQnBO3GVfxpNXsh7Eg-1; Thu, 13 May 2021 10:44:02 -0400 X-MC-Unique: l3dFiQnBO3GVfxpNXsh7Eg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77B20107ACCD; Thu, 13 May 2021 14:44:00 +0000 (UTC) Received: from redhat.com (ovpn-113-225.phx2.redhat.com [10.3.113.225]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D8C161145; Thu, 13 May 2021 14:44:00 +0000 (UTC) Date: Thu, 13 May 2021 08:43:59 -0600 From: Alex Williamson To: Christoph Hellwig Cc: tkffaul@outlook.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Yao Subject: Re: [PATCH] vfio/pci: Sanity check IGD OpRegion Size Message-ID: <20210513084359.274353e9@redhat.com> In-Reply-To: References: <162041357421.21800.16214130780777455390.stgit@omen> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 10 May 2021 07:12:46 +0100 Christoph Hellwig wrote: > On Fri, May 07, 2021 at 12:53:17PM -0600, Alex Williamson wrote: > > + /* > > + * The OpRegion size field is specified as size in KB, but there have been > > + * user reports where this field appears to report size in bytes. If we > > + * read 8192, assume this is the case. > > + */ > > Please avoid pointlesly spilling the comment line over 80 chars. Oops, I didn't notice I was using a wider terminal. Fixed. > > + if (size == OPREGION_SIZE) > > Shouldn't this be a range tests, i.e. >= ? My concern here is how far we go down the path of trying to figure out what a sane size range is for this table an how/if we try to assume the BIOS intentions. The precise value of 8192 is not only absurdly large, but happens to coincide with the default table size, so it seems likely that we can infer this specific misinterpretation. If the BIOS has used a different value, suggesting they're trying to do something more extensive than a basic implementation, but still managed to botch the units for the size field, we should probably disregard it entirely. We can probably do that for smaller values as well, but I don't know where the line between reasonable and absurd is crossed. Would it make more sense to export e820__get_entry_type() so that we can validate that the full range of the table fits within an e820 mapping, which I understand should be ACPI NVS in this case? Thanks, Alex