diff mbox series

userns/userns08.c: Enable userns in max_user_namespaces file

Message ID 1628144855-5924-1-git-send-email-xuyang2018.jy@fujitsu.com
State Changes Requested
Headers show
Series userns/userns08.c: Enable userns in max_user_namespaces file | expand

Commit Message

Yang Xu \(Fujitsu\) Aug. 5, 2021, 6:27 a.m. UTC
On old distros ie centos7, the default value of max_user_namespaces is set to 0.
Enable it by increasing this value.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 testcases/kernel/containers/userns/userns08.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Yang Xu \(Fujitsu\) Aug. 18, 2021, 9:57 a.m. UTC | #1
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
> On old distros ie centos7, the default value of max_user_namespaces is set to 0.
> Enable it by increasing this value.
> 
> Signed-off-by: Yang Xu<xuyang2018.jy@fujitsu.com>
> ---
>   testcases/kernel/containers/userns/userns08.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/testcases/kernel/containers/userns/userns08.c b/testcases/kernel/containers/userns/userns08.c
> index aedfc6c4e..0910ea7d4 100644
> --- a/testcases/kernel/containers/userns/userns08.c
> +++ b/testcases/kernel/containers/userns/userns08.c
> @@ -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"},
Richard Palethorpe Aug. 27, 2021, 10:35 a.m. UTC | #2
Hello Yang,

Yang Xu <xuyang2018.jy@fujitsu.com> writes:

> On old distros ie centos7, the default value of max_user_namespaces is set to 0.
> Enable it by increasing this value.
>
> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>

Looks good, except for very minor point below.

Reviewed-by: Richard Palethorpe <rpalethorpe@suse.com>

> ---
>  testcases/kernel/containers/userns/userns08.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/testcases/kernel/containers/userns/userns08.c b/testcases/kernel/containers/userns/userns08.c
> index aedfc6c4e..0910ea7d4 100644
> --- a/testcases/kernel/containers/userns/userns08.c
> +++ b/testcases/kernel/containers/userns/userns08.c
> @@ -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.
Yang Xu \(Fujitsu\) Aug. 31, 2021, 10:09 a.m. UTC | #3
Hi  Richard
> Hello Yang,
> 
> Yang Xu<xuyang2018.jy@fujitsu.com>  writes:
> 
>> On old distros ie centos7, the default value of max_user_namespaces is set to 0.
>> Enable it by increasing this value.
>>
>> Signed-off-by: Yang Xu<xuyang2018.jy@fujitsu.com>
> 
> Looks good, except for very minor point below.
> 
> Reviewed-by: Richard Palethorpe<rpalethorpe@suse.com>
> 
>> ---
>>   testcases/kernel/containers/userns/userns08.c | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/testcases/kernel/containers/userns/userns08.c b/testcases/kernel/containers/userns/userns08.c
>> index aedfc6c4e..0910ea7d4 100644
>> --- a/testcases/kernel/containers/userns/userns08.c
>> +++ b/testcases/kernel/containers/userns/userns08.c
>> @@ -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.

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
>
diff mbox series

Patch

diff --git a/testcases/kernel/containers/userns/userns08.c b/testcases/kernel/containers/userns/userns08.c
index aedfc6c4e..0910ea7d4 100644
--- a/testcases/kernel/containers/userns/userns08.c
+++ b/testcases/kernel/containers/userns/userns08.c
@@ -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"},