Skip to contentSkip to conversation

fix keyctl01 testcase on s390x systems

PATCH In review Caspar Zhang 2 participants 3 messages Oct 26, 2010 1 message not in the archive

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 fix keyctl01 testcase on s390x systems

In reply to a message not in the archive

Hi all,

on s390x systems, a string like "MyKey" is not a valid argument for keyctl syscall function, I substitute the string by number to make keyctl testcase work on s390x systems.

use "MyKey":

keyctl01    1  TPASS  :  KEYCTL_GET_KEYRING_ID succeeded
keyctl01    2  TFAIL  :  KEYCTL_REVOKE got unexpected errno: errno=EINVAL(22): Invalid argument

use a number:

keyctl01    1  TPASS  :  KEYCTL_GET_KEYRING_ID succeeded
keyctl01    2  TPASS  :  KEYCTL_REVOKE got expected errno: errno=???(126): Required key not available
---
 testcases/kernel/syscalls/keyctl/keyctl01.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/keyctl/keyctl01.c +5 -2
index 292e573..179fcb7 100644
@@ -46,6 +46,9 @@
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
 
+/* define a non-exist key */
+#define NONEXIST_KEY 65535
+
 /* Extern Global Variables */
 extern int Tst_count;	/* counter for tst_xxx routines.	 */
 extern char *TESTDIR;	/* temporary dir created by tst_tmpdir() */
@@ -126,7 +129,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);
@@ -137,7 +140,7 @@ int main(int ac, char **av) {
 			}
 
 			/* 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 {
Signature · 24 lines
1.7.3.1



-- 
/---------------------------------------\
| Name: Caspar Zhang                    |
| Team: Kernel-QE                       |
| Timezone: GMT+0800 (Asia/Shanghai)    |
| IRC: caspar @ #kernel-qe, #eng-china  |
| Phone: +86-10-6260-8150               |
| Cellphone: +86-1381-073-0090          |
\---------------------------------------/

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#2 lore raw
Quoted 11 lines · Caspar Zhang

Hi all,

on s390x systems, a string like "MyKey" is not a valid argument for keyctl syscall function, I substitute the string by number to make keyctl testcase work on s390x systems.

use "MyKey":

keyctl01    1  TPASS  :  KEYCTL_GET_KEYRING_ID succeeded
keyctl01    2  TFAIL  :  KEYCTL_REVOKE got unexpected errno: errno=EINVAL(22): Invalid argument

Quoted 6 lines

use a number:

keyctl01    1  TPASS  :  KEYCTL_GET_KEYRING_ID succeeded
keyctl01    2  TPASS  :  KEYCTL_REVOKE got expected errno: errno=???(126): Required key not available

Looks like a kernel bug to me:
http://manpages.ubuntu.com/manpages/lucid/man3/keyctl_revoke.3.html . EINVAL isn't listed in the manpage.
Thanks,
-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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#3 lore raw
Quoted 14 lines · Garrett Cooper
Quoted 13 lines · Caspar Zhang

Hi all,

on s390x systems, a string like "MyKey" is not a valid argument for keyctl syscall function, I substitute the string by number to make keyctl testcase work on s390x systems.

use "MyKey":

keyctl01    1  TPASS  :  KEYCTL_GET_KEYRING_ID succeeded
keyctl01    2  TFAIL  :  KEYCTL_REVOKE got unexpected errno: errno=EINVAL(22): Invalid argument

use a number:

Quoted 8 lines
Quoted 4 lines

keyctl01    1  TPASS  :  KEYCTL_GET_KEYRING_ID succeeded
keyctl01    2  TPASS  :  KEYCTL_REVOKE got expected errno: errno=???(126): Required key not available

   Looks like a kernel bug to me:
http://manpages.ubuntu.com/manpages/lucid/man3/keyctl_revoke.3.html . EINVAL isn't listed in the manpage.

FWIW though, the testcase is sort of bogus anyhow by sending in a
pointer to a static char buffer instead of int32_t...

(see http://linux.die.net/man/3/keyctl_revoke )

include/linux/key.h:typedef int32_t key_serial_t;
include/linux/key.h: key_serial_t serial; /* key serial number */
include/linux/key.h:extern struct key *key_lookup(key_serial_t id); include/linux/key.h:static inline key_serial_t key_serial(struct key *key)
include/linux/lsm_audit.h: key_serial_t key;
include/linux/syscalls.h: key_serial_t destringid);
include/linux/syscalls.h: key_serial_t destringid);

So there are two bugs here. The most futureproof way to fix this
is to do do linear probing with something like keyctl(KEYCTL_UNLINK,
i) until you find a value i that isn't already allocated; it might be wise to linearly probe backwards from INT32_MAX.
Thanks,
-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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list