lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK1hOcN2zvZGhPxRRcoQCv=i-kEOhN2o_gofaRAj+hnFE8uLqg@mail.gmail.com>
Date:	Mon, 9 Mar 2015 16:15:57 +0100
From:	Denys Vlasenko <vda.linux@...glemail.com>
To:	Ingo Molnar <mingo@...nel.org>
Cc:	Denys Vlasenko <dvlasenk@...hat.com>,
	Andy Lutomirski <luto@...capital.net>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Borislav Petkov <bp@...en8.de>,
	"H. Peter Anvin" <hpa@...or.com>, Oleg Nesterov <oleg@...hat.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Alexei Starovoitov <ast@...mgrid.com>,
	Will Drewry <wad@...omium.org>,
	Kees Cook <keescook@...omium.org>, X86 ML <x86@...nel.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2] move offsetofend() from vfio.h to stddef.h

On Mon, Mar 9, 2015 at 3:58 PM, Ingo Molnar <mingo@...nel.org> wrote:
>> -/**
>> - * offsetofend(TYPE, MEMBER)
>> - *
>> - * @TYPE: The type of the structure
>> - * @MEMBER: The member within the structure to get the end offset of
>> - *
>> - * Simple helper macro for dealing with variable sized structures passed
>> - * from user space.  This allows us to easily determine if the provided
>> - * structure is sized to include various fields.
>> - */
>> -#define offsetofend(TYPE, MEMBER) \
>> -     (offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER))
>
> So I like it, and because it is not particularly trivial when to use
> this primitive it was explained nicely in a description in the vfio.h
> version.
>
> But you lost that nice description during the code move!!

That description was clearly specific to how that macro is used in
drivers/vfio/*.c, along the lines of

                minsz = offsetofend(struct vfio_eeh_pe_op, op);
                if (copy_from_user(&op, (void __user *)arg, minsz))
                        return -EFAULT;
                if (op.argsz < minsz || op.flags)
                        return -EINVAL;

But the macro is generic, it has many other uses besides this one.

Nevertheless, I can resend a version where comment survives if you want...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