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:   Tue, 3 Jul 2018 04:28:11 +0200
From:   Adam Borowski <kilobyte@...band.pl>
To:     Kees Cook <keescook@...omium.org>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Matthew Wilcox <willy@...radead.org>,
        Eric Biggers <ebiggers@...gle.com>,
        Randy Dunlap <rdunlap@...radead.org>,
        linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] kernel.h: Documentation for roundup() vs round_up()

On Mon, Jul 02, 2018 at 07:16:54PM -0700, Kees Cook wrote:
> Things like commit 3619dec5103d ("dh key: fix rounding up KDF output
> length") expose the lack of explicit documentation for roundup() vs
> round_up(). At least we can try to document it better if anyone goes
> looking.
> 
> Signed-off-by: Kees Cook <keescook@...omium.org>
> ---

> +/**
> + * round_up - round up to next specified power of 2
> + * @x: the value to round
> + * @y: multiple to round up to (must be a power of 2)
                                   ^^^^^^^^^^^^^^^^^^^^
This matches the description -- so far, good.
> + *
> + * Rounds @x up to next multiple of @y (which must be a power of 2).
> + * To perform arbitrary rounding up, use roundup() below.
> + */

> +/**
> + * roundup - round up to the next specified multiple
> + * @x: the value to up
> + * @y: multiple to round up to (must be a power of 2)
                                   ^^^^^^^^^^^^^^^^^^^^
But isn't this supposed to differ from the above?
> + *
> + * Rounds @x up to next multiple of @y. If @y will always be a power
> + * of 2, consider using the faster round_up().
> + *
> + * The `const' here prevents gcc-3.3 from calling __divdi3
> + */
>  #define roundup(x, y) (					\
>  {							\
>  	const typeof(y) __y = y;			\
>  	(((x) + (__y - 1)) / __y) * __y;		\
>  }							\


Meow!
-- 
⢀⣴⠾⠻⢶⣦⠀ 
⣾⠁⢰⠒⠀⣿⡁ Imagine there are bandits in your house, your kid is bleeding out,
⢿⡄⠘⠷⠚⠋⠀ the house is on fire, and seven big-ass trumpets are playing in the
⠈⠳⣄⠀⠀⠀⠀ sky.  Your cat demands food.  The priority should be obvious...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