Skip to contentSkip to conversation

commands/keyctl01: Fix potential infinite loop

PATCH Superseded Guangwen Feng 2 participants 22 messages May 11, 2017 – Aug 23, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 commands/keyctl01: Fix potential infinite loop

End the loop when max key quota is less than or equal to current key usage, in case some errors happen and result in endless loop.

We expect the test to trigger key quota excess which breaks the loop but it may not happen, so add a TWARN message for this.

---
 testcases/commands/keyctl/keyctl01.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
testcases/commands/keyctl/keyctl01.sh +7 -1
index 076a130..5a97499 100644
@@ -62,15 +62,17 @@ cleanup()
 
 do_test()
 {
+	local quota_excd=0
 	local maxkeysz=$((ORIG_KEYSZ + 100))
 
-	while true
+	while [ $maxkeysz -gt $ORIG_KEYSZ ]
 	do
 		echo $maxkeysz >$PATH_KEYQUOTA
 
 		keyctl request2 user debug:fred negate @t >temp 2>&1
 		grep -q -E "quota exceeded" temp
 		if [ $? -eq 0 ]; then
+			quota_excd=1
 			break
 		fi
 
@@ -83,6 +85,10 @@ do_test()
 		((maxkeysz -= 4))
 	done
 
+	if [ $quota_excd -eq 0 ]; then
+		tst_res TWARN "Failed to trigger the quota excess"
+	fi
+
 	tst_res TPASS "Bug not reproduced"
 }
 
Signature · 1 line
1.8.4.2
#1 lore raw

PATCH 1/3 commands/keyctl01: Fix potential infinite loop

Hi!

Ping, thanks!

Best Regards,
Guangwen Feng

Quoted 46 lines · Guangwen Feng

End the loop when max key quota is less than or equal to current key usage, in case some errors happen and result in endless loop.

We expect the test to trigger key quota excess which breaks the loop but it may not happen, so add a TWARN message for this.

---
 testcases/commands/keyctl/keyctl01.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
testcases/commands/keyctl/keyctl01.sh +7 -1
index 076a130..5a97499 100644
@@ -62,15 +62,17 @@ cleanup()
 
 do_test()
 {
+	local quota_excd=0
 	local maxkeysz=$((ORIG_KEYSZ + 100))
 
-	while true
+	while [ $maxkeysz -gt $ORIG_KEYSZ ]
 	do
 		echo $maxkeysz >$PATH_KEYQUOTA
 
 		keyctl request2 user debug:fred negate @t >temp 2>&1
 		grep -q -E "quota exceeded" temp
 		if [ $? -eq 0 ]; then
+			quota_excd=1
 			break
 		fi
 
@@ -83,6 +85,10 @@ do_test()
 		((maxkeysz -= 4))
 	done
 
+	if [ $quota_excd -eq 0 ]; then
+		tst_res TWARN "Failed to trigger the quota excess"
+	fi
+
 	tst_res TPASS "Bug not reproduced"
 }
 
#2 lore raw

PATCH 2/3 commands/keyctl01: Fix getting key serial number

In reply to Guangwen Feng

We expect to get the key serial number by matching "debug:fred":

Session Keyring

1072563454 --alswrv      0     0  keyring: _ses
 340758544 --alswrv      0 65534   \_ keyring: _uid.0
 783746283 --alswrv      0     0   \_ user: debug:fred

But in some kernels the key will be inaccessible immediately after being requested with "debug:fred negate":

Session Keyring

        -3 --alswrv      0     0  keyring: _ses

842289032 --alswrv 0 -1 \_ keyring: _uid.0
877125164: key inaccessible (Permission denied)

So fix this by adding a match with "inaccessible".

---
 testcases/commands/keyctl/keyctl01.sh | 5 +++++
 1 file changed, 5 insertions(+)
testcases/commands/keyctl/keyctl01.sh +5 -0
index 5a97499..8ea2b25 100644
@@ -77,6 +77,11 @@ do_test()
 		fi
 
 		local key=`keyctl show | awk '/debug:fred/ {print $1}'`
