From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751945AbdJDKa2 (ORCPT ); Wed, 4 Oct 2017 06:30:28 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36518 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751114AbdJDKa0 (ORCPT ); Wed, 4 Oct 2017 06:30:26 -0400 Date: Wed, 4 Oct 2017 12:30:34 +0200 From: Greg Kroah-Hartman To: Arnd Bergmann Cc: Hans de Goede , Christoph Hellwig , Michael Thayer , "Knut St . Osmundsen" , Larry Finger , Linux Kernel Mailing List Subject: Re: [PATCH] virt: Add vboxguest driver for Virtual Box Guest integration Message-ID: <20171004103034.GA30246@kroah.com> References: <20171003092115.11341-1-hdegoede@redhat.com> <20171003092115.11341-2-hdegoede@redhat.com> <20171003100449.GA5491@infradead.org> <20171004101148.GA30855@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 04, 2017 at 12:23:41PM +0200, Arnd Bergmann wrote: > On Wed, Oct 4, 2017 at 12:11 PM, Greg Kroah-Hartman > 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: > >> > >> > >> > >> > > > +#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. Then why can't we do the same thing here as well?