mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel.daenzer@mailbox.org>
To: Julian Orth <ju.orth@gmail.com>
Cc: "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
	"Rob Clark" <robin.clark@oss.qualcomm.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/syncobj: Fix handle <-> fd ioctls with dirty stack
Date: Wed, 4 Mar 2026 12:47:17 +0100	[thread overview]
Message-ID: <0847752c-39cb-4233-8e07-8e1325c196cc@mailbox.org> (raw)
In-Reply-To: <CAHijbEUSFA3ptTNZ_YuOLgc44Px4CjAaa9x6DDjJktRCKjj+Dw@mail.gmail.com>

On 3/4/26 12:25, Julian Orth wrote:
> On Wed, Mar 4, 2026 at 12:15 PM Michel Dänzer
> <michel.daenzer@mailbox.org> wrote:
>> On 3/3/26 20:12, Julian Orth wrote:
>>> On Tue, Mar 3, 2026 at 7:53 PM Michel Dänzer <michel.daenzer@mailbox.org> wrote:
>>>> On 3/3/26 18:44, Maarten Lankhorst wrote:
>>>>>
>>>>> You don't even need to use memset, this would work too:
>>>>>
>>>>> struct drm_syncobj_handle args = {
>>>>>       .flags = 0
>>>>> };
>>>>
>>>> TL;DR: This method isn't 100% safe either.
>>>>
>>>> It won't initialize any padding which isn't covered by any struct field. We try to avoid that and have explicit padding fields instead, mistakes may happen though, and in theory such padding could later be used for a new field.
>>>
>>> I don't think this is workable.
>>
>> libdrm begs to differ. It shows that it's not only workable but really easy. There's no reason for doing it any other way.
> 
> Using memset to initialize padding bytes between fields is workable.
> Having the kernel add checks for this for existing ioctls is not
> workable because it would break usespace that doesn't do this.

As discussed in this thread, memset is also required for when the size of an ioctl struct is extended, even if there is no such padding.


> Which is every rust program out there as far as I can tell.

That's surprising. Surely there must be some unsafe code involved which allows uninitialized memory to be passed to ioctl()?


> I'm not aware of any ioctls that actually have padding bytes between
> fields so this discussion is mostly academic.

I covered that in my previous post quoted above.


-- 
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast

  reply	other threads:[~2026-03-04 11:47 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-01 12:34 Julian Orth
2026-03-02 11:27 ` Christian König
2026-03-02 11:54   ` Dmitry Osipenko
2026-03-03 11:17 ` Michel Dänzer
2026-03-03 11:23   ` Julian Orth
2026-03-03 11:38     ` Michel Dänzer
2026-03-03 11:41       ` Julian Orth
2026-03-03 14:53 ` Maarten Lankhorst
2026-03-03 14:59   ` Christian König
2026-03-03 15:15     ` Maarten Lankhorst
2026-03-03 15:21       ` Julian Orth
2026-03-03 17:02         ` Michel Dänzer
2026-03-03 15:29     ` Michel Dänzer
2026-03-03 15:36       ` Julian Orth
2026-03-03 16:40         ` Maarten Lankhorst
2026-03-03 16:54           ` Julian Orth
2026-03-03 17:04             ` Michel Dänzer
2026-03-03 17:11               ` Julian Orth
2026-03-03 17:18                 ` Michel Dänzer
2026-03-03 17:30                   ` Julian Orth
2026-03-03 17:44                     ` Maarten Lankhorst
2026-03-03 18:53                       ` Michel Dänzer
2026-03-03 19:12                         ` Julian Orth
2026-03-04  9:57                           ` Maarten Lankhorst
2026-03-04 11:15                           ` Michel Dänzer
2026-03-04 11:25                             ` Julian Orth
2026-03-04 11:47                               ` Michel Dänzer [this message]
2026-03-04 12:32                                 ` Julian Orth
2026-03-04 14:29                                   ` Michel Dänzer
2026-03-04 14:35                                     ` Julian Orth
2026-03-05  9:47                               ` Maarten Lankhorst
2026-03-03 17:40                   ` Maarten Lankhorst
2026-03-03 17:44                     ` Julian Orth
2026-03-03 19:58                       ` David Laight
2026-03-04 10:35                         ` Maarten Lankhorst
2026-03-03 17:05             ` Maarten Lankhorst

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=0847752c-39cb-4233-8e07-8e1325c196cc@mailbox.org \
    --to=michel.daenzer@mailbox.org \
    --cc=airlied@gmail.com \
    --cc=christian.koenig@amd.com \
    --cc=dmitry.osipenko@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ju.orth@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=simona@ffwll.ch \
    --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®