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>] [day] [month] [year] [list]
Date:	Thu, 11 Sep 2014 03:03:45 -0500
From:	Steve French <smfrench@...il.com>
To:	LKML <linux-kernel@...r.kernel.org>
Subject: 64 bit signed division

Does 64 bit signed division work on all archs?

Since do_div (currently used by cifs and ntfs to convert time formats
from DCE time to Linux time) does not handle negative numbers, and
there does not appear to be a kernel equivalent of Ildiv, I was
wondering if there really is a problem with simply doing s64 division
on other architectures (it obviously works on my systems but they are
Intel and AMD).

ie I have to change from
- u64 t = le64_to_cpu(ntutc) - NTFS_TIME_OFFSET;
-
- ts.tv_nsec = do_div(t, 10000000) * 100;
- ts.tv_sec = t;

to something like

+ s64 t = le64_to_cpu(ntutc) - NTFS_TIME_OFFSET;
+
+ ts.tv_sec = t / 10000000;
+ ts.tv_nsec = (t % 10000000) * 100;

If 64 bit division does not work on all archs then I will need to fall
back to something uglier,

+    s64 t = le64_to_cpu(ntutc) - NTFS_TIME_OFFSET;
+
+    if (t < 0) {
+        t = -t;
+        ts.tv_nsec = -(do_div(t, 10000000) * 100);
+        ts.tv_sec = -t;
+    } else {
+        ts.tv_nsec = do_div(t, 10000000) * 100;
+        ts.tv_sec = t;
+    }

Are there better alternatives?

-- 
Thanks,

Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