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] [day] [month] [year] [list]
Date:   Fri, 12 Apr 2019 04:49:30 -0700
From:   tip-bot for Rasmus Villemoes <tipbot@...or.com>
To:     linux-tip-commits@...r.kernel.org
Cc:     linux@...musvillemoes.dk, tglx@...utronix.de,
        linux-kernel@...r.kernel.org, hpa@...or.com, keescook@...omium.org,
        bp@...e.de, willy@...radead.org, mingo@...nel.org
Subject: [tip:core/core] overflow.h: Add comment documenting __ab_c_size()

Commit-ID:  e0478542cfd4d993e38d5f92a3f3ecd238805e96
Gitweb:     https://git.kernel.org/tip/e0478542cfd4d993e38d5f92a3f3ecd238805e96
Author:     Rasmus Villemoes <linux@...musvillemoes.dk>
AuthorDate: Wed, 10 Apr 2019 22:27:25 +0200
Committer:  Borislav Petkov <bp@...e.de>
CommitDate: Fri, 12 Apr 2019 13:44:24 +0200

overflow.h: Add comment documenting __ab_c_size()

__ab_c_size() is a somewhat opaque name. Document its purpose, and while
at it, rename the parameters to actually match the abc naming.

 [ bp: glued a complete patch from chunks on LKML. ]

Reported-by: Borislav Petkov <bp@...e.de>
Signed-off-by: Rasmus Villemoes <linux@...musvillemoes.dk>
Signed-off-by: Borislav Petkov <bp@...e.de>
Acked-by: Kees Cook <keescook@...omium.org>
Cc: Matthew Wilcox <willy@...radead.org>
Link: https://lkml.kernel.org/r/20190405045711.30339-1-bp@alien8.de
---
 include/linux/overflow.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/overflow.h b/include/linux/overflow.h
index 40b48e2133cb..6534a727cadb 100644
--- a/include/linux/overflow.h
+++ b/include/linux/overflow.h
@@ -278,11 +278,15 @@ static inline __must_check size_t array3_size(size_t a, size_t b, size_t c)
 	return bytes;
 }
 
-static inline __must_check size_t __ab_c_size(size_t n, size_t size, size_t c)
+/*
+ * Compute a*b+c, returning SIZE_MAX on overflow. Internal helper for
+ * struct_size() below.
+ */
+static inline __must_check size_t __ab_c_size(size_t a, size_t b, size_t c)
 {
 	size_t bytes;
 
-	if (check_mul_overflow(n, size, &bytes))
+	if (check_mul_overflow(a, b, &bytes))
 		return SIZE_MAX;
 	if (check_add_overflow(bytes, c, &bytes))
 		return SIZE_MAX;

Powered by blists - more mailing lists