Skip to contentSkip to conversation

syscalls/userfaultfd01: Always require CAP_SYS_PTRACE

PATCH New Yang Xu 3 participants 7 messages Dec 5, 2019 – Jan 22, 2020

lore
Share & tools
lore

Yang Xu

author
#0 lore raw

PATCH 1/1 syscalls/userfaultfd01: Always require CAP_SYS_PTRACE

Since commit cefdca0a86be ("userfaultfd/sysctl: add vm.unprivileged_userfaultfd"). , it adds a global sysctl knob "vm.unprivileged_userfaultfd" to control whether unprivileged users can use the userfaultfd system calls. Set this to 1 to allow unprivileged users to use the userfaultfd system calls, or set this to 0 to restrict userfaultfd to only privileged users (with SYS_CAP_PTRACE capability).The default value is 1. In order to use userfaultfd always, require CAP_SYS_PTRACE.

---
 include/lapi/capability.h                             | 4 ++++
 testcases/kernel/syscalls/userfaultfd/userfaultfd01.c | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
include/lapi/capability.h +4 -0
index 8833f0605..06c3f4921 100644
@@ -24,6 +24,10 @@
 # define CAP_NET_RAW          13
 #endif
 
+#ifndef CAP_SYS_PTRACE
+# define CAP_SYS_PTRACE       19
+#endif
+
 #ifndef CAP_SYS_ADMIN
 # define CAP_SYS_ADMIN        21
 #endif
testcases/kernel/syscalls/userfaultfd/userfaultfd01.c +6 -1
index a5e142209..74d2d2253 100644
@@ -19,6 +19,7 @@
 #include "tst_safe_macros.h"
 #include "tst_safe_pthread.h"
 #include "lapi/syscalls.h"
+#include "lapi/capability.h"
 
 static int page_size;
 static char *page;
@@ -114,7 +115,11 @@ static void run(void)
 static struct tst_test test = {
 	.test_all = run,
 	.min_kver = "4.3",
-	.timeout = 20
+	.timeout = 20,
+	.caps = (struct tst_cap []) {
+		TST_CAP(TST_CAP_REQ, CAP_SYS_PTRACE),
+		{}
+	}
 };
 
 #else
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/1 syscalls/userfaultfd01: Always require CAP_SYS_PTRACE

Hi Xu,

Quoted 8 lines

Since commit cefdca0a86be ("userfaultfd/sysctl: add vm.unprivileged_userfaultfd"). , it adds a global sysctl knob "vm.unprivileged_userfaultfd" to control whether unprivileged users can use the userfaultfd system calls. Set this to 1 to allow unprivileged users to use the userfaultfd system calls, or set this to 0 to restrict userfaultfd to only privileged users (with SYS_CAP_PTRACE capability).The default value is 1. In order to use userfaultfd always, require CAP_SYS_PTRACE.

Good idea, thanks!

Kind regards,
Petr

author
#2 lore raw

PATCH 1/1 syscalls/userfaultfd01: Always require CAP_SYS_PTRACE

Hi Peter

Quoted 11 lines

Hi Xu,

Quoted 7 lines

Since commit cefdca0a86be ("userfaultfd/sysctl: add vm.unprivileged_userfaultfd"). , it adds a global sysctl knob "vm.unprivileged_userfaultfd" to control whether unprivileged users can use the userfaultfd system calls. Set this to 1 to allow unprivileged users to use the userfaultfd system calls, or set this to 0 to restrict userfaultfd to only privileged users (with SYS_CAP_PTRACE capability).The default value is 1. In order to use userfaultfd always, require CAP_SYS_PTRACE.

Good idea, thanks!

We have pushed "syscalls/userfaultfd01: add hint about unprivileged_userfaultfd" patch(v2)[1].

This is v1.? li Wang and me both think adding hint is more wise, more info see[2].

[1] https://github.com/linux-test-project/ltp/commit/7dc571d3ad1908d6e50163a06ef848f096fe880a
[2] http://lists.linux.it/pipermail/ltp/2020-January/014921.html

