From: "Christian König" <christian.koenig@amd.com>
To: Danilo Krummrich <dakr@kernel.org>,
Philipp Stanner <pstanner@redhat.com>
Cc: Luben Tuikov <ltuikov89@gmail.com>,
Matthew Brost <matthew.brost@intel.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] drm/sched: Fix UB pointer dereference
Date: Tue, 27 Aug 2024 11:00:32 +0200 [thread overview]
Message-ID: <9ba7f944-52d1-4937-80c7-a03bc0c5b1d5@amd.com> (raw)
In-Reply-To: <c443e90d-6907-4a02-bab4-c1943f021a8c@kernel.org>
Am 27.08.24 um 10:39 schrieb Danilo Krummrich:
> On 8/27/24 9:45 AM, Philipp Stanner wrote:
>> In drm_sched_job_init(), commit 56e449603f0a ("drm/sched: Convert the
>> GPU scheduler to variable number of run-queues") implemented a call to
>> drm_err(), which uses the job's scheduler pointer as a parameter.
>> job->sched, however, is not yet valid as it gets set by
>> drm_sched_job_arm(), which is always called after drm_sched_job_init().
>>
>> Since the scheduler code has no control over how the API-User has
>> allocated or set 'job', the pointer's dereference is undefined behavior.
>>
>> Fix the UB by replacing drm_err() with pr_err().
>>
>> Cc: <stable@vger.kernel.org> # 6.7+
>> Fixes: 56e449603f0a ("drm/sched: Convert the GPU scheduler to
>> variable number of run-queues")
>> Reported-by: Danilo Krummrich <dakr@redhat.com>
>> Closes:
>> https://lore.kernel.org/lkml/20231108022716.15250-1-dakr@redhat.com/
>> Signed-off-by: Philipp Stanner <pstanner@redhat.com>
>> ---
>> drivers/gpu/drm/scheduler/sched_main.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/scheduler/sched_main.c
>> b/drivers/gpu/drm/scheduler/sched_main.c
>> index 7e90c9f95611..356c30fa24a8 100644
>> --- a/drivers/gpu/drm/scheduler/sched_main.c
>> +++ b/drivers/gpu/drm/scheduler/sched_main.c
>> @@ -797,7 +797,7 @@ int drm_sched_job_init(struct drm_sched_job *job,
>> * or worse--a blank screen--leave a trail in the
>> * logs, so this can be debugged easier.
>> */
>> - drm_err(job->sched, "%s: entity has no rq!\n", __func__);
>> + pr_err("*ERROR* %s: entity has no rq!\n", __func__);
>
> I don't think the "*ERROR*" string is necessary, it's pr_err() already.
Good point. I will remove that and also add a comment why drm_err won't
work here before pushing it to drm-misc-fixes.
Thanks,
Christian.
>
> Otherwise,
>
> Acked-by: Danilo Krummrich <dakr@kernel.org>
>
>> return -ENOENT;
>> }
next prev parent reply other threads:[~2024-08-27 9:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 7:45 Philipp Stanner
2024-08-27 7:48 ` Christian König
2024-08-27 8:39 ` Danilo Krummrich
2024-08-27 9:00 ` Christian König [this message]
2024-08-27 9:59 ` Philipp Stanner
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=9ba7f944-52d1-4937-80c7-a03bc0c5b1d5@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=dakr@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ltuikov89@gmail.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=mripard@kernel.org \
--cc=pstanner@redhat.com \
--cc=stable@vger.kernel.org \
--cc=tzimmermann@suse.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®