+		if [ -z "$key" ]; then
+			key=`keyctl show | \
+				awk -F ':' '/inaccessible/ {print $1}'`
+		fi
+
 		if [ -n "$key" ]; then
 			keyctl unlink $key @s >/dev/null
 			tst_sleep 50ms
Signature · 1 line
1.8.4.2
#3 lore raw

PATCH 2/3 commands/keyctl01: Fix getting key serial number

Hi!

Quoted 12 lines

So fix this by adding a match with "inaccessible".

---
 testcases/commands/keyctl/keyctl01.sh | 5 +++++
 1 file changed, 5 insertions(+)
testcases/commands/keyctl/keyctl01.sh +0 -0
index 5a97499..8ea2b25 100644

testcases/commands/keyctl/keyctl01.sh do_test() · line 83

Quoted 7 lines
testcases/commands/keyctl/keyctl01.sh +4 -0
@@ -77,6 +77,11 @@ do_test()
 		fi
 
 		local key=`keyctl show | awk '/debug:fred/ {print $1}'`
+		if [ -z "$key" ]; then
+			key=`keyctl show | \
+				awk -F ':' '/inaccessible/ {print $1}'`
+		fi

Can't we rather split the keyctl request and keyctl negate operations into two and get the key after the key has been requested but before it was negated?

Or is it required to do the request and negate operation in a signle keyctl command in order to reproduce the kernel crash?

Quoted 11 lines
testcases/commands/keyctl/keyctl01.sh +0 -0
 		if [ -n "$key" ]; then
 			keyctl unlink $key @s >/dev/null
 			tst_sleep 50ms
Signature · 7 lines
1.8.4.2




-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis
[email protected]
#4 lore raw

PATCH 2/3 commands/keyctl01: Fix getting key serial number

Hi!

Thanks for your review.

Quoted 25 lines · Cyril Hrubis

Hi!

Quoted 12 lines

So fix this by adding a match with "inaccessible".

---
 testcases/commands/keyctl/keyctl01.sh | 5 +++++
 1 file changed, 5 insertions(+)
testcases/commands/keyctl/keyctl01.sh +0 -0
index 5a97499..8ea2b25 100644

testcases/commands/keyctl/keyctl01.sh do_test() · line 83

Quoted 7 lines
testcases/commands/keyctl/keyctl01.sh +4 -0
@@ -77,6 +77,11 @@ do_test()
 		fi
 
 		local key=`keyctl show | awk '/debug:fred/ {print $1}'`
+		if [ -z "$key" ]; then
+			key=`keyctl show | \
+				awk -F ':' '/inaccessible/ {print $1}'`
+		fi

Can't we rather split the keyctl request and keyctl negate operations into two and get the key after the key has been requested but before it was negated?

Quoted 2 lines

Or is it required to do the request and negate operation in a signle keyctl command in order to reproduce the kernel crash?

I think it is required to do the operations in one command... I will try to split them and reproduce the kernel crash, thanks.

Best Regards,
Guangwen Feng

Quoted 13 lines
Quoted 12 lines
testcases/commands/keyctl/keyctl01.sh +0 -0
 		if [ -n "$key" ]; then
 			keyctl unlink $key @s >/dev/null
 			tst_sleep 50ms
Signature · 7 lines
1.8.4.2




-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

PATCH 2/3 commands/keyctl01: Fix getting key serial number

Hi!

Quoted 30 lines · Guangwen Feng

Hi!

Thanks for your review.

Quoted 25 lines · Cyril Hrubis

Hi!

Quoted 12 lines

So fix this by adding a match with "inaccessible".

---
 testcases/commands/keyctl/keyctl01.sh | 5 +++++
 1 file changed, 5 insertions(+)
testcases/commands/keyctl/keyctl01.sh +0 -0
index 5a97499..8ea2b25 100644

testcases/commands/keyctl/keyctl01.sh do_test() · line 83

