All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] fix keyctl01 revoke argument on s390x
@ 2010-10-26  9:02 Caspar Zhang
  2010-10-26  9:29 ` Garrett Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Caspar Zhang @ 2010-10-26  9:02 UTC (permalink / raw)
  To: LTP List

From 1101aa2287f761df5cfab29806baf49fadd80c34 Mon Sep 17 00:00:00 2001
From: Caspar Zhang <casparant@gmail.com>
Date: Tue, 26 Oct 2010 16:54:13 +0800
Subject: [PATCH] fix keyctl revoke argument

add some codes to find an unused id instead of
using #define directly.

Signed-off-by: Caspar Zhang <czhang@redhat.com>

---
 testcases/kernel/syscalls/keyctl/keyctl01.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/keyctl/keyctl01.c b/testcases/kernel/syscalls/keyctl/keyctl01.c
index 292e573..57f334f 100644
--- a/testcases/kernel/syscalls/keyctl/keyctl01.c
+++ b/testcases/kernel/syscalls/keyctl/keyctl01.c
@@ -40,6 +40,7 @@
 
 #include <stdio.h>
 #include <errno.h>
+#include <stdint.h>
 #include <linux/keyctl.h>
 /* Harness Specific Include Files. */
 #include "test.h"
@@ -110,6 +111,7 @@ void setup() {
 int main(int ac, char **av) {
 	int ret;
 	int lc;		/* loop counter */
+	int i, nonexist_key;
 	char *msg;	/* message returned from parse_opts */
 
 	/* parse standard options */
@@ -126,7 +128,7 @@ int main(int ac, char **av) {
 		Tst_count = 0;
 
 		for (testno = 1; testno < TST_TOTAL; ++testno) {
-	
+
 			/* Call keyctl() and ask for a keyring's ID. */
 			ret = syscall(__NR_keyctl, KEYCTL_GET_KEYRING_ID,
 					KEY_SPEC_USER_SESSION_KEYRING);
@@ -136,8 +138,17 @@ int main(int ac, char **av) {
 		 		tst_resm(TFAIL | TERRNO, "KEYCTL_GET_KEYRING_ID");
 			}
 
+			/* find a non-existed key */
+			for (i = INT32_MAX; i > -INT32_MAX; --i)
+			{
+				ret = syscall(__NR_keyctl, KEYCTL_READ, i);
+				if (ret == -1 && errno == ENOKEY)
+					break;
+			}
+			nonexist_key = i;
+
 			/* Call keyctl. */
-			ret = syscall(__NR_keyctl, KEYCTL_REVOKE, "MyKey");
+			ret = syscall(__NR_keyctl, KEYCTL_REVOKE, nonexist_key);
 			if (ret != -1) {
 				tst_resm(TFAIL | TERRNO, "KEYCTL_REVOKE succeeded unexpectly");
 			} else {
-- 
1.7.3.1

-- 
Quality Assurance Associate (Kernel) in
Red Hat Software (Beijing) Co., R&D Branch

TEL: +86-10-62608150
WEB: http://www.redhat.com/

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
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] fix keyctl01 revoke argument on s390x
  2010-10-26  9:02 [LTP] [PATCH v2] fix keyctl01 revoke argument on s390x Caspar Zhang
@ 2010-10-26  9:29 ` Garrett Cooper
  2010-10-26  9:30   ` Garrett Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Garrett Cooper @ 2010-10-26  9:29 UTC (permalink / raw)
  To: Caspar Zhang; +Cc: LTP List

On Tue, Oct 26, 2010 at 2:02 AM, Caspar Zhang <czhang@redhat.com> wrote:
> >From 1101aa2287f761df5cfab29806baf49fadd80c34 Mon Sep 17 00:00:00 2001
> From: Caspar Zhang <casparant@gmail.com>
> Date: Tue, 26 Oct 2010 16:54:13 +0800
> Subject: [PATCH] fix keyctl revoke argument
>
> add some codes to find an unused id instead of
> using #define directly.
>
> Signed-off-by: Caspar Zhang <czhang@redhat.com>
>
> ---
>  testcases/kernel/syscalls/keyctl/keyctl01.c |   15 +++++++++++++--
>  1 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/keyctl/keyctl01.c b/testcases/kernel/syscalls/keyctl/keyctl01.c
> index 292e573..57f334f 100644
> --- a/testcases/kernel/syscalls/keyctl/keyctl01.c
> +++ b/testcases/kernel/syscalls/keyctl/keyctl01.c
> @@ -40,6 +40,7 @@
>
>  #include <stdio.h>
>  #include <errno.h>
> +#include <stdint.h>
>  #include <linux/keyctl.h>
>  /* Harness Specific Include Files. */
>  #include "test.h"
> @@ -110,6 +111,7 @@ void setup() {
>  int main(int ac, char **av) {
>        int ret;
>        int lc;         /* loop counter */
> +       int i, nonexist_key;
>        char *msg;      /* message returned from parse_opts */
>
>        /* parse standard options */
> @@ -126,7 +128,7 @@ int main(int ac, char **av) {
>                Tst_count = 0;
>
>                for (testno = 1; testno < TST_TOTAL; ++testno) {
> -
> +
>                        /* Call keyctl() and ask for a keyring's ID. */
>                        ret = syscall(__NR_keyctl, KEYCTL_GET_KEYRING_ID,
>                                        KEY_SPEC_USER_SESSION_KEYRING);
> @@ -136,8 +138,17 @@ int main(int ac, char **av) {
>                                tst_resm(TFAIL | TERRNO, "KEYCTL_GET_KEYRING_ID");
>                        }
>
> +                       /* find a non-existed key */
> +                       for (i = INT32_MAX; i > -INT32_MAX; --i)

INT32_MIN is actually preferred over INT32_MAX as that would be an
invalid value (integers are represented in two's complement).

> +                       {
> +                               ret = syscall(__NR_keyctl, KEYCTL_READ, i);
> +                               if (ret == -1 && errno == ENOKEY)
> +                                       break;
> +                       }
> +                       nonexist_key = i;

This is ok, but you could actually get rid of i entirely and just
decrement nonexist_key :).

>                        /* Call keyctl. */
> -                       ret = syscall(__NR_keyctl, KEYCTL_REVOKE, "MyKey");
> +                       ret = syscall(__NR_keyctl, KEYCTL_REVOKE, nonexist_key);
>                        if (ret != -1) {
>                                tst_resm(TFAIL | TERRNO, "KEYCTL_REVOKE succeeded unexpectly");
>                        } else {

Otherwise, the trivial patch looks ok :).
Cheers,
-Garrett

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
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] fix keyctl01 revoke argument on s390x
  2010-10-26  9:29 ` Garrett Cooper
