Skip to content

Commit 270b329

Browse files
arndbDanilo Krummrich
authored andcommitted
Revert "drm/nouveau: check ioctl command codes better"
My previous patch ended up causing a regression for the DRM_IOCTL_NOUVEAU_NVIF ioctl. The intention of my patch was to only pass ioctl commands that have the correct dir/type/nr bits into the nouveau_abi16_ioctl() function. This turned out to be too strict, as userspace does use at least write-only and write-read direction settings. Checking for both of these still did not fix the issue, so the best we can do for the 6.16 release is to revert back to what we've had since linux-3.16. This version is still fragile, but at least it is known to work with existing userspace. Fixing this properly requires a better understanding of what commands are being passed from userspace in practice, and how that relies on the undocumented (miss)behavior in nouveau_drm_ioctl(). Fixes: e547816 ("drm/nouveau: check ioctl command codes better") Reported-by: Satadru Pramanik <[email protected]> Closes: https://lore.kernel.org/lkml/CAFrh3J85tsZRpOHQtKgNHUVnn=EG=QKBnZTRtWS8eWSc1K1xkA@mail.gmail.com/ Reported-by: Chris Bainbridge <[email protected]> Closes: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Add Closes: tags, fix minor typo in commit message. - Danilo ] Signed-off-by: Danilo Krummrich <[email protected]>
1 parent 491254f commit 270b329

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/gpu/drm/nouveau/nouveau_drm.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,9 +1284,6 @@ nouveau_ioctls[] = {
12841284
DRM_IOCTL_DEF_DRV(NOUVEAU_EXEC, nouveau_exec_ioctl_exec, DRM_RENDER_ALLOW),
12851285
};
12861286

1287-
#define DRM_IOCTL_NOUVEAU_NVIF _IOC(_IOC_READ | _IOC_WRITE, DRM_IOCTL_BASE, \
1288-
DRM_COMMAND_BASE + DRM_NOUVEAU_NVIF, 0)
1289-
12901287
long
12911288
nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
12921289
{
@@ -1300,10 +1297,14 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
13001297
return ret;
13011298
}
13021299

1303-
if ((cmd & ~IOCSIZE_MASK) == DRM_IOCTL_NOUVEAU_NVIF)
1300+
switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) {
1301+
case DRM_NOUVEAU_NVIF:
13041302
ret = nouveau_abi16_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
1305-
else
1303+
break;
1304+
default:
13061305
ret = drm_ioctl(file, cmd, arg);
1306+
break;
1307+
}
13071308

13081309
pm_runtime_mark_last_busy(dev->dev);
13091310
pm_runtime_put_autosuspend(dev->dev);

0 commit comments

Comments
 (0)