public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] sysctl03: sysctl returns EACCES after 2.6.33-rc1
@ 2010-02-01 11:25 Shi Weihua
  0 siblings, 0 replies; 14+ messages in thread
From: Shi Weihua @ 2010-02-01 11:25 UTC (permalink / raw)
  To: ltp-list

The syscall of sysctl has been changed function call process on 2.6.33-rc1.
So we should change some code about sysctl.

Before 2.6.33-rc1:
do_sysctl
	->parse_table
		->sysctl_perm		(will return EPERM sometime)
		->do_sysctl_strategy
			->sysctl_perm	(will return EPERM sometime)
...

After 2.6.33-rc1:
do_sysctl
	->binary_sysctl
		check enable to access or not	(will return EACCES some time)
...

I fixed sysctl03, other cases of sysctl are OK.
This patch works on 2.6.31.5-127.fc12.x86_64, 2.6.32, 2.6.33-rc1, 
and 2.6.33-rc6.

Signed-off-by: Shi Weihua <shiwh@cn.fujitsu.com>
---
--- testcases/kernel/syscalls/sysctl/sysctl03.c.orig	2010-02-02 18:15:56.000000000 +0800
+++ testcases/kernel/syscalls/sysctl/sysctl03.c	2010-02-02 18:49:40.000000000 +0800
@@ -22,15 +22,18 @@
  *	sysctl03.c
  *
  * DESCRIPTION
- *	Testcase to check that sysctl(2) sets errno to EPERM correctly.
+ *	Testcase to check that sysctl(2) sets errno to EPERM or EACCES 
+ *	correctly. But it will return EACCES on kernels that are 2.6.33-rc1 
+ *	and higher.  
  *
  * ALGORITHM
  *	a.	Call sysctl(2) as a root user, and attempt to write data
  *		to the kernel_table[]. Since the table does not have write
- *		permissions even for the root, it should fail EPERM.
+ *		permissions even for the root, it should fail EPERM or EACCES.
  *	b.	Call sysctl(2) as a non-root user, and attempt to write data
  *		to the kernel_table[]. Since the table does not have write
- *		permission for the regular user, it should fail with EPERM.
+ *		permission for the regular user, it should fail with EPERM 
+ *		or EACCES.
  *
  * USAGE:  <for command-line>
  *  sysctl03 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
@@ -43,6 +46,7 @@
  *
  * HISTORY
  *	07/2001 Ported by Wayne Boyer
+ *	02/2010 Updated by shiwh@cn.fujitsu.com
  *
  * RESTRICTIONS
  *	Test must be run as root.
@@ -82,6 +86,7 @@ int main(int ac, char **av)
 {
 	int lc;
 	char *msg;
+	int exp_eno;
 
 	char osname[OSNAMESZ];
 	int osnamelth, status;
@@ -96,6 +101,13 @@ int main(int ac, char **av)
 
 	setup();
 
+	if ((tst_kvercmp(2, 6, 32)) <= 0){
+		exp_eno = EPERM;
+	} else {
+		exp_eno = EACCES;
+		exp_enos[0] = EACCES;
+	}
+
 	TEST_EXP_ENOS(exp_enos);
 
 	/* check looping state if -i option is given */
@@ -114,13 +126,13 @@ int main(int ac, char **av)
 		} else {
 			TEST_ERROR_LOG(TEST_ERRNO);
 
-			if (TEST_ERRNO != EPERM) {
+			if (TEST_ERRNO != exp_eno) {
 				tst_resm(TFAIL,
-					 "Expected EPERM (%d), got %d: %s",
-					 EPERM, TEST_ERRNO,
+					 "Expected %s (%d), got %d: %s",
+					 strerror(exp_eno), exp_eno, TEST_ERRNO,
 					 strerror(TEST_ERRNO));
 			} else {
-				tst_resm(TPASS, "Got expected EPERM error");
+				tst_resm(TPASS, "Got expected %s error", strerror(exp_eno));
 			}
 		}
 
@@ -147,12 +159,12 @@ int main(int ac, char **av)
 			} else {
 				TEST_ERROR_LOG(TEST_ERRNO);
 
-				if (TEST_ERRNO != EPERM) {
-					tst_resm(TFAIL, "Expected EPERM, got "
-						 "%d", TEST_ERRNO);
+				if (TEST_ERRNO != exp_eno) {
+					tst_resm(TFAIL, "Expected %s, got "
+						 "%d", strerror(exp_eno), TEST_ERRNO);
 				} else {
-					tst_resm(TPASS, "Got expected EPERM "
-						 "error");
+					tst_resm(TPASS, "Got expected %s "
+						 "error", strerror(exp_eno));
 				}
 			}
 

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [LTP] [PATCH] sysctl03: sysctl returns EACCES after 2.6.33-rc1
@ 2010-02-17  8:01 Rishikesh
  2010-02-17 17:10 ` Garrett Cooper
  0 siblings, 1 reply; 14+ messages in thread
From: Rishikesh @ 2010-02-17  8:01 UTC (permalink / raw)
  To: Shi Weihua; +Cc: LTP

Hi Shi,

Thanks for your patch, still i am finding time to look into your patch. 
Will reply you soon.

http://marc.info/?l=ltp-list&m=126502355614857&w=2

-- 
Thanks&  Regards
Rishi Kesh K Rajak
IBM LTC, Bangalore
LTP Maintainer
Please join IRC: #ltp @ freenode.net


------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2010-03-05  7:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-01 11:25 [LTP] [PATCH] sysctl03: sysctl returns EACCES after 2.6.33-rc1 Shi Weihua
  -- strict thread matches above, loose matches on Subject: below --
2010-02-17  8:01 Rishikesh
2010-02-17 17:10 ` Garrett Cooper
2010-02-18  4:25   ` Rishikesh K Rajak
2010-02-22  7:15     ` Shi Weihua
2010-02-22  7:44       ` Garrett Cooper
2010-02-23  1:48         ` Shi Weihua
2010-02-25  1:18           ` Garrett Cooper
2010-03-04  8:38             ` Shi Weihua
2010-03-04 18:35               ` Garrett Cooper
2010-03-04 18:37               ` Garrett Cooper
2010-03-04 19:57                 ` Eric W. Biederman
2010-03-05  7:20                   ` Garrett Cooper
2010-03-05  7:50                     ` Eric W. Biederman

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