From: Andrzej Kacprowski <andrzej.kacprowski@linux.intel.com>
To: sashiko-reviews@lists.linux.dev
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] accel/ivpu: Add support for getting and setting command queue priority
Date: Wed, 9 Sep 2026 12:06:07 +0200 [thread overview]
Message-ID: <a38fed2b-ad33-447b-84f7-b6020c9b4072@linux.intel.com> (raw)
In-Reply-To: <20260831123327.110C91F00A3D@smtp.kernel.org>
On 31-Aug-26 2:33 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>
> Pre-existing issues:
> - [High] Missing CAP_SYS_NICE or DRM_MASTER check for elevated job priorities (REALTIME / FOCUS), allowing unprivileged users to monopolize the NPU.
> --
>
> commit 57cf0d7005a7761ad6193ea568802164b7fac6db
> Author: Andrzej Kacprowski <andrzej.kacprowski@linux.intel.com>
>
> accel/ivpu: Add support for getting and setting command queue priority
>
> This commit adds a new DRM_IVPU_PARAM_CMDQ_PRIORITY parameter to query and
> update the scheduling priority of an existing command queue. The priority
> can be changed on a queue that already has pending jobs, propagating the
> change to firmware in hardware scheduling mode.
>
>> diff --git a/drivers/accel/ivpu/ivpu_job.c b/drivers/accel/ivpu/ivpu_job.c
>> index ebb2c865b09a0..b3de5dd29d1e8 100644
>> --- a/drivers/accel/ivpu/ivpu_job.c
>> +++ b/drivers/accel/ivpu/ivpu_job.c
>
> [ ... ]
>
>> @@ -1127,6 +1132,86 @@ int ivpu_cmdq_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file
>> return ret;
>> }
>>
>> +static int ivpu_cmdq_priority_args_check(struct ivpu_device *vdev, u32 cmdq_id, u64 priority)
>> +{
>> + if (!ivpu_is_capable(vdev, DRM_IVPU_CAP_CMDQ_SET_PRIORITY)) {
>> + ivpu_dbg(vdev, IOCTL, "Command queue priority not supported\n");
>> + return -ENODEV;
>> + }
>> +
>> + if (cmdq_id < IVPU_CMDQ_MIN_ID || cmdq_id > IVPU_CMDQ_MAX_ID) {
>> + ivpu_dbg(vdev, IOCTL, "Invalid command queue ID %u\n", cmdq_id);
>> + return -EINVAL;
>> + }
>> +
>> + if (priority > DRM_IVPU_JOB_PRIORITY_REALTIME)
>> + return -EINVAL;
>
> [Severity: High]
> This is a pre-existing issue, but is there a missing capability check for
> elevated priorities here?
>
> An unprivileged user who opens the NPU device can call the IVPU_SET_PARAM
> ioctl with DRM_IVPU_PARAM_CMDQ_PRIORITY and set the priority to
> DRM_IVPU_JOB_PRIORITY_REALTIME. Without a CAP_SYS_NICE or DRM_MASTER check,
> could a malicious or buggy application elevate its command queue priority to
> monopolize the hardware and starve other processes?
>
> I notice this same behavior appears to be pre-existing in
> ivpu_cmdq_create_ioctl() as well, where queues can be created with realtime
> priority by any user. Should these priority levels be restricted?
>
The Intel NPU is not a display/graphics device and has no notion of
DRM_MASTER which is typically the display server process.
Using CAP_SYS_NICE has a bit more merit however:
- strict CAP_SYS_NICE check in KMD will break existing use cases
- no other accel drivers use CAP_SYS_NICE
Current strategy is to allow OS level AI runtime to control NPU workload
priority - dynamic priority change was added to
support that use case.
I will take it into consideration for future driver updates, but it
cannot be immediately solved in this patch.
- Andrzej
>> +
>> + return 0;
>> +}
>> +
>> +int ivpu_cmdq_get_priority(struct ivpu_file_priv *file_priv, u32 cmdq_id, u64 *priority)
>> +{
>
> [ ... ]
>
next prev parent reply other threads:[~2026-09-09 10:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 12:16 [PATCH] accel/ivpu: Add support for getting and setting command queue priority Andrzej Kacprowski
2026-08-31 12:33 ` sashiko-bot
2026-09-09 10:06 ` Andrzej Kacprowski [this message]
2026-09-09 10:13 ` Wachowski, Karol
2026-09-11 5:30 ` Wachowski, Karol
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=a38fed2b-ad33-447b-84f7-b6020c9b4072@linux.intel.com \
--to=andrzej.kacprowski@linux.intel.com \
--cc=dri-devel@lists.freedesktop.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.