Quoted 7 lines
testcases/commands/keyctl/keyctl01.sh +4 -0
@@ -77,6 +77,11 @@ do_test()
 		fi
 
 		local key=`keyctl show | awk '/debug:fred/ {print $1}'`
+		if [ -z "$key" ]; then
+			key=`keyctl show | \
+				awk -F ':' '/inaccessible/ {print $1}'`
+		fi

Can't we rather split the keyctl request and keyctl negate operations into two and get the key after the key has been requested but before it was negated?

Quoted 5 lines
Quoted 2 lines

Or is it required to do the request and negate operation in a signle keyctl command in order to reproduce the kernel crash?

I think it is required to do the operations in one command... I will try to split them and reproduce the kernel crash, thanks.

Without using a single keyctl command, this bug cannot be triggered, so I want to keep it this way.

I think the problem is that we cannot get the keyid by matching "debug:fred" via "keyctl show" when the key is expired, I find that in /proc/keys even the key is expired, we can still see the key's description, so we can just look it up this way.

I will send a V2 soon.

Best Regards,
Guangwen Feng

Quoted 20 lines

Best Regards,
Guangwen Feng

Quoted 13 lines
Quoted 12 lines
testcases/commands/keyctl/keyctl01.sh +0 -0
 		if [ -n "$key" ]; then
 			keyctl unlink $key @s >/dev/null
 			tst_sleep 50ms
Signature · 7 lines
1.8.4.2




-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

PATCH 2/3 commands/keyctl01: Fix getting key serial number

Hi!

Quoted 39 lines · Guangwen Feng

Hi!

Quoted 30 lines · Guangwen Feng

Hi!

Thanks for your review.

Quoted 25 lines · Cyril Hrubis

Hi!

Quoted 12 lines

So fix this by adding a match with "inaccessible".

---
 testcases/commands/keyctl/keyctl01.sh | 5 +++++
 1 file changed, 5 insertions(+)
testcases/commands/keyctl/keyctl01.sh +0 -0
index 5a97499..8ea2b25 100644

testcases/commands/keyctl/keyctl01.sh do_test() · line 83

Quoted 7 lines
testcases/commands/keyctl/keyctl01.sh +4 -0
@@ -77,6 +77,11 @@ do_test()
 		fi
 
 		local key=`keyctl show | awk '/debug:fred/ {print $1}'`
+		if [ -z "$key" ]; then
+			key=`keyctl show | \
+				awk -F ':' '/inaccessible/ {print $1}'`
+		fi

Can't we rather split the keyctl request and keyctl negate operations into two and get the key after the key has been requested but before it was negated?

Quoted 5 lines
Quoted 2 lines

Or is it required to do the request and negate operation in a signle keyctl command in order to reproduce the kernel crash?

I think it is required to do the operations in one command... I will try to split them and reproduce the kernel crash, thanks.

Quoted 7 lines

Without using a single keyctl command, this bug cannot be triggered, so I want to keep it this way.

I think the problem is that we cannot get the keyid by matching "debug:fred" via "keyctl show" when the key is expired, I find that in /proc/keys even the key is expired, we can still see the key's description, so we can just look it up this way.

Sorry, but there are also some old kernels like 2.6.18-398.el5 do not show user key in /proc/keys:

[root@rhel5 ~]# cat /proc/keys

00000001 I-----     1 perm 1f3f0000     0     0 keyring   _uid_ses.0: 1/4
00000002 I-----     3 perm 1f3f0000     0     0 keyring   _uid.0: empty
039d3f23 I--Q--     3 perm 1f3f0000     0     0 keyring   _ses.2742: 6/8

^
6 keys in this keyring

It only shows how many keys in a keyring, so this is unreliable...

Can we just use "keyctl show" to match "inaccessible" when this happens?

Best Regards,
Guangwen Feng

Quoted 29 lines

I will send a V2 soon.

Best Regards,
Guangwen Feng

Quoted 20 lines

Best Regards,
Guangwen Feng

