Re: [LTP] [PATCH] io_submit: uninitialized iocb may not return -EINVAL

Jan Stancek
2012-03-15T07:48:38Z

----- Original Message -----
> From: "Wanlong Gao" <gaowanlong@cn.fujitsu.com>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: ltp-list@lists.sourceforge.net, "Jeffrey Burke" <jburke@redhat.com>
> Sent: Thursday, March 15, 2012 2:09:48 AM
> Subject: Re: [LTP] [PATCH] io_submit: uninitialized iocb may not return -EINVAL
>
> Hi Jan,
>
> >
> > Testcase 1.3 - EINVAL: uninitialized iocb
> > is about submitting uninitialized iocb structure.
> >
> > Test is expecting to get -EINVAL, but other values are also
> > possible as uninitialized struct can contain any values.
> >
> > For example following data fails with -EBADF:
> > --- snip ---
> > unsigned char bad_iocb[64] = {
> > 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> > 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> > 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x84, 0xa5,
> > 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> > 0x00, 0x00, 0x0f, 0xff, 0xe0, 0x10, 0x0c, 0x30,
> > 0x00, 0x00, 0x0f, 0xff, 0xe0, 0x10, 0x0c, 0x40,
> > 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> > 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
> > memcpy(&iocb, bad_iocb, sizeof(iocb));
> > iocbs[0] = &iocb;
> > TEST(io_submit(ctx, 1, iocbs));
> > check_result(-EINVAL, TEST_RETURN);
> > --- snip ---
> >
> > This patch accepts also few other errno codes as valid return
> > value.
> >
> > Signed-off-by: Jan Stancek <jstancek@redhat.com>
> > ---
> > testcases/kernel/syscalls/io_submit/io_submit01.c | 16
> > +++++++++++++++-
> > 1 files changed, 15 insertions(+), 1 deletions(-)
> >
> >
> >
> > 0001-io_submit-uninitialized-iocb-may-not-return-EINVAL.patch
> >
> >
> > diff --git a/testcases/kernel/syscalls/io_submit/io_submit01.c
> > b/testcases/kernel/syscalls/io_submit/io_submit01.c
> > index da15aa0..3983fa4 100644
> > --- a/testcases/kernel/syscalls/io_submit/io_submit01.c
> > +++ b/testcases/kernel/syscalls/io_submit/io_submit01.c
> > @@ -126,7 +126,21 @@ int main(int argc, char *argv[])
> > /* 1.3 - EINVAL: uninitialized iocb */
> > iocbs[0] = &iocb;
> > TEST(io_submit(ctx, 1, iocbs));
> > - check_result(-EINVAL, TEST_RETURN);
> > + switch(TEST_RETURN) {
> > + case -EINVAL:
> > + case -EBADF:
> > + case -EFAULT:
> > + case -EPERM:
>
>
> I don't think io_submit(2) can return -EPERM.
>
> Do you think so?

I was trying all sorts of random data and I remember seeing once "-1".
I'm failing to reproduce it today, so I could be wrong. If I fail to find
data that gives -EPERM, I'll remove it in v2.

Regards,
Jan

>
> Thanks,
> Wanlong Gao
>

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here