From: sashiko-bot@kernel.org
To: "Maxime Ripard" <mripard@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 11/13] drm/atomic-uapi: Add DRM_MODE_ATOMIC_RESET flag
Date: Fri, 18 Sep 2026 14:48:38 +0000 [thread overview]
Message-ID: <20260918144838.CED431F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260918-drm-reset-state-flag-v4-11-5ad106370f05@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/atomic: TOCTOU race leading to NULL pointer dereference in DRM_MODE_ATOMIC_RESET
--
commit 03ae8ccf607b3a82a4b17b4343d5b86063dc861c
Author: Sebastian Wick <sebastian.wick@redhat.com>
Date: Fri Sep 18 14:18:00 2026 +0000
drm/atomic-uapi: Add DRM_MODE_ATOMIC_RESET flag
This commit introduces the DRM_MODE_ATOMIC_RESET flag for the atomic ioctl.
When set, it resets all KMS object states to their defaults by dynamically
allocating and setting default states before applying user properties.
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index 1eebcf6f5e05b..237c7ff823523 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
[ ... ]
> @@ -1688,6 +1695,17 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
> fence_state = NULL;
> num_fences = 0;
>
> + if (arg->flags & DRM_MODE_ATOMIC_RESET) {
> + if (!drm_atomic_implements_create_state(dev)) {
> + ret = -EOPNOTSUPP;
> + goto out;
> + }
> +
> + ret = drm_atomic_commit_fill_with_defaults(state);
[Severity: High]
Could this lockless check introduce a Time-Of-Check to Time-Of-Use (TOCTOU) race
condition?
The initial validation in drm_atomic_implements_create_state() iterates over the
dynamic connector list without locks. If a hardware hotplug event (such as DP
MST) occurs right after this check returns true, the MST workqueue might
asynchronously add a new connector that lacks the .atomic_create_state hook
(like mst_connector_funcs) without taking connection_mutex.
When drm_atomic_commit_fill_with_defaults(state) is subsequently called, it
will encounter the newly added connector and unconditionally dereference the
missing function pointer:
drivers/gpu/drm/drm_atomic.c:drm_atomic_commit_fill_with_defaults() {
...
drm_for_each_connector_iter(connector, &conn_iter) {
...
connector_state = connector->funcs->atomic_create_state(connector);
...
}
}
Is there a way to protect the connector list during validation, or safely handle
the missing hook during the fill operation to prevent a NULL pointer
dereference?
> + if (ret)
> + goto out;
> + }
> +
> for (i = 0; i < arg->count_objs; i++) {
> uint32_t obj_id, count_props;
> struct drm_mode_object *obj;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260918-drm-reset-state-flag-v4-0-5ad106370f05@kernel.org?part=11
next prev parent reply other threads:[~2026-09-18 14:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 14:17 [PATCH v4 00/13] drm: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 01/13] drm/atomic: Switch to krealloc_array() in drm_atomic_get_private_obj_state() Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 02/13] drm/atomic: Use __GFP_ZERO instead of explicit memset " Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 03/13] drm/atomic: Use __GFP_ZERO instead of explicit memset in drm_atomic_get_connector_state() Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 04/13] drm/atomic: Create function to insert CRTC state into a commit Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 05/13] drm/atomic: Create function to insert plane " Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 06/13] drm/atomic: Create function to insert colorop " Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 07/13] drm/atomic: Create function to insert private obj " Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 08/13] drm/atomic: Create function to insert connector " Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 09/13] drm/atomic: Add drm_atomic_implements_create_state() helper Maxime Ripard
2026-09-23 9:19 ` Daniel Stone
2026-09-18 14:17 ` [PATCH v4 10/13] drm/atomic: Allow filling a commit with pristine object states Maxime Ripard
2026-09-18 14:47 ` sashiko-bot
2026-09-18 14:18 ` [PATCH v4 11/13] drm/atomic-uapi: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-09-18 14:48 ` sashiko-bot [this message]
2026-09-18 14:18 ` [PATCH v4 12/13] drm/vkms: Switch container_of helpers to container_of_const Maxime Ripard
2026-09-18 14:18 ` [PATCH v4 13/13] drm/vkms: Add driver-specific plane property for testing Maxime Ripard
2026-09-23 9:48 ` [PATCH v4 00/13] drm: Add DRM_MODE_ATOMIC_RESET flag Daniel Stone
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=20260918144838.CED431F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=mripard@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.