Skip to content

Commit 76dc376

Browse files
vsyrjalajnikula
authored andcommitted
drm/i915: Don't clobber the addfb2 ioctl params
We try to convert the old way of of specifying fb tiling (obj->tiling) into the new fb modifiers. We store the result in the passed in mode_cmd structure. But that structure comes directly from the addfb2 ioctl, and gets copied back out to userspace, which means we're clobbering the modifiers that the user provided (all 0 since the DRM_MODE_FB_MODIFIERS flag wasn't even set by the user). Hence if the user reuses the struct for another addfb2, the ioctl will be rejected since it's now asking for some modifiers w/o the flag set. Fix the problem by making a copy of the user provided structure. We can play any games we want with the copy. IGT-Version: 1.12-git (x86_64) (Linux: 4.4.0-rc1-stereo+ x86_64) ... Subtest basic-X-tiled: SUCCESS (0.001s) Test assertion failure function pitch_tests, file kms_addfb_basic.c:167: Failed assertion: drmIoctl(fd, DRM_IOCTL_MODE_ADDFB2, &f) == 0 Last errno: 22, Invalid argument Stack trace: #0 [__igt_fail_assert+0x101] #1 [pitch_tests+0x619] #2 [__real_main426+0x2f] #3 [main+0x23] #4 [__libc_start_main+0xf0] #5 [_start+0x29] #6 [<unknown>+0x29] Subtest framebuffer-vs-set-tiling failed. **** DEBUG **** Test assertion failure function pitch_tests, file kms_addfb_basic.c:167: Failed assertion: drmIoctl(fd, DRM_IOCTL_MODE_ADDFB2, &f) == 0 Last errno: 22, Invalid argument **** END **** Subtest framebuffer-vs-set-tiling: FAIL (0.003s) ... IGT-Version: 1.12-git (x86_64) (Linux: 4.4.0-rc1-stereo+ x86_64) Subtest framebuffer-vs-set-tiling: SUCCESS (0.000s) Cc: [email protected] # v4.1+ Cc: Daniel Vetter <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Fixes: 2a80ead ("drm/i915: Add fb format modifier support") Testcase: igt/kms_addfb_basic/clobbered-modifier Signed-off-by: Ville Syrjälä <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Signed-off-by: Jani Nikula <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent ba8af3e commit 76dc376

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/gpu/drm/i915/intel_display.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14369,16 +14369,17 @@ static int intel_framebuffer_init(struct drm_device *dev,
1436914369
static struct drm_framebuffer *
1437014370
intel_user_framebuffer_create(struct drm_device *dev,
1437114371
struct drm_file *filp,
14372-
struct drm_mode_fb_cmd2 *mode_cmd)
14372+
struct drm_mode_fb_cmd2 *user_mode_cmd)
1437314373
{
1437414374
struct drm_i915_gem_object *obj;
14375+
struct drm_mode_fb_cmd2 mode_cmd = *user_mode_cmd;
1437514376

1437614377
obj = to_intel_bo(drm_gem_object_lookup(dev, filp,
14377-
mode_cmd->handles[0]));
14378+
mode_cmd.handles[0]));
1437814379
if (&obj->base == NULL)
1437914380
return ERR_PTR(-ENOENT);
1438014381

14381-
return intel_framebuffer_create(dev, mode_cmd, obj);
14382+
return intel_framebuffer_create(dev, &mode_cmd, obj);
1438214383
}
1438314384

1438414385
#ifndef CONFIG_DRM_FBDEV_EMULATION

0 commit comments

Comments
 (0)