From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Maíra Canal" <mcanal@igalia.com>
Cc: "André Almeida" <andrealmeid@igalia.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Simon Ser" <contact@emersion.fr>,
dri-devel@lists.freedesktop.org,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Melissa Wen" <mwen@igalia.com>,
"Rob Clark" <robdclark@gmail.com>,
"VMware Graphics Reviewers"
<linux-graphics-maintainer@vmware.com>,
amd-gfx@lists.freedesktop.org, "Daniel Vetter" <daniel@ffwll.ch>,
"Daniel Vetter" <daniel.vetter@ffwll.ch>,
"Alex Deucher" <alexander.deucher@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Christian König" <christian.koenig@amd.com>,
"Zack Rusin" <zackr@vmware.com>
Subject: Re: [PATCH v2 1/3] drm/framebuffer: Check for valid formats
Date: Fri, 13 Jan 2023 15:06:34 +0200 [thread overview]
Message-ID: <Y8FXWvEhO7GCRKVJ@intel.com> (raw)
In-Reply-To: <20230113112743.188486-2-mcanal@igalia.com>
On Fri, Jan 13, 2023 at 08:27:42AM -0300, Maíra Canal wrote:
> Currently, framebuffer_check() doesn't check if the pixel format is
> supported, which can lead to the acceptance of invalid pixel formats
> e.g. the acceptance of invalid modifiers. Therefore, add a check for
> valid formats on framebuffer_check(), so that the ADDFB2 IOCTL rejects
> calls with invalid formats.
>
> Moreover, note that this check is only valid for atomic drivers,
> because, for non-atomic drivers, checking drm_any_plane_has_format() is
> not possible since the format list for the primary plane is fake, and
> we'd therefore reject valid formats.
>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Maíra Canal <mcanal@igalia.com>
> ---
> Documentation/gpu/todo.rst | 9 ++++-----
> drivers/gpu/drm/drm_framebuffer.c | 8 ++++++++
> 2 files changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
> index 1f8a5ebe188e..3a79c26c5cc7 100644
> --- a/Documentation/gpu/todo.rst
> +++ b/Documentation/gpu/todo.rst
> @@ -276,11 +276,10 @@ Various hold-ups:
> - Need to switch to drm_fbdev_generic_setup(), otherwise a lot of the custom fb
> setup code can't be deleted.
>
> -- Many drivers wrap drm_gem_fb_create() only to check for valid formats. For
> - atomic drivers we could check for valid formats by calling
> - drm_plane_check_pixel_format() against all planes, and pass if any plane
> - supports the format. For non-atomic that's not possible since like the format
> - list for the primary plane is fake and we'd therefor reject valid formats.
> +- Need to switch to drm_gem_fb_create(), as now framebuffer_check() checks for
> + valid formats for atomic drivers.
> +
> +- Add an addfb format validation for non-atomic drivers.
>
> - Many drivers subclass drm_framebuffer, we'd need a embedding compatible
> version of the varios drm_gem_fb_create functions. Maybe called
> diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> index aff3746dedfb..605642bf3650 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -280,6 +280,14 @@ static int framebuffer_check(struct drm_device *dev,
> }
> }
>
> + /* Verify that the modifier is supported. */
> + if (drm_drv_uses_atomic_modeset(dev) &&
> + !drm_any_plane_has_format(dev, r->pixel_format, r->modifier[0])) {
> + drm_dbg_kms(dev, "Unsupported pixel format %p4cc / modifier 0x%llx\n",
> + &r->pixel_format, r->modifier[0]);
> + return -EINVAL;
> + }
Like I said this is still wrong for the !modifiers case.
> +
> return 0;
> }
>
> --
> 2.39.0
--
Ville Syrjälä
Intel
WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Maíra Canal" <mcanal@igalia.com>
Cc: "André Almeida" <andrealmeid@igalia.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
dri-devel@lists.freedesktop.org, "Melissa Wen" <mwen@igalia.com>,
"VMware Graphics Reviewers"
<linux-graphics-maintainer@vmware.com>,
amd-gfx@lists.freedesktop.org,
"Daniel Vetter" <daniel.vetter@ffwll.ch>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH v2 1/3] drm/framebuffer: Check for valid formats
Date: Fri, 13 Jan 2023 15:06:34 +0200 [thread overview]
Message-ID: <Y8FXWvEhO7GCRKVJ@intel.com> (raw)
In-Reply-To: <20230113112743.188486-2-mcanal@igalia.com>
On Fri, Jan 13, 2023 at 08:27:42AM -0300, Maíra Canal wrote:
> Currently, framebuffer_check() doesn't check if the pixel format is
> supported, which can lead to the acceptance of invalid pixel formats
> e.g. the acceptance of invalid modifiers. Therefore, add a check for
> valid formats on framebuffer_check(), so that the ADDFB2 IOCTL rejects
> calls with invalid formats.
>
> Moreover, note that this check is only valid for atomic drivers,
> because, for non-atomic drivers, checking drm_any_plane_has_format() is
> not possible since the format list for the primary plane is fake, and
> we'd therefore reject valid formats.
>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Maíra Canal <mcanal@igalia.com>
> ---
> Documentation/gpu/todo.rst | 9 ++++-----
> drivers/gpu/drm/drm_framebuffer.c | 8 ++++++++
> 2 files changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
> index 1f8a5ebe188e..3a79c26c5cc7 100644
> --- a/Documentation/gpu/todo.rst
> +++ b/Documentation/gpu/todo.rst
> @@ -276,11 +276,10 @@ Various hold-ups:
> - Need to switch to drm_fbdev_generic_setup(), otherwise a lot of the custom fb
> setup code can't be deleted.
>
> -- Many drivers wrap drm_gem_fb_create() only to check for valid formats. For
> - atomic drivers we could check for valid formats by calling
> - drm_plane_check_pixel_format() against all planes, and pass if any plane
> - supports the format. For non-atomic that's not possible since like the format
> - list for the primary plane is fake and we'd therefor reject valid formats.
> +- Need to switch to drm_gem_fb_create(), as now framebuffer_check() checks for
> + valid formats for atomic drivers.
> +
> +- Add an addfb format validation for non-atomic drivers.
>
> - Many drivers subclass drm_framebuffer, we'd need a embedding compatible
> version of the varios drm_gem_fb_create functions. Maybe called
> diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> index aff3746dedfb..605642bf3650 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -280,6 +280,14 @@ static int framebuffer_check(struct drm_device *dev,
> }
> }
>
> + /* Verify that the modifier is supported. */
> + if (drm_drv_uses_atomic_modeset(dev) &&
> + !drm_any_plane_has_format(dev, r->pixel_format, r->modifier[0])) {
> + drm_dbg_kms(dev, "Unsupported pixel format %p4cc / modifier 0x%llx\n",
> + &r->pixel_format, r->modifier[0]);
> + return -EINVAL;
> + }
Like I said this is still wrong for the !modifiers case.
> +
> return 0;
> }
>
> --
> 2.39.0
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2023-01-13 13:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-13 11:27 [PATCH v2 0/3] Check for valid framebuffer's format Maíra Canal
2023-01-13 11:27 ` [PATCH v2 1/3] drm/framebuffer: Check for valid formats Maíra Canal
2023-01-13 13:06 ` Ville Syrjälä [this message]
2023-01-13 13:06 ` Ville Syrjälä
2023-01-13 11:27 ` [PATCH v2 2/3] drm/amdgpu: Remove redundant framebuffer format check Maíra Canal
2023-01-13 11:27 ` [PATCH v2 3/3] drm/vmwgfx: " Maíra Canal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y8FXWvEhO7GCRKVJ@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=andrealmeid@igalia.com \
--cc=christian.koenig@amd.com \
--cc=contact@emersion.fr \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-graphics-maintainer@vmware.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mcanal@igalia.com \
--cc=mripard@kernel.org \
--cc=mwen@igalia.com \
--cc=robdclark@gmail.com \
--cc=tzimmermann@suse.de \
--cc=zackr@vmware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.