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-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 15 May 2021 22:06:30 +0800
From:   Zheng Yejian <zhengyejian1@...wei.com>
To:     <linux-kernel@...r.kernel.org>
CC:     <akpm@...ux-foundation.org>, <rdunlap@...radead.org>,
        <vbabka@...e.cz>, <guohanjun@...wei.com>, <zhangjinhao2@...wei.com>
Subject: [PATCH 1/2] acct: Fix accuracy loss for input value of encode_comp_t()

See calculation of ac_{u,s}time in fill_ac():
  > ac->ac_utime = encode_comp_t(nsec_to_AHZ(pacct->ac_utime));
  > ac->ac_stime = encode_comp_t(nsec_to_AHZ(pacct->ac_stime));

Return value of nsec_to_AHZ() is always type of 'u64', but it is
handled as type of 'unsigned long' in encode_comp_t, and accuracy
loss would happen on 32-bit platform when 'unsigned long' value
is 32-bit-width.

So 'u64' value of encode_comp_t() may look better.

Signed-off-by: Zheng Yejian <zhengyejian1@...wei.com>
---
 kernel/acct.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/acct.c b/kernel/acct.c
index a64102be2bb0..9e143ed5b5d0 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -301,7 +301,7 @@ void acct_exit_ns(struct pid_namespace *ns)
 }
 
 /*
- *  encode an unsigned long into a comp_t
+ *  encode an u64 into a comp_t
  *
  *  This routine has been adopted from the encode_comp_t() function in
  *  the kern_acct.c file of the FreeBSD operating system. The encoding
@@ -312,7 +312,7 @@ void acct_exit_ns(struct pid_namespace *ns)
 #define	EXPSIZE		3			/* Base 8 (3 bit) exponent. */
 #define	MAXFRACT	((1 << MANTSIZE) - 1)	/* Maximum fractional value. */
 
-static comp_t encode_comp_t(unsigned long value)
+static comp_t encode_comp_t(u64 value)
 {
 	int exp, rnd;
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