[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a1HGEUkeOpSZQ8r4p-rD7vn3_F1w2cjKdTHPAGJJWqWBg@mail.gmail.com>
Date: Wed, 4 Oct 2017 12:23:41 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Hans de Goede <hdegoede@...hat.com>,
Christoph Hellwig <hch@...radead.org>,
Michael Thayer <michael.thayer@...cle.com>,
"Knut St . Osmundsen" <knut.osmundsen@...cle.com>,
Larry Finger <Larry.Finger@...inger.net>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] virt: Add vboxguest driver for Virtual Box Guest integration
On Wed, Oct 4, 2017 at 12:11 PM, Greg Kroah-Hartman
<gregkh@...uxfoundation.org> wrote:
> On Wed, Oct 04, 2017 at 11:32:23AM +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 03-10-17 13:41, Hans de Goede wrote:
>>
>> <snip>
>>
>> > > > +#define CHECK_IOCTL_IN(req) \
>> > > > +do { \
>> > > > + if ((req)->Hdr.cbIn != (sizeof((req)->Hdr) + sizeof((req)->u.In)) || \
>> > > > + (req)->Hdr.cbOut != sizeof((req)->Hdr)) \
>> > > > + return -EINVAL; \
>> > > > +} while (0)
>> > >
>> > > Make these things functions instead of macros.
>> >
>> > Turning these into functions is a good idea I will do so for v2.
>>
>> Correction, I forgot that the passed in "req" macro
>> argument has a different type with all the calls, so
>> these cannot be changed into functions because they
>> rely on sizeof on the specific type to do the size
>> checks.
>
> Don't we already have built-in checks for these types of things? Surely
> we don't require each ioctl user in the kernel to do this by
> themselves...
No other driver uses this kind of header for the ioctl structures,
usually we just rely on the ioctl command number to encode the
size, or we copy a fixed length.
Arnd
Powered by blists - more mailing lists