Quoted 13 lines
Quoted 12 lines
testcases/commands/keyctl/keyctl01.sh +0 -0
 		if [ -n "$key" ]; then
 			keyctl unlink $key @s >/dev/null
 			tst_sleep 50ms
Signature · 7 lines
1.8.4.2




-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

PATCH 2/3 commands/keyctl01: Fix getting key serial number

Hi!

Quoted 2 lines

Can we just use "keyctl show" to match "inaccessible" when this happens?

Sure, if there is no better way let's go with the original version.

Signature · 2 lines
Cyril Hrubis
[email protected]
#8 lore raw

PATCH v2 1/3 commands/keyctl01: Fix potential infinite loop

End the loop once the max key quota is less than zero, in case some errors happen and result in endless loop.

We expect the test to trigger key quota excess which breaks the loop but it may not happen, so add a TWARN message for this.

---
 testcases/commands/keyctl/keyctl01.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
testcases/commands/keyctl/keyctl01.sh +7 -1
index 690fbbf..238b117 100644
@@ -61,15 +61,17 @@ cleanup()
 
 do_test()
 {
+	local quota_excd=0
 	local maxkeysz=$((ORIG_KEYSZ + 100))
 
-	while true
+	while [ $maxkeysz -ge 0 ]
 	do
 		echo $maxkeysz >$PATH_KEYQUOTA
 
 		keyctl request2 user debug:fred negate @t >temp 2>&1
 		grep -q -E "quota exceeded" temp
 		if [ $? -eq 0 ]; then
+			quota_excd=1
 			break
 		fi
 
@@ -82,6 +84,10 @@ do_test()
 		((maxkeysz -= 4))
 	done
 
+	if [ $quota_excd -eq 0 ]; then
+		tst_res TWARN "Failed to trigger the quota excess"
+	fi
+
 	tst_res TPASS "Bug not reproduced"
 }
 
Signature · 1 line
2.9.4
#9 lore raw

PATCH v2 2/3 commands/keyctl01: Fix getting key serial number

We expect to get the key serial number by matching "debug:fred":

Session Keyring

1072563454 --alswrv      0     0  keyring: _ses
 340758544 --alswrv      0 65534   \_ keyring: _uid.0
 783746283 --alswrv      0     0   \_ user: debug:fred

But in some kernels the key will be inaccessible immediately after being requested with "debug:fred negate":

Session Keyring

        -3 --alswrv      0     0  keyring: _ses

842289032 --alswrv 0 -1 \_ keyring: _uid.0
877125164: key inaccessible (Permission denied)

So fix this by adding a match with "inaccessible".

---
 testcases/commands/keyctl/keyctl01.sh | 5 +++++
 1 file changed, 5 insertions(+)
testcases/commands/keyctl/keyctl01.sh +5 -0
index 238b117..76226ae 100644
@@ -76,6 +76,11 @@ do_test()
 		fi
 
 		local key=`keyctl show | awk '/debug:fred/ {print $1}'`
+		if [ -z "$key" ]; then
+			key=`keyctl show | \
+				awk -F ':' '/inaccessible/ {print $1}'`
+		fi
+
 		if [ -n "$key" ]; then
 			keyctl unlink $key @s >/dev/null
 			tst_sleep 50ms
Signature · 1 line
2.9.4
#10 lore raw

PATCH v2 3/3 commands/keyctl01: Check keyctl support instead of kernel version

In reply to Guangwen Feng
---
 testcases/commands/keyctl/keyctl01.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
