Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp359985lqg; Thu, 11 Apr 2024 05:31:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWnIqNxTzhu0sgObI9XPD03cL+WdIr/xoxGrk3xiLuTL3RCNNI11EXQRmlN+TaDnsyX7Lzueqogdc3dh1NEV25sq707jgBGUkTNG1iaWQ== X-Google-Smtp-Source: AGHT+IGHQQy0ltRhsPro+yhQ9vfZW5KBfIPbyJfGZgY3vVUL58NQCo660QZAFMMXo2vGFglqKYVs X-Received: by 2002:a05:6a21:27b0:b0:1a9:88d6:3b80 with SMTP id rn48-20020a056a2127b000b001a988d63b80mr786674pzb.55.1712838703280; Thu, 11 Apr 2024 05:31:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712838703; cv=pass; d=google.com; s=arc-20160816; b=RyJi6712bpT0a0Oz++41mue2mHhl0h6ZD06NZ4dO7MUV6mIcxjxbvgHDpSnQa0sXw3 9xyCBYMxiGZh5ueBeSAypBaESW+wllG94PS/F1+uMbRagF5xaEbGxiALSYhJhHu0bSuw 5RsBNHwbLp9uHZFQs1usJ0zw0RnEdJAzrjLGYgSTAE0r+0HlAgx/olakDMkXAwoOKokl RBmf+Pfzg0gfMhEBDgUwBN6uT7dVjESs6Fd39K4X+ZLH7ZqNHYewOvbn0TkBT0/DHMqC 2Rac6izj9uQ1XSIG+dzEo1W2s7rKUc8PD0/8WTAQnBBAQZs5dFFYl8J5vhZyCz47FFk9 VepA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=1oIQRiFt2pm+clyXYjMJypM56tWC05pUV/YmmB1XGbs=; fh=qNz+N5UKmpvullVLnjkQqhQFxrz4wfnePGu0eh0/WxE=; b=GbNImQ5Z5yFyucIROJVdNOTBWKfjLcMocfWEjtb2E73PN6AReTuzixbRK4m5QzDLQc bjtbNAEpON0IKVmr4nA7wGHvkbIS4uyLsZQriz5R1aUWJlf/epJZ+cvpbW37V6blEyj+ apJxhboPW6XDSBrxqfUWDZW7CDatvuQd0qi6iIIxtqv8+QCmGgDPClAFENw97Gqwx5Bx rGgdpJB9k1M/qmBp++A9bFW5LsIIYd7AAONOe/o0nXR3A0rf+dFp5Eqcc19OzQq2oKvu BE/TRsjKCJONEN4SCpOsvSFYH2vlzAfg/pprkF0vR2g7LP4KYnyVVMxh8RF/QNuBRypS 34Xw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=qwmnSSbh; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-140439-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140439-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 30-20020a63185e000000b005dc8915c9cesi1224340pgy.381.2024.04.11.05.31.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 05:31:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140439-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=qwmnSSbh; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-140439-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140439-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E9C59289514 for ; Thu, 11 Apr 2024 12:31:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F09D96FB1; Thu, 11 Apr 2024 12:31:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="qwmnSSbh" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 90C79610B for ; Thu, 11 Apr 2024 12:31:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712838697; cv=none; b=FDxBU0i+TXrijHDWdH/ojMonEOA+oK7SIw4MvVeT8eJCwxb4cFYNvowyJa+tC68KSo4xCXYiNZuUo3moyDmtkf3tFg8pMER+ofelr0UfGgKt43jBXoOyv65NKs7VWJohzQFm3WakynVlCG41A7ocWndyIfm22jdsbof6bmM3QVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712838697; c=relaxed/simple; bh=zmevCFhXx6ZuzMCYAfjpOwI5DJ6QN9bdg4fgOkPUdqo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hUBnXLsf28autHBvkcnO5gtoXr55WByc4xZIoRhQkD/rn4WhHaxmhqAYI0cF1chZ2CQkv5fmDtJp1c2V5gwY7eyH1b7UEb3i/jhFX9Ra/0UGF5aQRk6rXmIXD02I0DPQVYflsNpYBF43TMt3QY05K77wAhJz0Sy2PnpkharRGxI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=qwmnSSbh; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712838688; bh=zmevCFhXx6ZuzMCYAfjpOwI5DJ6QN9bdg4fgOkPUdqo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=qwmnSSbhoBchnoBCuYnXfp2/6Jh3cN8jMBjFqh9AFIsoZwin9j3UUiUbk6U6zjoEQ ADrLiHD5rMU5plZ6/8l4lXNooe6j1yW+63uH8y6vLZsWmjKI63swv3aSnEFvsr72qr ZM27KFJFjzxFVaS/O97bQ1y/DEGFITe5vyUY/KTwAnyBtRuvfLBx9HzWPCLVf9cIyh 8UyhB6kp/XbNKpXQTbtuXeQqzjalp11cbrYLoABsvl3yV+/LEsTBieN3d4WgPJ9VAo 6SCIJRqaWzK/6Mg7ZArxaxnbDriu93Qt21D0GAYu6yS2qrbZGPI/P03AZWkqEPye1L xqhzxE9rPH8Qw== Received: from [100.109.49.129] (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 0B7C537813C0; Thu, 11 Apr 2024 12:31:26 +0000 (UTC) Message-ID: <6ca1e5de-2188-466f-a05c-ba190702d7a5@collabora.com> Date: Thu, 11 Apr 2024 15:31:24 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] drm/virtio: add driver_priv validation in virtio_gpu_create_context To: Maxim Korotkov , David Airlie Cc: Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Daniel Vetter , Ivan Kapranov , lvc-project@linuxtesting.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org References: <20240328134351.298050-1-korotkov.maxim.s@gmail.com> Content-Language: en-US From: Dmitry Osipenko In-Reply-To: <20240328134351.298050-1-korotkov.maxim.s@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/28/24 16:43, Maxim Korotkov wrote: > The pointer file->driver_priv was dereferenced without checking > against NULL, but in the "virtio_gpu_transfer_to_host_ioctl" function > it was checked against NULL after calling virtio_gpu_create_context > function. > > Found by Security Code and Linux Verification Center(linuxtesting.org) > Fixes: 72b48ae800da ("drm/virtio: enqueue virtio_gpu_create_context after the first 3D ioctl") > Signed-off-by: Maxim Korotkov > --- > drivers/gpu/drm/virtio/virtgpu_ioctl.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c > index e4f76f315550..98fe9ad4ed15 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c > +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c > @@ -64,6 +64,9 @@ void virtio_gpu_create_context(struct drm_device *dev, struct drm_file *file) > struct virtio_gpu_device *vgdev = dev->dev_private; > struct virtio_gpu_fpriv *vfpriv = file->driver_priv; > > + if (!vfpriv) > + return; > + > mutex_lock(&vfpriv->context_lock); > if (vfpriv->context_created) > goto out_unlock; NULL check in virtio_gpu_transfer_to_host_ioctl() is bogus, vfpriv can't be NULL there. -- Best regards, Dmitry