mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Eugenio Pérez" <eperezma@redhat.com>, "Arnd Bergmann" <arnd@kernel.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
	"Xie Yongji" <xieyongji@bytedance.com>,
	"Anders Roxell" <anders.roxell@linaro.org>,
	"Marco Crivellari" <marco.crivellari@suse.com>,
	"Ashwini Sahu" <ashwini@wisig.com>,
	virtualization@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] vduse: avoid adding implicit padding
Date: Mon, 02 Feb 2026 13:06:54 +0100	[thread overview]
Message-ID: <2941167c-822c-4f37-a3ce-803bb94ab566@app.fastmail.com> (raw)
In-Reply-To: <CAJaqyWeLYCTmOAqOPuLZWaJWGn8Tg3uf4DtYTZYpvZUCXxxYzg@mail.gmail.com>

On Mon, Feb 2, 2026, at 12:50, Eugenio Perez Martin wrote:
> On Mon, Feb 2, 2026 at 12:28 PM Eugenio Perez Martin <eperezma@redhat.com> wrote:
>> >                 ret = -EFAULT;
>> > -               if (cmd == VDUSE_IOTLB_GET_FD2) {
>> > -                       if (copy_from_user(&entry, argp, sizeof(entry)))
>> > -                               break;
>> > -               } else {
>> > -                       if (copy_from_user(&entry.v1, argp,
>> > -                                          sizeof(entry.v1)))
>> > -                               break;
>> > -               }
>> > +               if (copy_from_user(&entry, argp, _IOC_SIZE(cmd)))
>>
>> I did not know about _IOC_SIZE and I like how it reduces the complexity, thanks!
>>
>> As a proposal, maybe we can add MIN(_IOC_SIZE, sizeof(entry)) ? Not
>> sure if it is too much boilerplate for nothing as the compiler should
>> make the code identical and the uapi ioctl part should never change.
>> But it seems to me future changes to the code are better tied with the
>> MIN.
>> I'm ok with not including MIN() either way.

I think it's more readable without the MIN(), but I don't mind
adding it either.

>> >   */
>> >  struct vduse_iotlb_entry_v2 {
>> > -       struct vduse_iotlb_entry v1;
>> > +       __u64 offset;
>> > +       __u64 start;
>> > +       __u64 last;
>> > +       __u8 perm;
>> > +       __u8 padding[7];
>> >         __u32 asid;
>> > -       __u32 reserved[12];
>> > +       __u32 reserved[11];
>
> (I hit "Send" too early).
>
> We could make this padding[3] so reserved keeps being [12]. This way
> the struct members keep the same alignment between the commits. Not
> super important as there should not be a lot of users of this right
> now, we're just introducing it.

I think that is too risky, as it would overlay 'asid' on top of
previously uninitialized padding fields coming from userspace
on most architectures. Since there was previously no is_mem_zero()
check for the padding, I don't think it should be reused at all.

    Arnd

  reply	other threads:[~2026-02-02 12:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-02  9:59 Arnd Bergmann
2026-02-02  9:59 ` [PATCH 2/2] vduse: fix compat handling for VDUSE_IOTLB_GET_FD/VDUSE_VQ_GET_INFO Arnd Bergmann
2026-02-02 11:34   ` Eugenio Perez Martin
2026-02-02 11:59     ` Arnd Bergmann
2026-02-02 16:45       ` Michael S. Tsirkin
2026-02-02 22:54         ` Arnd Bergmann
2026-02-03 10:35           ` Michael S. Tsirkin
2026-02-03 14:13             ` Eugenio Perez Martin
2026-02-03 14:41               ` Arnd Bergmann
2026-02-03 15:03                 ` Eugenio Perez Martin
2026-02-02 11:28 ` [PATCH 1/2] vduse: avoid adding implicit padding Eugenio Perez Martin
2026-02-02 11:50   ` Eugenio Perez Martin
2026-02-02 12:06     ` Arnd Bergmann [this message]
2026-02-03  7:00       ` Eugenio Perez Martin

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=2941167c-822c-4f37-a3ce-803bb94ab566@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=anders.roxell@linaro.org \
    --cc=arnd@kernel.org \
    --cc=ashwini@wisig.com \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marco.crivellari@suse.com \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xieyongji@bytedance.com \
    --cc=xuanzhuo@linux.alibaba.com \
    /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®