testcases/commands/keyctl/keyctl01.sh +4 -2
index 76226ae..8e96622 100644
@@ -36,8 +36,10 @@ TST_NEEDS_CMDS="keyctl"
 
 setup()
 {
-	if tst_kvcmp -le 2.6.33; then
-		tst_brk TCONF "Kernel newer than 2.6.33 is needed"
+	keyctl 2>&1 | tr '\n' ' ' | grep "request2" | grep "negate" | \
+		grep "show" | grep "unlink" >/dev/null
+	if [ $? -ne 0 ]; then
+		tst_brk TCONF "keyctl operations not supported"
 	fi
 
 	PATH_KEYSTAT="/proc/key-users"
Signature · 1 line
2.9.4
#11 lore raw

PATCH v2 3/3 commands/keyctl01: Check keyctl support instead of kernel version

Hi!
I've pushed the first two patches, thanks.

testcases/commands/keyctl/keyctl01.sh TST_NEEDS_CMDS="keyctl" · line 40

Quoted 6 lines

setup()
{

testcases/commands/keyctl/keyctl01.sh +2 -2
-	if tst_kvcmp -le 2.6.33; then
-		tst_brk TCONF "Kernel newer than 2.6.33 is needed"
+	keyctl 2>&1 | tr '\n' ' ' | grep "request2" | grep "negate" | \
+		grep "show" | grep "unlink" >/dev/null

Uh, what are we grepping here for exactly? Can't we do that with a single regular expression?

Quoted 10 lines
testcases/commands/keyctl/keyctl01.sh +2 -0
+	if [ $? -ne 0 ]; then
+		tst_brk TCONF "keyctl operations not supported"
 	fi
 
 	PATH_KEYSTAT="/proc/key-users"
Signature · 1 line
2.9.4
Signature · 2 lines
Cyril Hrubis
[email protected]
#12 lore raw

PATCH v2 3/3 commands/keyctl01: Check keyctl support instead of kernel version

Hi!

Quoted 2 lines · Cyril Hrubis

Hi!
I've pushed the first two patches, thanks.

Thanks!

Quoted 9 lines

testcases/commands/keyctl/keyctl01.sh TST_NEEDS_CMDS="keyctl" · line 40

Quoted 7 lines

setup()
{

testcases/commands/keyctl/keyctl01.sh +2 -2
-	if tst_kvcmp -le 2.6.33; then
-		tst_brk TCONF "Kernel newer than 2.6.33 is needed"
+	keyctl 2>&1 | tr '\n' ' ' | grep "request2" | grep "negate" | \
+		grep "show" | grep "unlink" >/dev/null

Uh, what are we grepping here for exactly?

We need to check the keyctl operations "request2", "negate", "show", "unlink" are all available...

Quoted 1 line

Can't we do that with a single regular expression?

Yes, we can do:

keyctl 2>&1 | sort | tr '\n' ' ' | grep -P "\bnegate\b.*\brequest2\b.*\bshow\b.*\bunlink\b" >/dev/null

Best Regards,
Guangwen Feng

Quoted 12 lines
Quoted 11 lines
testcases/commands/keyctl/keyctl01.sh +2 -0
+	if [ $? -ne 0 ]; then
+		tst_brk TCONF "keyctl operations not supported"
 	fi
 
 	PATH_KEYSTAT="/proc/key-users"
Signature · 1 line
2.9.4
#13 lore raw

PATCH v3 1/1 commands/keyctl01: Check keyctl support instead of kernel version

---
 testcases/commands/keyctl/keyctl01.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
testcases/commands/keyctl/keyctl01.sh +4 -2
index 76226ae..0b8e86c 100644
@@ -36,8 +36,10 @@ TST_NEEDS_CMDS="keyctl"
 
 setup()
 {
-	if tst_kvcmp -le 2.6.33; then
-		tst_brk TCONF "Kernel newer than 2.6.33 is needed"
+	keyctl 2>&1 | sort | tr '\n' ' ' | grep -P \
+		"\bnegate\b.*\brequest2\b.*\bshow\b.*\bunlink\b" >/dev/null
+	if [ $? -ne 0 ]; then
+		tst_brk TCONF "keyctl operations not supported"
 	fi
 
 	PATH_KEYSTAT="/proc/key-users"
Signature · 1 line
2.9.4
#14 lore raw

PATCH v3 1/1 commands/keyctl01: Check keyctl support instead of kernel version

Hi!
Looking at this closer we only check that the keyctl binary understands these requests, shouldn't we as well try to request2 and unlink a key to seek if kernel is up to the task?

And btw, it would be a bit cleaner to use a for loop to check for each flag separately and tell user what flag is not supported:

testcases/commands/keyctl/keyctl01.sh +10 -3
old mode 100644
new mode 100755
index 76226ae4d..f831acbfc
@@ -34,11 +34,18 @@ TST_NEEDS_TMPDIR=1
 TST_NEEDS_CMDS="keyctl"
 . tst_test.sh
 
+check_keyctl()
+{
+       for op in $@; do
+               if ! keyctl 2>&1 | grep -q "keyctl $op"; then
+                       tst_brk TCONF "keyctl operation $op not supported"
+               fi
+       done
+}
+
 setup()
 {
-       if tst_kvcmp -le 2.6.33; then
-               tst_brk TCONF "Kernel newer than 2.6.33 is needed"
-       fi
+       check_keyctl negate request2 show unlink
 
        PATH_KEYSTAT="/proc/key-users"
        PATH_KEYQUOTA="/proc/sys/kernel/keys/root_maxbytes"
Signature · 2 lines
Cyril Hrubis
[email protected]
#15 lore raw

PATCH v4 1/1 commands/keyctl01: Check keyctl support instead of kernel version

---
 testcases/commands/keyctl/keyctl01.sh | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
testcases/commands/keyctl/keyctl01.sh +30 -3
index 76226ae..650e7f4 100644
@@ -34,11 +34,38 @@ TST_NEEDS_TMPDIR=1
 TST_NEEDS_CMDS="keyctl"
 . tst_test.sh
 
+check_keyctl()
+{
+	local nosup
+	for op in $@; do
+		nosup=0
+
+		if ! keyctl 2>&1 | grep -q "keyctl $op"; then
+			nosup=1
+		fi
+
+		if [ "$op" = "request2" ]; then
+			local key=`keyctl request2 user debug:foo bar`
+			if [ $? -ne 0 ]; then
+				nosup=1
+			fi
+		fi
+
+		if [ "$op" = "unlink" ]; then
+			if ! keyctl unlink $key @s; then
+				nosup=1
+			fi
+		fi
+
+		if [ $nosup -ne 0 ]; then
+			tst_brk TCONF "keyctl operation $op not supported"
+		fi
+	done
+}
+
 setup()
 {
-	if tst_kvcmp -le 2.6.33; then
-		tst_brk TCONF "Kernel newer than 2.6.33 is needed"
-	fi
+	check_keyctl negate request2 show unlink
 
 	PATH_KEYSTAT="/proc/key-users"
 	PATH_KEYQUOTA="/proc/sys/kernel/keys/root_maxbytes"
Signature · 1 line
2.9.4
#17 lore raw

PATCH 3/3 commands/keyctl01: Enable this test for RHEL6

In reply to Guangwen Feng

This bug also happened on RHEL6 and was introduced in 2.6.32-254.el6, so add RHEL6's kernel as target as well.

---
 testcases/commands/keyctl/keyctl01.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
testcases/commands/keyctl/keyctl01.sh +3 -2
index 8ea2b25..40183b0 100644
@@ -37,8 +37,9 @@ TST_NEEDS_CMDS="keyctl"
 
 setup()
 {
-	if tst_kvcmp -le 2.6.33; then
-		tst_brk TCONF "Kernel newer than 2.6.33 is needed"
+	if tst_kvcmp -le '2.6.33 RHEL6:2.6.32-254'; then
+		tst_brk TCONF \
+			"Kernel newer than 2.6.33 or 2.6.32-254.el6 is needed"
 	fi
 
 	PATH_KEYSTAT="/proc/key-users"
Signature · 1 line
1.8.4.2
#18 lore raw

PATCH 3/3 commands/keyctl01: Enable this test for RHEL6

Hi!

testcases/commands/keyctl/keyctl01.sh TST_NEEDS_CMDS="keyctl" · line 42

Quoted 13 lines
testcases/commands/keyctl/keyctl01.sh +3 -2
index 8ea2b25..40183b0 100644
@@ -37,8 +37,9 @@ TST_NEEDS_CMDS="keyctl"
 
 setup()
 {
-	if tst_kvcmp -le 2.6.33; then
-		tst_brk TCONF "Kernel newer than 2.6.33 is needed"
+	if tst_kvcmp -le '2.6.33 RHEL6:2.6.32-254'; then
+		tst_brk TCONF \
+			"Kernel newer than 2.6.33 or 2.6.32-254.el6 is needed"

I would be a bit happier if we could check if keyctl operations we need for the test are supported (if that is reasonably easy to do) insetad of listing minimal kernel versions per distribution.

Signature · 2 lines
Cyril Hrubis
[email protected]
#19 lore raw

PATCH 3/3 commands/keyctl01: Enable this test for RHEL6

Hi!

Thanks for your review.

Quoted 7 lines · Cyril Hrubis

Hi!

Quoted 6 lines
testcases/commands/keyctl/keyctl01.sh +0 -0
index 8ea2b25..40183b0 100644
@@ -37,8 +37,9 @@ TST_NEEDS_CMDS="keyctl"
 
Quoted 11 lines

testcases/commands/keyctl/keyctl01.sh TST_NEEDS_CMDS="keyctl" · line 42

Quoted 7 lines
testcases/commands/keyctl/keyctl01.sh +3 -2
 setup()
 {
-	if tst_kvcmp -le 2.6.33; then
-		tst_brk TCONF "Kernel newer than 2.6.33 is needed"
+	if tst_kvcmp -le '2.6.33 RHEL6:2.6.32-254'; then
+		tst_brk TCONF \
+			"Kernel newer than 2.6.33 or 2.6.32-254.el6 is needed"

I would be a bit happier if we could check if keyctl operations we need for the test are supported (if that is reasonably easy to do) insetad of listing minimal kernel versions per distribution.

OK, I see.
I will check if they are supported and drop the tst_kvcmp, thanks.

Best Regards,
Guangwen Feng

#20 lore raw

PATCH 1/3 commands/keyctl01: Fix potential infinite loop

In reply to Guangwen Feng

Hi!

testcases/commands/keyctl/keyctl01.sh cleanup() · line 68

Quoted 13 lines
testcases/commands/keyctl/keyctl01.sh +2 -1
index 076a130..5a97499 100644
@@ -62,15 +62,17 @@ cleanup()
 
 do_test()
 {
+	local quota_excd=0
 	local maxkeysz=$((ORIG_KEYSZ + 100))
 
-	while true
+	while [ $maxkeysz -gt $ORIG_KEYSZ ]

This may still be incorrect if some keys has been deleted after we executed the setup() function though. This is quite unlikely but still may happen. What about we ended the loop once $maxkeysz < 0?

Otherwise it looks fine.

Signature · 2 lines
Cyril Hrubis
[email protected]
#21 lore raw

PATCH 1/3 commands/keyctl01: Fix potential infinite loop

Hi!

Thanks for your review.

Quoted 12 lines · Cyril Hrubis

Hi!

Quoted 11 lines
testcases/commands/keyctl/keyctl01.sh +1 -0
index 076a130..5a97499 100644
@@ -62,15 +62,17 @@ cleanup()
 
 do_test()
 {
+	local quota_excd=0
 	local maxkeysz=$((ORIG_KEYSZ + 100))
 
Quoted 6 lines

testcases/commands/keyctl/keyctl01.sh cleanup() · line 68

Quoted 2 lines
testcases/commands/keyctl/keyctl01.sh +1 -1
-	while true
+	while [ $maxkeysz -gt $ORIG_KEYSZ ]

This may still be incorrect if some keys has been deleted after we executed the setup() function though. This is quite unlikely but still may happen. What about we ended the loop once $maxkeysz < 0?

Yes, it sounds more reasonable,
I got it, thanks.

Best Regards,
Guangwen Feng

Quoted 3 lines

Otherwise it looks fine.