Skip to contentSkip to conversation

syscalls/fcntl35: the pipe-max-size should be multiple of PAGE_SIZE

PATCH New Li Wang 3 participants 3 messages Aug 7, 2017 – Aug 8, 2017

lore
Share & tools
lore

Li Wang

author
#0 lore raw

PATCH 1/1 syscalls/fcntl35: the pipe-max-size should be multiple of PAGE_SIZE

It's very easy to get failures on a system which the PAGE_SIZE is larger than 4096.

  # uname -r
  4.13.0-rc3
  # getconf PAGESIZE
  65536
  # echo 4096 >/proc/sys/fs/pipe-max-size
  bash: echo: write error: Invalid argument
---
 testcases/kernel/syscalls/fcntl/fcntl35.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/fcntl/fcntl35.c +9 -5
index b984584..675da71 100644
@@ -45,19 +45,23 @@
 #include "tst_test.h"
 
 static int pipe_max_unpriv;
-static int test_max_unpriv = 4096;
+static int test_max_unpriv;
+static int test_max_priv;
 static struct passwd *pw;
 static struct tcase {
-	int exp_sz;
+	int *exp_sz;
 	int exp_usr;
 	char *des;
 } tcases[] = {
-	{4096, 1, "an unprivileged user"},
-	{65536, 0, "a privileged user"}
+	{&test_max_unpriv, 1, "an unprivileged user"},
+	{&test_max_priv, 0, "a privileged user"}
 };
 
 static void setup(void)
 {
+	test_max_unpriv = getpagesize();
+	test_max_priv = test_max_unpriv * 16;
+
 	if (!access("/proc/sys/fs/pipe-max-size", F_OK)) {
 		SAFE_FILE_SCANF("/proc/sys/fs/pipe-max-size", "%d",
 				&pipe_max_unpriv);
@@ -115,7 +119,7 @@ static void do_test(unsigned int n)
 		if (tc->exp_usr)
 			SAFE_SETUID(pw->pw_uid);
 
-		verify_pipe_size(tc->exp_sz, tc->des);
+		verify_pipe_size(*tc->exp_sz, tc->des);
 	}
 
 	tst_reap_children();
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/1 syscalls/fcntl35: the pipe-max-size should be multiple of PAGE_SIZE

Hi!
Pushed, thanks.

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

PATCH 1/1 syscalls/fcntl35: the pipe-max-size should be multiple of PAGE_SIZE

In reply to Li Wang

Hi Li,

Thanks for fixing this issue! :-)

Thanks,
Xiao Yang.

Quoted 55 lines · Li Wang

It's very easy to get failures on a system which the PAGE_SIZE is larger than 4096.

  # uname -r
  4.13.0-rc3
  # getconf PAGESIZE
  65536
  # echo 4096 >/proc/sys/fs/pipe-max-size
  bash: echo: write error: Invalid argument
---
 testcases/kernel/syscalls/fcntl/fcntl35.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/fcntl/fcntl35.c +9 -5
index b984584..675da71 100644
@@ -45,19 +45,23 @@
 #include "tst_test.h"
 
 static int pipe_max_unpriv;
-static int test_max_unpriv = 4096;
+static int test_max_unpriv;
+static int test_max_priv;
 static struct passwd *pw;
 static struct tcase {
-	int exp_sz;
+	int *exp_sz;
 	int exp_usr;
 	char *des;
 } tcases[] = {
-	{4096, 1, "an unprivileged user"},
-	{65536, 0, "a privileged user"}
+	{&test_max_unpriv, 1, "an unprivileged user"},
+	{&test_max_priv, 0, "a privileged user"}
 };
 
 static void setup(void)
 {
+	test_max_unpriv = getpagesize();
+	test_max_priv = test_max_unpriv * 16;
+
 	if (!access("/proc/sys/fs/pipe-max-size", F_OK)) {
 		SAFE_FILE_SCANF("/proc/sys/fs/pipe-max-size", "%d",
 				&pipe_max_unpriv);
@@ -115,7 +119,7 @@ static void do_test(unsigned int n)
 		if (tc->exp_usr)
 			SAFE_SETUID(pw->pw_uid);
 
-		verify_pipe_size(tc->exp_sz, tc->des);
+		verify_pipe_size(*tc->exp_sz, tc->des);
 	}
 
 	tst_reap_children();