From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387630; b=0vuJUfavhn9ds5zU30CQ3VTD1MQa9ZHKidEQHp4cf9ws4jpBLk/8O8r60aBIsoGNHPag q5CWVEfcLlcgib7BLiibe8KEQNIIoyRlGmLpSd4h5sF0EnZ+zvmX1AaRYiNBAqhYflCZe wxVJLR6T2Ep7RTWD/uP/D/vvfq/FAppEK8ed8I7ilGctykWawO3lxvt7wi6iU9awKLXCH +HpzV0KWvzmA7yt4+68DFEtaQOAQmSyvdL/72Dtwh2UNIGfQ3XVWq48mtRhZ0AerLn7yV z3Y//yNuHuX6ts/LNjDFSc4648Zn9xYO9IqVisekUr5qmDtn4BlHBvf6jP+2wn7pwpA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387630; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=GJWmyHHmcb0FwN26jkXa0ijosUe/gq5Zby5VG9iUFhc=; b=D7eO6D4G1OM+Gz6OppsZoNOEuaFRUV6M4pZdEdX9FppGxUFcfq7kCMLkqxFoK9rsYc7P rv5YUXJ4/j22d9Kwb9qzgKul5NpOhnbCAhX/w9H0LZA+DVaeoAUHQbRx6EEeHQ8Luk5pj oOE2rGCfAZ0jr1katSjWwPbtyDh9ubPwYXKnKFXyhST3x9lP1lq2zvOyv/2HJ/cyVjWm7 42C6r7GY11I59HesBVooguDulxlOk3bXbJmneYBoNTNMUDHftSXtm0LyfraRTjoRh/UkJ hFEiZgMgtnfzh1SOI3kqXvRGiAAaoJyPVCzDrALgsuERbP2P7vz3mz/9dsTg6n/w8tA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=qF9n+86B; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D522F606A322; Fri, 4 Dec 2026 12:33:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=qF9n+86B Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50D0C1F000C2; Fri, 4 Dec 2026 12:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387630; bh=GJWmyHHmcb0FwN26jkXa0ijosUe/gq5Zby5VG9iUFhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qF9n+86BMPZTuBCgw/N+xFyDHIxMvH+PtrOx9fI2Hvi6sw6JtAELhZuExjptj/qYZ MlCFoqW0dRNRhZ5z6rR210epH9dM2PNPvB1DiRyUJdsY/6t9wWvgFeuVx6ichA0szX gbT4z8hic5aPOl2IIdZdfHnZi8AnU3ljRuPLiArY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mostafa Saleh , Eric Auger , Pranjal Shrivastava , Abdifatah Suruur , Alex Williamson , Sasha Levin Subject: [PATCH 6.1 0318/1059] vfio/platform: prevent read-only region mappings from becoming writable Date: Fri, 4 Dec 2026 18:57:29 +0900 Message-ID: <20261204100652.505387272@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Abdifatah Suruur [ Upstream commit 420bed9131dbbe37abe9d6b32af51219875811e0 ] vfio_platform_mmap() rejects writable mappings of regions without the WRITE flag, but leaves VM_MAYWRITE set. Userspace can map such a region read-only and then upgrade the mapping to writable with mprotect(). Clear VM_MAYWRITE for regions without the WRITE flag, as i915 does for its read-only objects and as fixed in drm/vc4 (CVE-2026-68445), drm/panthor (CVE-2024-53071) and commit a5edadbae57e ("ptp: vmclock: prevent read-only mappings from becoming writable"). Note this is defensive hardening: no in-tree platform driver currently publishes a region without the WRITE flag. The guard costs nothing and keeps the mmap() interface honest if a read-only region ever appears. Fixes: fad4d5b1f042 ("vfio/platform: support MMAP of MMIO regions") Reviewed-by: Mostafa Saleh Reviewed-by: Eric Auger Reviewed-by: Pranjal Shrivastava Signed-off-by: Abdifatah Suruur Link: https://lore.kernel.org/r/20260929094848.7439-2-suruurism@gmail.com Signed-off-by: Alex Williamson [ sashal: Replaced the vm_flags_clear(vma, VM_MAYWRITE) call with the open-coded vma->vm_flags &= ~VM_MAYWRITE; because the helper doesn't exist in this tree. ] Signed-off-by: Sasha Levin --- drivers/vfio/platform/vfio_platform_common.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index 1820ed0f9e010..0f0f8fdef896e 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -608,9 +608,13 @@ int vfio_platform_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma && (vma->vm_flags & VM_READ)) return -EINVAL; - if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_WRITE) - && (vma->vm_flags & VM_WRITE)) - return -EINVAL; + /* Prevent read-only region mappings from being upgraded with mprotect() */ + if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_WRITE)) { + if (vma->vm_flags & VM_WRITE) + return -EINVAL; + + vma->vm_flags &= ~VM_MAYWRITE; + } vma->vm_private_data = vdev; -- 2.53.0