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]
Message-ID: <ZdOJv3Dz2JVs6hhG@FVFF77S0Q05N>
Date: Mon, 19 Feb 2024 17:02:55 +0000
From: Mark Rutland <mark.rutland@....com>
To: Kees Cook <keescook@...omium.org>
Cc: Andy Shevchenko <andy@...nel.org>,
	"Gustavo A . R . Silva" <gustavoars@...nel.org>,
	linux-hardening@...r.kernel.org,
	Rasmus Villemoes <rasmus.villemoes@...vas.dk>,
	Marco Elver <elver@...gle.com>, Eric Biggers <ebiggers@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v7 1/3] overflow: Adjust check_*_overflow() kern-doc to
 reflect results

On Wed, Feb 14, 2024 at 11:46:01AM -0800, Kees Cook wrote:
> The check_*_overflow() helpers will return results with potentially
> wrapped-around values. These values have always been checked by the
> selftests, so avoid the confusing language in the kern-doc. The idea of
> "safe for use" was relative to the expectation of whether or not the
> caller wants a wrapped value -- the calculation itself will always follow
> arithmetic wrapping rules.
> 
> Reviewed-by: Gustavo A. R. Silva <gustavoars@...nel.org>
> Signed-off-by: Kees Cook <keescook@...omium.org>
> ---
> Cc: Mark Rutland <mark.rutland@....com>
> Cc: linux-hardening@...r.kernel.org

Acked-by: Mark Rutland <mark.rutland@....com>

Mark.

> ---
>  include/linux/overflow.h | 21 +++++++++------------
>  1 file changed, 9 insertions(+), 12 deletions(-)
> 
> diff --git a/include/linux/overflow.h b/include/linux/overflow.h
> index 7b5cf4a5cd19..ad64d810c8aa 100644
> --- a/include/linux/overflow.h
> +++ b/include/linux/overflow.h
> @@ -57,11 +57,10 @@ static inline bool __must_check __must_check_overflow(bool overflow)
>   * @b: second addend
>   * @d: pointer to store sum
>   *
> - * Returns 0 on success.
> + * Returns true on wrap-around, false otherwise.
>   *
> - * *@d holds the results of the attempted addition, but is not considered
> - * "safe for use" on a non-zero return value, which indicates that the
> - * sum has overflowed or been truncated.
> + * *@d holds the results of the attempted addition, regardless of whether
> + * wrap-around occurred.
>   */
>  #define check_add_overflow(a, b, d)	\
>  	__must_check_overflow(__builtin_add_overflow(a, b, d))
> @@ -72,11 +71,10 @@ static inline bool __must_check __must_check_overflow(bool overflow)
>   * @b: subtrahend; value to subtract from @a
>   * @d: pointer to store difference
>   *
> - * Returns 0 on success.
> + * Returns true on wrap-around, false otherwise.
>   *
> - * *@d holds the results of the attempted subtraction, but is not considered
> - * "safe for use" on a non-zero return value, which indicates that the
> - * difference has underflowed or been truncated.
> + * *@d holds the results of the attempted subtraction, regardless of whether
> + * wrap-around occurred.
>   */
>  #define check_sub_overflow(a, b, d)	\
>  	__must_check_overflow(__builtin_sub_overflow(a, b, d))
> @@ -87,11 +85,10 @@ static inline bool __must_check __must_check_overflow(bool overflow)
>   * @b: second factor
>   * @d: pointer to store product
>   *
> - * Returns 0 on success.
> + * Returns true on wrap-around, false otherwise.
>   *
> - * *@d holds the results of the attempted multiplication, but is not
> - * considered "safe for use" on a non-zero return value, which indicates
> - * that the product has overflowed or been truncated.
> + * *@d holds the results of the attempted multiplication, regardless of whether
> + * wrap-around occurred.
>   */
>  #define check_mul_overflow(a, b, d)	\
>  	__must_check_overflow(__builtin_mul_overflow(a, b, d))
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