drm: pre-fill getfb2 modifier array with INVALID
Subsystems (2)
PATCH 1/1 drm: pre-fill getfb2 modifier array with INVALID
User-space shouldn't look up the modifier array when the modifier flag is missing, but at the moment no docs make this clear (working on it). Right now the modifier array is pre-filled with zeroes, aka. LINEAR. Instead, pre-fill with INVALID to avoid footguns.
This is a uAPI change, but OTOH any user-space which looks up the modifier array without checking the flag is broken already, so should be fine.
--- drivers/gpu/drm/drm_framebuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_framebuffer.c +1 -1
@@ -601,7 +601,7 @@ int drm_mode_getfb2_ioctl(struct drm_device *dev, r->handles[i] =0 ; r->pitches[i] =0 ; r->offsets[i] =0 ; - r->modifier[i] =0 ; + r->modifier[i] =DRM_FORMAT_MOD_INVALID ; }for (i =0 ; i < fb->format->num_planes; i++) {
Signature · 1 line
2.33.1
Quoted 22 lines · On Thu, 11 Nov 2021 10:10:54 +0000 Simon Ser <[email protected]> wrote:
User-space shouldn't look up the modifier array when the modifier flag is missing, but at the moment no docs make this clear (working on it). Right now the modifier array is pre-filled with zeroes, aka. LINEAR. Instead, pre-fill with INVALID to avoid footguns.
This is a uAPI change, but OTOH any user-space which looks up the modifier array without checking the flag is broken already, so should be fine.
Signed-off-by Simon Ser <[email protected]>Cc Daniel Vetter <[email protected]>Cc Pekka Paalanen <[email protected]>Cc Daniel Stone <[email protected]>--- drivers/gpu/drm/drm_framebuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_framebuffer.c +0
-0
drivers/gpu/drm/drm_framebuffer.c int drm_mode_getfb2_ioctl(struct drm_device *dev, · line 607
Quoted 8 lines
drivers/gpu/drm/drm_framebuffer.c +1
-1@@ -601,7 +601,7 @@ int drm_mode_getfb2_ioctl(struct drm_device *dev, r->handles[i] =0 ; r->pitches[i] =0 ; r->offsets[i] =0 ; - r->modifier[i] =0 ; + r->modifier[i] =DRM_FORMAT_MOD_INVALID ; }for (i =0 ; i < fb->format->num_planes; i++) {
Thanks,
pq
Quoted 8 lines · Simon Ser
User-space shouldn't look up the modifier array when the modifier flag is missing, but at the moment no docs make this clear (working on it). Right now the modifier array is pre-filled with zeroes, aka. LINEAR. Instead, pre-fill with INVALID to avoid footguns.
This is a uAPI change, but OTOH any user-space which looks up the modifier array without checking the flag is broken already, so should be fine.
I don't know of any userspace which this would break.
Quoted 5 lines · Simon Ser
User-space shouldn't look up the modifier array when the modifier flag is missing, but at the moment no docs make this clear (working on it). Right now the modifier array is pre-filled with zeroes, aka. LINEAR. Instead, pre-fill with INVALID to avoid footguns.
Quoted 8 lines
This is a uAPI change, but OTOH any user-space which looks up the modifier array without checking the flag is broken already, so should be fine.
Signed-off-by Simon Ser <[email protected]>Cc Daniel Vetter <[email protected]>Cc Pekka Paalanen <[email protected]>Cc Daniel Stone <[email protected]>
Isn't this going to break the test where we pass the get getfb2 result back into addfb2?
Quoted 20 lines
--- drivers/gpu/drm/drm_framebuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_framebuffer.c +1
-1@@ -601,7 +601,7 @@ int drm_mode_getfb2_ioctl(struct drm_device *dev, r->handles[i] =0 ; r->pitches[i] =0 ; r->offsets[i] =0 ; - r->modifier[i] =0 ; + r->modifier[i] =DRM_FORMAT_MOD_INVALID ; }for (i =0 ; i < fb->format->num_planes; i++) {Signature · 1 line
2.33.1
Signature · 2 lines
Ville Syrjälä Intel
Quoted 10 lines · Ville Syrjälä
Quoted 9 lines · Simon Ser
User-space shouldn't look up the modifier array when the modifier flag is missing, but at the moment no docs make this clear (working on it). Right now the modifier array is pre-filled with zeroes, aka. LINEAR. Instead, pre-fill with INVALID to avoid footguns.
This is a uAPI change, but OTOH any user-space which looks up the modifier array without checking the flag is broken already, so should be fine.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Simon Ser <[email protected]>Cc Daniel Vetter <[email protected]>Cc Pekka Paalanen <[email protected]>Cc Daniel Stone <[email protected]>Isn't this going to break the test where we pass the get getfb2 result back into addfb2?
Shouldn't be the case, since the kernel will ignore modifiers if the flag isn't set.
Quoted 17 lines · Simon Ser
Quoted 15 lines · Ville Syrjälä
Quoted 13 lines · Simon Ser
User-space shouldn't look up the modifier array when the modifier flag is missing, but at the moment no docs make this clear (working on it). Right now the modifier array is pre-filled with zeroes, aka. LINEAR. Instead, pre-fill with INVALID to avoid footguns.
This is a uAPI change, but OTOH any user-space which looks up the modifier array without checking the flag is broken already, so should be fine.
Signed-off-by Simon Ser <[email protected]>Cc Daniel Vetter <[email protected]>Cc Pekka Paalanen <[email protected]>Cc Daniel Stone <[email protected]>
Quoted 5 lines
Quoted 2 lines
Isn't this going to break the test where we pass the get getfb2 result back into addfb2?
Shouldn't be the case, since the kernel will ignore modifiers if the flag isn't set.
if (r->modifier[i] && !(r->flags & DRM_MODE_FB_MODIFIERS)) {
DRM_DEBUG_KMS("bad fb modifier %llu for plane %d\n",
r->modifier[i], i);
return -EINVAL;
}Signature · 2 lines
Ville Syrjälä Intel
Hm indeed, RIP. I got confused by this one:
/* Pre-FB_MODIFIERS userspace didn't clear the structs properly. */ if (!(r->flags & DRM_MODE_FB_MODIFIERS)) continue;
But it's only run for unused planes.