[PATCH 2/2] userfaultfd: Add ioctl tests

Dmitry V. Levin ldv at altlinux.org
Tue May 10 11:17:48 UTC 2016


On Tue, May 10, 2016 at 11:16:03AM +0100, Dr. David Alan Gilbert wrote:
> * Dmitry V. Levin (ldv at altlinux.org) wrote:
> > On Fri, May 06, 2016 at 12:08:41PM +0100, Dr. David Alan Gilbert (git) wrote:
[...]
> > > +	struct uffdio_api api_struct;
> > > +	/* With a bad fd */
> > > +	memset(&api_struct, 0, sizeof(api_struct));
> > > +	rc = ioctl(-1, UFFDIO_API, &api_struct);
> > 
> > We have a function called tail_alloc: it allocates memory that ends on the
> > page boundary; pages allocated by tail_alloc are preceded by an unmapped
> > page and followed by another unmapped page.
> > 
> > This method is used in many tests to check that strace parsers do not read
> > beyond the end of structure they are supposed to parse, see e.g.
> > tests/ioctl_v4l2.c.
> > 
> > For example,
> > 	(void) tail_alloc(1); /* initial memory hole just in case */
> > 	struct uffdio_api *api_struct = tail_alloc(sizeof(*api_struct));
> > 	memset(api_struct, 0, sizeof(*api_struct));
> > 	rc = ioctl(-1, UFFDIO_API, api_struct);
> 
> OK, done.  I'm not sure I understand the logic behind the tail_alloc(1)'s -
> I've placed them at the start of each group.

I don't think the test really needs that many memory mapping holes, the
first tail_alloc(1) is probably enough, but they won't harm.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160510/aeb679f9/attachment.bin>


More information about the Strace-devel mailing list