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=1796380749; b=SWv3+wXL606GDZdcVsm2INN1Aimmz3BXQp0jKE1UeuGoKQFI8UqOrQ8e6pOGJ7BVpozA D0NsRyH/WBF+XpwgdlpGVbmSrOocBquCmiZ/3Iz0RP0p2grAIUiQWqFjXHFY9AK4yp1lJ 8/nkeHzzgn7ieYXJ6W+lktMQMEjnT4s/A7eg/MokI51lJJLOAo/Lgda4lmOpQ41PRGhA+ 5JE7OdjVafW/NPR7+mswusey1r1OBwmIBZ0kkNVfau5pvpEFDOzIsAQDCsXtN2iqtM+ML H7ugrPYMhrm1Rjdy4hi9ldivTPnOBmUJJLg76rBfZBRp+SS/6BeJGdv+MyvE8N47jEw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380749; 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=X43wHcToZ7yvCl5vKIor4Nw0VVX6ZdiSt4efXZ2lScM=; b=0TelTMLzDg5ziMzABd20oqH212KUZSWbNfEheaLtF3liM32D0KsNvFMh0VCMnwf1++/m Bd7asq99QF3zSmTzmF+fGvP6C0CUowfrm9cJ7dhkhhArWan8OFsVWcs2/4QMkkRZ+9Y+d JMjHh+T8ocBAoHGwkbNB8KI3ZpwPCuQVgxpnG/JiIXhlEg5yScY6hExY8ovAN5b8peCpM cOtnHWJtguZ9N8P07pwc0DzDrAifYOduoPEZT2mA6ZALe/Y+DH0U2q7xPgvLcw5mvFdPn 2WrxF7uK98BU6KhhuAvGjG3RzeRyExCowCyDf2t4lN/7qcMT5C1LwnjRgP6QVxa+zQA== 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=A+plkl8u; 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 9BF4C606A334; Fri, 4 Dec 2026 10:39:09 +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=A+plkl8u Received: by smtp.kernel.org (Postfix) with ESMTPSA id 155071F000CE; Fri, 4 Dec 2026 10:39:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380749; bh=X43wHcToZ7yvCl5vKIor4Nw0VVX6ZdiSt4efXZ2lScM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=A+plkl8uBxJP3SdcGBqZWHJ4J2vuCWvEMN6PFv7JKXBHwxJQ3zofrJfGX8uDYF+m7 t/LDAa6KM4QDVBggngtKN6ldVkdwNYXiKvm1tSaeWnXvK8x7y+qQYxQMQ9+Uzdho+8 0iiQONzK6lhNqIEydLsH2oj61IIDrxhC8ilrkGIk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zack Rusin , Maaz Mombasawala Subject: [PATCH 7.3 409/742] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages Date: Fri, 4 Dec 2026 19:04:33 +0900 Message-ID: <20261204100645.962679609@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zack Rusin commit 9725b0454e65f15ae76788f2004a7ba8b493362a upstream. vmw_mksstat_add_ioctl rounds the user-supplied 64bit lengths to page counts before comparing them with the descriptors page arrays. PFN_UP can wrap for lengths near U64_MAX. On 32bit kernels, storing a large page count in size_t can also truncate it to a value that passes the checks. A render-node client can therefore register a descriptor with lengths that exceed its pinned page arrays, including nonzero lengths with no backing pages. Compare each byte length with its page array's capacity before rounding or narrowing it. Compute those capacities in 64 bits and calculate the page counts only after all three lengths have passed validation. Sashiko reported this while reviewing the i386 hypercall changes. Fixes: 7a7a933edd6c ("drm/vmwgfx: Introduce VMware mks-guest-stats") Cc: stable@vger.kernel.org Closes: https://sashiko.dev/#/patchset/4ab10678a8f50053934b62b56af81f881c1d3798.1788414669.git.zack.rusin%40broadcom.com Signed-off-by: Zack Rusin Reviewed-by: Maaz Mombasawala Link: https://patch.msgid.link/20261029215738.3010276-2-zack.rusin@broadcom.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c @@ -939,9 +939,12 @@ int vmw_mksstat_add_ioctl(struct drm_dev struct vmw_private *const dev_priv = vmw_priv(dev); - const size_t num_pages_stat = PFN_UP(arg->stat_len); - const size_t num_pages_info = PFN_UP(arg->info_len); - const size_t num_pages_strs = PFN_UP(arg->strs_len); + const u64 max_stat_len = (u64)MKS_GUEST_STAT_INSTANCE_MAX_STAT_PPNS * PAGE_SIZE; + const u64 max_info_len = (u64)MKS_GUEST_STAT_INSTANCE_MAX_INFO_PPNS * PAGE_SIZE; + const u64 max_strs_len = (u64)MKS_GUEST_STAT_INSTANCE_MAX_STRS_PPNS * PAGE_SIZE; + size_t num_pages_stat; + size_t num_pages_info; + size_t num_pages_strs; long desc_len; long nr_pinned_stat; long nr_pinned_info; @@ -965,11 +968,15 @@ int vmw_mksstat_add_ioctl(struct drm_dev if (!arg->description) return -EINVAL; - if (num_pages_stat > ARRAY_SIZE(pdesc->statPPNs) || - num_pages_info > ARRAY_SIZE(pdesc->infoPPNs) || - num_pages_strs > ARRAY_SIZE(pdesc->strsPPNs)) + if (arg->stat_len > max_stat_len || + arg->info_len > max_info_len || + arg->strs_len > max_strs_len) return -EINVAL; + num_pages_stat = PFN_UP(arg->stat_len); + num_pages_info = PFN_UP(arg->info_len); + num_pages_strs = PFN_UP(arg->strs_len); + /* Find an available slot in the mksGuestStats user array and reserve it */ for (slot = 0; slot < ARRAY_SIZE(dev_priv->mksstat_user_pids); ++slot) if (!atomic_cmpxchg(&dev_priv->mksstat_user_pids[slot], 0, MKSSTAT_PID_RESERVED))