@ 2010-10-26  9:30   ` Garrett Cooper
  0 siblings, 0 replies; 3+ messages in thread
From: Garrett Cooper @ 2010-10-26  9:30 UTC (permalink / raw)
  To: Caspar Zhang; +Cc: LTP List

On Tue, Oct 26, 2010 at 2:29 AM, Garrett Cooper <yanegomi@gmail.com> wrote:
> On Tue, Oct 26, 2010 at 2:02 AM, Caspar Zhang <czhang@redhat.com> wrote:
>> >From 1101aa2287f761df5cfab29806baf49fadd80c34 Mon Sep 17 00:00:00 2001
>> From: Caspar Zhang <casparant@gmail.com>
>> Date: Tue, 26 Oct 2010 16:54:13 +0800
>> Subject: [PATCH] fix keyctl revoke argument
>>
>> add some codes to find an unused id instead of
>> using #define directly.
>>
>> Signed-off-by: Caspar Zhang <czhang@redhat.com>
>>
>> ---
>>  testcases/kernel/syscalls/keyctl/keyctl01.c |   15 +++++++++++++--
>>  1 files changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/testcases/kernel/syscalls/keyctl/keyctl01.c b/testcases/kernel/syscalls/keyctl/keyctl01.c
>> index 292e573..57f334f 100644
>> --- a/testcases/kernel/syscalls/keyctl/keyctl01.c
>> +++ b/testcases/kernel/syscalls/keyctl/keyctl01.c
>> @@ -40,6 +40,7 @@
>>
>>  #include <stdio.h>
>>  #include <errno.h>
>> +#include <stdint.h>
>>  #include <linux/keyctl.h>
>>  /* Harness Specific Include Files. */
>>  #include "test.h"
>> @@ -110,6 +111,7 @@ void setup() {
>>  int main(int ac, char **av) {
>>        int ret;
>>        int lc;         /* loop counter */
>> +       int i, nonexist_key;
>>        char *msg;      /* message returned from parse_opts */
>>
>>        /* parse standard options */
>> @@ -126,7 +128,7 @@ int main(int ac, char **av) {
>>                Tst_count = 0;
>>
>>                for (testno = 1; testno < TST_TOTAL; ++testno) {
>> -
>> +
>>                        /* Call keyctl() and ask for a keyring's ID. */
>>                        ret = syscall(__NR_keyctl, KEYCTL_GET_KEYRING_ID,
>>                                        KEY_SPEC_USER_SESSION_KEYRING);
>> @@ -136,8 +138,17 @@ int main(int ac, char **av) {
>>                                tst_resm(TFAIL | TERRNO, "KEYCTL_GET_KEYRING_ID");
>>                        }
>>
>> +                       /* find a non-existed key */
>> +                       for (i = INT32_MAX; i > -INT32_MAX; --i)
>
> INT32_MIN is actually preferred over INT32_MAX as that would be an
> invalid value (integers are represented in two's complement).

Sorry, misstated this -- the negative value would be correct. The
positive value would be wrong.

>> +                       {
>> +                               ret = syscall(__NR_keyctl, KEYCTL_READ, i);
>> +                               if (ret == -1 && errno == ENOKEY)
>> +                                       break;
>> +                       }
>> +                       nonexist_key = i;
>
> This is ok, but you could actually get rid of i entirely and just
> decrement nonexist_key :).
>
>>                        /* Call keyctl. */
>> -                       ret = syscall(__NR_keyctl, KEYCTL_REVOKE, "MyKey");
>> +                       ret = syscall(__NR_keyctl, KEYCTL_REVOKE, nonexist_key);
>>                        if (ret != -1) {
>>                                tst_resm(TFAIL | TERRNO, "KEYCTL_REVOKE succeeded unexpectly");
>>                        } else {
>
> Otherwise, the trivial patch looks ok :).

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
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:[~2010-10-26  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-26  9:02 [LTP] [PATCH v2] fix keyctl01 revoke argument on s390x Caspar Zhang
2010-10-26  9:29 ` Garrett Cooper
2010-10-26  9:30   ` Garrett Cooper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.