linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau: check ioctl command codes better
@ 2025-07-11  7:24 Arnd Bergmann
  2025-07-11 17:41 ` Danilo Krummrich
  2025-07-11 18:06 ` Danilo Krummrich
  0 siblings, 2 replies; 11+ messages in thread
From: Arnd Bergmann @ 2025-07-11  7:24 UTC (permalink / raw)
  To: Lyude Paul, Danilo Krummrich, David Airlie, Simona Vetter,
	Ben Skeggs
  Cc: Arnd Bergmann, Ben Skeggs, Timur Tabi, Dave Airlie,
	Thomas Zimmermann, dri-devel, nouveau, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

nouveau_drm_ioctl() only checks the _IOC_NR() bits in the DRM_NOUVEAU_NVIF
command, but ignores the type and direction bits, so any command with
'7' in the low eight bits gets passed into nouveau_abi16_ioctl() instead
of drm_ioctl().

Check for all the bits except the size that is handled inside of the handler.

Fixes: 27111a23d01c ("drm/nouveau: expose the full object/event interfaces to userspace")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 1527b801f013..506eeb44f0d4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1284,6 +1284,9 @@ nouveau_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(NOUVEAU_EXEC, nouveau_exec_ioctl_exec, DRM_RENDER_ALLOW),
 };
 
+#define DRM_IOCTL_NOUVEAU_NVIV _IOC(_IOC_READ|_IOC_WRITE, DRM_IOCTL_BASE, \
+				    DRM_COMMAND_BASE + DRM_NOUVEAU_NVIF, 0)
+
 long
 nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
@@ -1297,14 +1300,10 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		return ret;
 	}
 
-	switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) {
-	case DRM_NOUVEAU_NVIF:
+	if ((cmd & ~IOCSIZE_MASK) == DRM_IOCTL_NOUVEAU_NVIV)
 		ret = nouveau_abi16_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
-		break;
-	default:
+	else
 		ret = drm_ioctl(file, cmd, arg);
-		break;
-	}
 
 	pm_runtime_mark_last_busy(dev->dev);
 	pm_runtime_put_autosuspend(dev->dev);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 11+ messages in thread
* Re: [PATCH] drm/nouveau: check ioctl command codes better
@ 2025-07-21 12:22 Satadru Pramanik
  2025-07-21 12:37 ` Arnd Bergmann
  2025-07-22 10:29 ` Chris Bainbridge
  0 siblings, 2 replies; 11+ messages in thread
From: Satadru Pramanik @ 2025-07-21 12:22 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: airlied, airlied, arnd, bskeggs, bskeggs, open list:DRM DRIVERS,
	open list, Lyude Paul, nouveau, simona, ttabi, Thomas Zimmermann,
	Satadru Pramanik

Hello all,

I suspect this commit in 6.16-rc7 has broken acceleration with Mesa's
nouveau drivers on my machine.

glxinfo -B reports that I'm using llvmpipe.

Reverting this in 6.16-rc7 restores nouveau acceleration, and glxinfo
then reports: "OpenGL renderer string: NVE7"

inxi -G
Graphics:
  Device-1: NVIDIA GK107M [GeForce GT 750M Mac Edition] driver: nouveau
    v: kernel
  Display: wayland server: X.Org v: 24.1.8 with: Xwayland v: 24.1.8
    compositor: gnome-shell v: 48.0 driver: X: loaded: modesetting
    unloaded: fbdev,vesa dri: nouveau gpu: nouveau resolution: 2880x1800~60Hz
  API: EGL v: 1.5 drivers: nouveau,swrast
    platforms: gbm,wayland,x11,surfaceless,device
  API: OpenGL v: 4.5 compat-v: 4.3 vendor: mesa
    v: 25.2.0~rc1+git2507191056.03f67b52319~p~mesarc0 renderer: NVE7
  API: Vulkan v: 1.4.304 drivers: N/A surfaces: xcb,xlib,wayland
  Info: Tools: api: eglinfo, glxinfo, vulkaninfo x11: xdriinfo, xdpyinfo,
    xprop, xrandr

Best,
Satadru Pramanik

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-07-22 11:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-11  7:24 [PATCH] drm/nouveau: check ioctl command codes better Arnd Bergmann
2025-07-11 17:41 ` Danilo Krummrich
2025-07-11 18:01   ` Arnd Bergmann
2025-07-11 18:06 ` Danilo Krummrich
  -- strict thread matches above, loose matches on Subject: below --
2025-07-21 12:22 Satadru Pramanik
2025-07-21 12:37 ` Arnd Bergmann
     [not found]   ` <CAFrh3J-SpU03=Kgi8vj1XLsMfruQyF1Rew6L2+aYUgZnkTLJAw@mail.gmail.com>
2025-07-21 13:50     ` Arnd Bergmann
2025-07-21 15:23       ` Satadru Pramanik
2025-07-22 10:29 ` Chris Bainbridge
2025-07-22 10:52   ` Arnd Bergmann
2025-07-22 11:45     ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).