Best Regards
Yang Xu

Quoted 4 lines

Kind regards,
Petr

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200121/5a4e74fb/attachment-0001.htm>

#3 lore raw

PATCH 1/1 syscalls/userfaultfd01: Always require CAP_SYS_PTRACE

Hi Xu,

Quoted 6 lines

We have pushed "syscalls/userfaultfd01: add hint about unprivileged_userfaultfd" patch(v2)[1].

This is v1.? li Wang and me both think adding hint is more wise, more info see[2].

[1] https://github.com/linux-test-project/ltp/commit/7dc571d3ad1908d6e50163a06ef848f096fe880a
[2] http://lists.linux.it/pipermail/ltp/2020-January/014921.html

Thanks for notification, I'll check previous commits next time!

BTW this was caused by maintainers not updating patchwork :(. Would you mind to register to patchwork and check state of your tickets time to time [1]. You'd be able to change state of your own patches.

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/list/?submitter=76329

#4 lore raw

PATCH 1/1 syscalls/userfaultfd01: Always require CAP_SYS_PTRACE

Quoted 11 lines · Petr Vorel

Hi Xu,

Quoted 4 lines

We have pushed "syscalls/userfaultfd01: add hint about unprivileged_userfaultfd" patch(v2)[1]. This is v1. li Wang and me both think adding hint is more wise, more info see[2].
[1] https://github.com/linux-test-project/ltp/commit/7dc571d3ad1908d6e50163a06ef848f096fe880a
[2] http://lists.linux.it/pipermail/ltp/2020-January/014921.html

Thanks for notification, I'll check previous commits next time!

BTW this was caused by maintainers not updating patchwork :(. Would you mind to register to patchwork and check state of your tickets time to time [1]. You'd be able to change state of your own patches.

Hi Petr,

Thanks for your effort.
Xu is my colleague and I helped him change the state to superseded. :-)

Best Regards,
Xiao Yang

Quoted 5 lines

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/list/?submitter=76329

author
#5 lore raw

PATCH 1/1 syscalls/userfaultfd01: Always require CAP_SYS_PTRACE

Quoted 11 lines · Petr Vorel
Quoted 9 lines

Hi Xu,

Quoted 7 lines

We have pushed "syscalls/userfaultfd01: add hint about unprivileged_userfaultfd" patch(v2)[1].
This is v1.? li Wang and me both think adding hint is more wise, more info see[2].
[1]
https://github.com/linux-test-project/ltp/commit/7dc571d3ad1908d6e50163a06ef848f096fe880a

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

[2] http://lists.linux.it/pipermail/ltp/2020-January/014921.html

Thanks for notification, I'll check previous commits next time!

BTW this was caused by maintainers not updating patchwork :(. Would you mind to register to patchwork and check state of your tickets time to
time [1]. You'd be able to change state of your own patches.

Hi Petr
I have registered to patchwork and I will change the state of my other
patches later. Thanks for your kind advice.

also thanks for xiao that changed the state of this patch.

Best Regards
Yang Xu

Quoted 13 lines

Hi Petr,

Thanks for your effort.
Xu is my colleague and I helped him change the state to superseded. :-)

Best Regards,
Xiao Yang

Quoted 5 lines

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/list/?submitter=76329

#6 lore raw

PATCH 1/1 syscalls/userfaultfd01: Always require CAP_SYS_PTRACE

Hi Xu,

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

BTW this was caused by maintainers not updating patchwork :(. Would you mind to register to patchwork and check state of your tickets time to
time [1]. You'd be able to change state of your own patches.

Hi Petr
I have registered to patchwork and I will change the state of my other
patches later. Thanks for your kind advice.

Thanks a lot! Normally it shouldn't be needed, but it can avoid errors like this one.

Quoted 1 line

also thanks for xiao that changed the state of this patch.

Kind regards,
Petr