userns/userns08.c: Enable userns in max_user_namespaces file
PATCH 1/1 userns/userns08.c: Enable userns in max_user_namespaces file
On old distros ie centos7, the default value of max_user_namespaces is set to 0. Enable it by increasing this value.
--- testcases/kernel/containers/userns/userns08.c | 9 +++++++++ 1 file changed, 9 insertions(+)
testcases/kernel/containers/userns/userns08.c +9 -0
@@ -120,6 +120,11 @@ static void setup(void)SAFE_WRITE (fd,1 ,"\n" ,1 );SAFE_CLOSE (fd); + +/* The default value of max_user_namespaces is set to 0 on some distros, +* We need to change the default value to call clone(). +*/ +SAFE_FILE_PRINTF ("/proc/sys/user/max_user_namespaces" ,"%d" ,10 ); }static struct tst_test test = {
@@ -133,6 +138,10 @@ static struct tst_test test = { "CONFIG_USER_NS",NULL }, + .save_restore = (const char *const []) { +"?/proc/sys/user/max_user_namespaces" , +NULL , + }, .tags = (const struct tst_tag []) { {"linux-git" ,"d2f007dbe7e4" }, {"CVE" ,"CVE-2018-18955" },
Signature · 1 line
2.23.0
PATCH 1/1 userns/userns08.c: Enable userns in max_user_namespaces file
Hi!
My machine's time is wrong, so I sent this patch today but the email's date is 8.5(It may lose your attention).
Best Regards
Yang Xu
Quoted 35 lines
On old distros ie centos7, the default value of
max_user_namespacesis set to 0. Enable it by increasing this value.Signed-off-by Yang Xu<[email protected]>--- testcases/kernel/containers/userns/userns08.c | 9 +++++++++ 1 file changed, 9 insertions(+)testcases/kernel/containers/userns/userns08.c +9
-0@@ -120,6 +120,11 @@ static void setup(void)SAFE_WRITE (fd,1 ,"\n" ,1 );SAFE_CLOSE (fd); + +/* The default value of max_user_namespaces is set to 0 on some distros, +* We need to change the default value to call clone(). +*/ +SAFE_FILE_PRINTF ("/proc/sys/user/max_user_namespaces" ,"%d" ,10 ); }static struct tst_test test = {@@ -133,6 +138,10 @@ static struct tst_test test = { "CONFIG_USER_NS",NULL }, + .save_restore = (const char *const []) { +"?/proc/sys/user/max_user_namespaces" , +NULL , + }, .tags = (const struct tst_tag []) { {"linux-git" ,"d2f007dbe7e4" }, {"CVE" ,"CVE-2018-18955" },
PATCH v2 1/1 testcases: Enable userns in max_user_namespaces file
In reply to Yang XuOn old distros ie centos7, the default value of max_user_namespaces is set to 0. Enable it by increasing this value.
--- testcases/cve/icmp_rate_limit01.c | 9 +++++++++ testcases/kernel/containers/userns/userns08.c | 9 +++++++++ testcases/kernel/syscalls/bind/bind06.c | 9 +++++++++ testcases/kernel/syscalls/sendto/sendto03.c | 9 +++++++++ testcases/kernel/syscalls/setsockopt/setsockopt05.c | 9 +++++++++ testcases/kernel/syscalls/setsockopt/setsockopt06.c | 9 +++++++++ testcases/kernel/syscalls/setsockopt/setsockopt07.c | 9 +++++++++ testcases/kernel/syscalls/setsockopt/setsockopt08.c | 9 +++++++++ 8 files changed, 72 insertions(+)
testcases/cve/icmp_rate_limit01.c +9 -0
@@ -58,6 +58,11 @@ static void setup(void)for (i =0 ; i <SRCADDR_COUNT ; i++) fds[i] =-1 ; +/* The default value of max_user_namespaces is set to 0 on some distros, +* We need to change the default value to call clone(). +*/ +SAFE_FILE_PRINTF ("/proc/sys/user/max_user_namespaces" ,"%d" ,10 ); +SAFE_UNSHARE (CLONE_NEWUSER );SAFE_UNSHARE (CLONE_NEWNET );SAFE_FILE_PRINTF ("/proc/self/setgroups" ,"deny" );
@@ -265,6 +270,10 @@ static struct tst_test test = { "CONFIG_NET_NS=y",NULL }, + .save_restore = (const char *const []) { +"?/proc/sys/user/max_user_namespaces" , +NULL , + }, .tags = (const struct tst_tag []) { {"linux-git" ,"b38e7819cae9" }, {"CVE" ,"2020-25705" },
testcases/kernel/containers/userns/userns08.c +9 -0
@@ -120,6 +120,11 @@ static void setup(void)SAFE_WRITE (fd,1 ,"\n" ,1 );SAFE_CLOSE (fd); + +/* The default value of max_user_namespaces is set to 0 on some distros, +* We need to change the default value to call clone(). +*/ +SAFE_FILE_PRINTF ("/proc/sys/user/max_user_namespaces" ,"%d" ,10 ); }static struct tst_test test = {
@@ -133,6 +138,10 @@ static struct tst_test test = { "CONFIG_USER_NS",NULL }, + .save_restore = (const char *const []) { +"?/proc/sys/user/max_user_namespaces" , +NULL , + }, .tags = (const struct tst_tag []) { {"linux-git" ,"d2f007dbe7e4" }, {"CVE" ,"CVE-2018-18955" },
testcases/kernel/syscalls/bind/bind06.c +9 -0
@@ -34,6 +34,11 @@ static void setup(void)int real_gid =getgid ();struct ifreq ifr; +/* The default value of max_user_namespaces is set to 0 on some distros, +* We need to change the default value to call clone(). +*/ +SAFE_FILE_PRINTF ("/proc/sys/user/max_user_namespaces" ,"%d" ,10 ); +SAFE_UNSHARE (CLONE_NEWUSER );SAFE_UNSHARE (CLONE_NEWNET );SAFE_FILE_PRINTF ("/proc/self/setgroups" ,"deny" );
@@ -107,6 +112,10 @@ static struct tst_test test = { "CONFIG_NET_NS=y",NULL }, + .save_restore = (const char *const []) { +"?/proc/sys/user/max_user_namespaces" , +NULL , + }, .tags = (const struct tst_tag []) { {"linux-git" ,"15fe076edea7" }, {"CVE" ,"2018-18559" },
testcases/kernel/syscalls/sendto/sendto03.c +9 -0
@@ -43,6 +43,11 @@ static void setup(void)int real_gid =getgid ();struct ifreq ifr; +/* The default value of max_user_namespaces is set to 0 on some distros, +* We need to change the default value to call clone(). +*/ +SAFE_FILE_PRINTF ("/proc/sys/user/max_user_namespaces" ,"%d" ,10 ); +SAFE_UNSHARE (CLONE_NEWUSER );SAFE_UNSHARE (CLONE_NEWNET );SAFE_FILE_PRINTF ("/proc/self/setgroups" ,"deny" );
@@ -215,6 +220,10 @@ static struct tst_test test = { "CONFIG_NET_NS=y",NULL }, + .save_restore = (const char *const []) { +"?/proc/sys/user/max_user_namespaces" , +NULL , + }, .tags = (const struct tst_tag []) { {"linux-git" ,"bcc5364bdcfe" }, {"linux-git" ,"acf69c946233" },
testcases/kernel/syscalls/setsockopt/setsockopt05.c +9 -0
@@ -40,6 +40,11 @@ static void setup(void)struct ifreq ifr;socklen_t addrlen =sizeof (addr); +/* The default value of max_user_namespaces is set to 0 on some distros, +* We need to change the default value to call clone(). +*/ +SAFE_FILE_PRINTF ("/proc/sys/user/max_user_namespaces" ,"%d" ,10 ); +SAFE_UNSHARE (CLONE_NEWUSER );SAFE_UNSHARE (CLONE_NEWNET );SAFE_FILE_PRINTF ("/proc/self/setgroups" ,"deny" );
@@ -99,6 +104,10 @@ static struct tst_test test = { "CONFIG_NET_NS=y",NULL }, + .save_restore = (const char *const []) { +"?/proc/sys/user/max_user_namespaces" , +NULL , + }, .tags = (const struct tst_tag []) { {"linux-git" ,"85f1bd9a7b5a" }, {"CVE" ,"2017-1000112" },
testcases/kernel/syscalls/setsockopt/setsockopt06.c +9 -0
@@ -35,6 +35,11 @@ static void setup(void)int real_uid =getuid ();int real_gid =getgid (); +/* The default value of max_user_namespaces is set to 0 on some distros, +* We need to change the default value to call clone(). +*/ +SAFE_FILE_PRINTF ("/proc/sys/user/max_user_namespaces" ,"%d" ,10 ); +SAFE_UNSHARE (CLONE_NEWUSER );SAFE_UNSHARE (CLONE_NEWNET );SAFE_FILE_PRINTF ("/proc/self/setgroups" ,"deny" );
@@ -125,6 +130,10 @@ static struct tst_test test = { "CONFIG_NET_NS=y",NULL }, + .save_restore = (const char *const []) { +"?/proc/sys/user/max_user_namespaces" , +NULL , + }, .tags = (const struct tst_tag []) { {"linux-git" ,"84ac7260236a" }, {"CVE" ,"2016-8655" },
testcases/kernel/syscalls/setsockopt/setsockopt07.c +9 -0
@@ -38,6 +38,11 @@ static void setup(void)int real_uid =getuid ();int real_gid =getgid (); +/* The default value of max_user_namespaces is set to 0 on some distros, +* We need to change the default value to call clone(). +*/ +SAFE_FILE_PRINTF ("/proc/sys/user/max_user_namespaces" ,"%d" ,10 ); +SAFE_UNSHARE (CLONE_NEWUSER );SAFE_UNSHARE (CLONE_NEWNET );SAFE_FILE_PRINTF ("/proc/self/setgroups" ,"deny" );
@@ -137,6 +142,10 @@ static struct tst_test test = { "CONFIG_NET_NS=y",NULL }, + .save_restore = (const char *const []) { +"?/proc/sys/user/max_user_namespaces" , +NULL , + }, .tags = (const struct tst_tag []) { {"linux-git" ,"c27927e372f0" }, {"CVE" ,"2017-1000111" },
testcases/kernel/syscalls/setsockopt/setsockopt08.c +9 -0
@@ -95,6 +95,11 @@ void setup(void) "The vulnerability was only present in 32-bit compat mode"); } +/* The default value of max_user_namespaces is set to 0 on some distros, +* We need to change the default value to call clone(). +*/ +SAFE_FILE_PRINTF ("/proc/sys/user/max_user_namespaces" ,"%d" ,10 ); +SAFE_UNSHARE (CLONE_NEWUSER );SAFE_UNSHARE (CLONE_NEWNET ); }
@@ -156,6 +161,10 @@ static struct tst_test test = { "CONFIG_NET_NS=y",NULL }, + .save_restore = (const char *const []) { +"?/proc/sys/user/max_user_namespaces" , +NULL , + }, .tags = (const struct tst_tag []) { {"linux-git" ,"b29c457a6511" }, {"CVE" ,"2021-22555" },
Signature · 1 line
2.23.0
PATCH 1/1 userns/userns08.c: Enable userns in max_user_namespaces file
In reply to Yang XuHello Yang,
Quoted 4 lines · Yang Xu
On old distros ie centos7, the default value of
max_user_namespacesis set to 0. Enable it by increasing this value.Signed-off-by Yang Xu <[email protected]>
Looks good, except for very minor point below.
Quoted 9 lines
--- testcases/kernel/containers/userns/userns08.c | 9 +++++++++ 1 file changed, 9 insertions(+)testcases/kernel/containers/userns/userns08.c +0
-0
testcases/kernel/containers/userns/userns08.c static void setup(void) · line 126
Quoted 7 lines
testcases/kernel/containers/userns/userns08.c +4
-0@@ -120,6 +120,11 @@ static void setup(void)SAFE_WRITE (fd,1 ,"\n" ,1 );SAFE_CLOSE (fd); + +/* The default value of max_user_namespaces is set to 0 on some distros, +* We need to change the default value to call clone(). +*/
We don't need inline comments like this. In this case the commit message and git-blame is fine. Other times the style guide requests it goes in the comment at the top.
Signature · 2 lines
Thank you, Richard.
PATCH 1/1 userns/userns08.c: Enable userns in max_user_namespaces file
Hi Richard
Quoted 23 lines
Hello Yang,
Quoted 4 lines · Yang Xu
On old distros ie centos7, the default value of
max_user_namespacesis set to 0. Enable it by increasing this value.Signed-off-by Yang Xu<[email protected]>Looks good, except for very minor point below.
Reviewed-by Richard Palethorpe<[email protected]>Quoted 10 lines
--- testcases/kernel/containers/userns/userns08.c | 9 +++++++++ 1 file changed, 9 insertions(+)testcases/kernel/containers/userns/userns08.c +0
-0@@ -120,6 +120,11 @@ static void setup(void)
Quoted 10 lines
testcases/kernel/containers/userns/userns08.c static void setup(void) · line 126
Quoted 6 lines
testcases/kernel/containers/userns/userns08.c +4
-0SAFE_WRITE (fd,1 ,"\n" ,1 );SAFE_CLOSE (fd); + +/* The default value of max_user_namespaces is set to 0 on some distros, +* We need to change the default value to call clone(). +*/ We don't need inline comments like this. In this case the commit message and git-blame is fine. Other times the style guide requests it goes in the comment at the top.
Thanks for your review. I have pushed the v2 patch with your reviewed-by(increase this value in more userns cases.)
Best Regards
Yang Xu