Thread (61 messages) read the whole thread 61 messages, 7 authors, 2019-08-19

[PATCHv6 11/36] timerfd: Make timerfd_settime() time namespace aware

From: Dmitry Safonov <hidden>
Date: 2019-08-15 16:38:59
Also in: lkml
Subsystem: filesystems (vfs and infrastructure), posix clocks and timers, the rest · Maintainers: Alexander Viro, Christian Brauner, Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner, Linus Torvalds

From: Andrei Vagin <redacted>

timerfd_settime() accepts an absolute value of the experation time if
TFD_TIMER_ABSTIME is specified. This value is in task's time namespace
and has to be converted to the host's time namespace.

Signed-off-by: Andrei Vagin <redacted>
Co-developed-by: Dmitry Safonov <redacted>
Signed-off-by: Dmitry Safonov <redacted>
---
 fs/timerfd.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/fs/timerfd.c b/fs/timerfd.c
index 48305ba41e3c..f9da5752a79e 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -26,6 +26,7 @@
 #include <linux/syscalls.h>
 #include <linux/compat.h>
 #include <linux/rcupdate.h>
+#include <linux/time_namespace.h>
 
 struct timerfd_ctx {
 	union {
@@ -196,6 +197,8 @@ static int timerfd_setup(struct timerfd_ctx *ctx, int flags,
 	}
 
 	if (texp != 0) {
+		if (flags & TFD_TIMER_ABSTIME)
+			texp = timens_ktime_to_host(clockid, texp);
 		if (isalarm(ctx)) {
 			if (flags & TFD_TIMER_ABSTIME)
 				alarm_start(&ctx->t.alarm, texp);
-- 
2.22.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help