From nobody Thu Dec 18 12:53:03 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05D4521CFEE for ; Wed, 5 Feb 2025 23:18:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738797498; cv=none; b=BALYSAw8zqFQLgNrKAPtDYSCaDpjivpCTxt+6EhmOckKKDW9xBq8qjZjmf9/KJz9FnG9P39Id4giOVQ4EvmjyqWf+21WXTdrZEO9N4PBkQ5gWJzjQqHoO2tnGHqdBQzlTUJfcK6ezJTXua2K3JRZiR4I01d0jZiNqwUZCjk876o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738797498; c=relaxed/simple; bh=c0FKae0datf842mFkxPTOtU/p5nszLRuh9nfgAkopfA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fEK7qcSqX4mAf4/117QKJKkz0dc+qiwIeMX4I0P4XFi3/DY0TKv9Y6xb4l7TTM/vuZsP7Y502yfNx0cFAD6XSNMRB8gOy2m7mIptSxJSJmzwYXhme2J8XEJtwtu6rD2+KVCx4XTAbYbR1Vx7mLwKEttKLxMPYiSNlq0w5GD31f8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=RITY8emc; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RITY8emc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738797494; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VBKJl1czRBY86nXc1glbEuEYIO4hJO4j3CmfeALteSw=; b=RITY8emcNZD9IaYoQThOu2B8gR3rqD3ppIuNZ6TWAOY+0FC+ZWQc7Q2t2Ss0ju1Mfwkya0 xT0mja5dZm21cEf89ymXjghijrEyVRvA/B8YO+ODJXtNEgpThPTCZxA3aORQQaMR4QEC4n GiMTKXfokDhiO9U2ZbZzvXo3d0K0Q5M= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-wEuLXHT-MzWAqIlLtDFQ3Q-1; Wed, 05 Feb 2025 18:18:11 -0500 X-MC-Unique: wEuLXHT-MzWAqIlLtDFQ3Q-1 X-Mimecast-MFC-AGG-ID: wEuLXHT-MzWAqIlLtDFQ3Q Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B4B131800873; Wed, 5 Feb 2025 23:18:10 +0000 (UTC) Received: from omen.home.shazbot.org (unknown [10.22.81.141]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 46B6B1800265; Wed, 5 Feb 2025 23:18:09 +0000 (UTC) From: Alex Williamson To: alex.williamson@redhat.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, peterx@redhat.com, mitchell.augustin@canonical.com, clg@redhat.com Subject: [PATCH 1/5] vfio/type1: Catch zero from pin_user_pages_remote() Date: Wed, 5 Feb 2025 16:17:17 -0700 Message-ID: <20250205231728.2527186-2-alex.williamson@redhat.com> In-Reply-To: <20250205231728.2527186-1-alex.williamson@redhat.com> References: <20250205231728.2527186-1-alex.williamson@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" pin_user_pages_remote() can currently return zero for invalid args or zero nr_pages, neither of which should ever happen. However vaddr_get_pfns() indicates it should only ever return a positive value or -errno and there's a theoretical case where this can slip through and be unhandled by callers. Therefore convert zero to -EFAULT. Signed-off-by: Alex Williamson Reviewed-by: "Mitchell Augustin" Reviewed-by: Jason Gunthorpe Tested-by: "Mitchell Augustin" --- drivers/vfio/vfio_iommu_type1.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type= 1.c index 50ebc9593c9d..119cf886d8c0 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -564,6 +564,8 @@ static int vaddr_get_pfns(struct mm_struct *mm, unsigne= d long vaddr, if (ret > 0) { *pfn =3D page_to_pfn(pages[0]); goto done; + } else if (!ret) { + ret =3D -EFAULT; } =20 vaddr =3D untagged_addr_remote(mm, vaddr); --=20 2.47.1