lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190816083246.169312-1-arul.jeniston@gmail.com>
Date:   Fri, 16 Aug 2019 01:32:46 -0700
From:   arul.jeniston@...il.com
To:     viro@...iv.linux.org.uk, tglx@...utronix.de
Cc:     linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
        arul_mc@...l.com, ARUL JENISTON MC <arul.jeniston@...il.com>
Subject: [PATCH] FS: timerfd: Fix unexpected return value of timerfd_read function.  'hrtimer_forward_now()' returns zero due to bigger backward time drift.  This causes timerfd_read to return 0. As per man page, read on timerfd  is not expected to return 0. This patch fixes this problem.  Signed-off-by: Arul Jeniston <arul.jeniston@...il.com>

From: ARUL JENISTON MC <arul.jeniston@...il.com>

---
 fs/timerfd.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/fs/timerfd.c b/fs/timerfd.c
index 6a6fc8aa1de7..f5094e070e9a 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -284,8 +284,16 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
 					&ctx->t.alarm, ctx->tintv) - 1;
 				alarm_restart(&ctx->t.alarm);
 			} else {
-				ticks += hrtimer_forward_now(&ctx->t.tmr,
-							     ctx->tintv) - 1;
+				u64 nooftimeo = hrtimer_forward_now(&ctx->t.tmr,
+								 ctx->tintv);
+				/*
+				 * ticks shouldn't become zero at this point.
+				 * Ignore if hrtimer_forward_now returns 0
+				 * due to larger backward time drift.
+				 */
+				if (likely(nooftimeo)) {
+					ticks += nooftimeo - 1;
+				}
 				hrtimer_restart(&ctx->t.tmr);
 			}
 		}
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