All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yu, Fei" <fei.yu@intel.com>
To: tursulin@ursulin.net
Cc: christian.koenig@amd.com, airlied@gmail.com,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	maarten.lankhorst@linux.intel.com, madhurkumar004@gmail.com,
	mripard@kernel.org, simona@ffwll.ch,
	syzbot+95416f957d84e858b377@syzkaller.appspotmail.com,
	tzimmermann@suse.de
Subject: Re: [PATCH v2] drm/syncobj: Limit the number of handles and use kvmalloc for user-sized arrays
Date: Thu,  5 Nov 2026 16:18:45 +0800	[thread overview]
Message-ID: <20261105081845.1230910-1-fei.yu@intel.com> (raw)
In-Reply-To: <39be711e-cd56-4a04-87ee-6aa2a0b69779@ursulin.net>

From: Fei Yu <fei.yu@intel.com>

On 04/11/2026 10:27, Tvrtko Ursulin wrote:
> On 04/11/2026 09:44, Christian König wrote:
>> On 11/4/26 04:09, Yu, Fei wrote:
>>> +#define DRM_SYNCOBJ_MAX_HANDLES        (INT_MAX / sizeof(struct syncobj_wait_entry))
>>
>> I really wonder if we should put that into the uAPI files?
>>
>> Not that userspace is potentially using it, but this is part of the uAPI
>> and makes sense for documentation purposes.

I thought about that, but I'd prefer to keep it kernel internal, at
least for this fix:

 - The value is derived from the size of a kernel internal struct and
   from the kvmalloc() size limit, so it is not the same on 32-bit and
   64-bit. To put it in drm.h I would have to replace it with a fixed
   number, and that number becomes ABI. We could not easily raise or
   lower it later.

 - Tvrtko's series below avoids most of these allocations. Once that
   lands, the right limit may be different, and an internal define is
   easier to change.

 - The patch has a Fixes tag, and keeping it out of the uAPI header
   keeps the stable backport small.

For documentation, I could send a follow-up that adds a sentence to the
uAPI struct comments, saying that count_handles above an implementation
defined limit is rejected with -EINVAL. That documents the behavior
without fixing a number. Would that work for you?

>> That kvmalloc_array() + the following copy_from_user should probably be
>> replaced by using vmemdup_array_user(). But that should of course be a
>> separate patch.
>
> Btw I tried to do that some time ago:
>
> https://lore.kernel.org/dri-devel/20251106132645.28208-1-tvrtko.ursulin@igalia.com/#t
>
> I have as local, more recent version which applies, but apparently never
> sent it.
>
> Interesting part should also be the other patches from the above linked
> series which avoid allocations altogether for the vast majority of cases.
>
> If there is interest I can re-base and re-send after this is merged.

Thanks, I wasn't aware of that series. I'll leave the
vmemdup_array_user() and points array cleanups to it, so we don't
duplicate work. Happy to test it once this fix is in.

Regards,
Fei

  reply	other threads:[~2026-11-05  8:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  3:09 [PATCH v2] drm/syncobj: Limit the number of handles and use kvmalloc for user-sized arrays Yu, Fei
2026-11-04  9:44 ` Christian König
2026-11-04 10:27   ` Tvrtko Ursulin
2026-11-05  8:18     ` Yu, Fei [this message]
2026-11-05  9:12       ` Tvrtko Ursulin
2026-11-05 12:25         ` Christian König
2026-11-06  5:35           ` Yu, Fei
2026-11-06  9:55             ` Christian König

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=20261105081845.1230910-1-fei.yu@intel.com \
    --to=fei.yu@intel.com \
    --cc=airlied@gmail.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=madhurkumar004@gmail.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=syzbot+95416f957d84e858b377@syzkaller.appspotmail.com \
    --cc=tursulin@ursulin.net \
    --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 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.