public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] io_submit: uninitialized iocb may not return -EINVAL
@ 2012-03-15  9:15 Jan Stancek
  2012-03-15  9:17 ` Caspar Zhang
  2012-03-15  9:28 ` Wanlong Gao
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Stancek @ 2012-03-15  9:15 UTC (permalink / raw)
  To: ltp-list; +Cc: Jeffrey Burke

[-- Attachment #1: Type: text/plain, Size: 1119 bytes --]


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 |   15 ++++++++++++++-
  1 files changed, 14 insertions(+), 1 deletions(-)



[-- Attachment #2: 0001-io_submit-uninitialized-iocb-may-not-return-EINVAL.patch --]
[-- Type: text/x-patch, Size: 954 bytes --]

diff --git a/testcases/kernel/syscalls/io_submit/io_submit01.c b/testcases/kernel/syscalls/io_submit/io_submit01.c
index da15aa0..2494863 100644
--- a/testcases/kernel/syscalls/io_submit/io_submit01.c
+++ b/testcases/kernel/syscalls/io_submit/io_submit01.c
@@ -126,7 +126,20 @@ 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:
+			tst_resm(TPASS, "expected failure - "
+					"returned value = %ld : %s",
+					TEST_RETURN, strerror(-1 * TEST_RETURN));
+			break;
+		default:
+			tst_resm(TFAIL, "unexpected failure - "
+					"returned value = %ld : %s, "
+					"expected one of -EINVAL, -EBADF, -EFAULT",
+					TEST_RETURN, strerror(-1 * TEST_RETURN));
+		}
 
 		/* 2 - EFAULT: iocb points to invalid data */
 		TEST(io_submit(ctx, 1, (struct iocb **)-1));


[-- Attachment #3: Type: text/plain, Size: 191 bytes --]

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH v2] io_submit: uninitialized iocb may not return -EINVAL
  2012-03-15  9:15 [LTP] [PATCH v2] io_submit: uninitialized iocb may not return -EINVAL Jan Stancek
@ 2012-03-15  9:17 ` Caspar Zhang
  2012-03-15  9:28 ` Wanlong Gao
  1 sibling, 0 replies; 3+ messages in thread
From: Caspar Zhang @ 2012-03-15  9:17 UTC (permalink / raw)
  To: ltp-list

On 03/15/2012 05:15 PM, Jan Stancek wrote:
> 
> 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>

Reviewed-by: Caspar Zhang <caspar@casparzhang.com>

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH v2] io_submit: uninitialized iocb may not return -EINVAL
  2012-03-15  9:15 [LTP] [PATCH v2] io_submit: uninitialized iocb may not return -EINVAL Jan Stancek
  2012-03-15  9:17 ` Caspar Zhang
@ 2012-03-15  9:28 ` Wanlong Gao
  1 sibling, 0 replies; 3+ messages in thread
From: Wanlong Gao @ 2012-03-15  9:28 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp-list, Jeffrey Burke

On 03/15/2012 05:15 PM, Jan Stancek wrote:

> 
> 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>


Thanks Jan, I will take this.

Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

> ---
>  testcases/kernel/syscalls/io_submit/io_submit01.c |   15 ++++++++++++++-
>  1 files changed, 14 insertions(+), 1 deletions(-)
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here 
> http://p.sf.net/sfu/sfd2d-msazure
> 
> 
> 
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list



------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-15  9:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-15  9:15 [LTP] [PATCH v2] io_submit: uninitialized iocb may not return -EINVAL Jan Stancek
2012-03-15  9:17 ` Caspar Zhang
2012-03-15  9:28 ` Wanlong Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox