Re: [PATCH v3 1/2] minmax: sanity check constant bounds when clamping

From: Kees Cook
Date: Mon Sep 26 2022 - 14:27:55 EST


On Mon, Sep 26, 2022 at 03:34:34PM +0200, Jason A. Donenfeld wrote:
> The clamp family of functions only makes sense if hi>=lo. If hi and lo
> are compile-time constants, then raise a build error. Doing so has
> already caught buggy code. This also introduces the infrastructure to
> improve the clamping function in subsequent commits.
>
> Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: Kees Cook <keescook@xxxxxxxxxxxx>
> Signed-off-by: Jason A. Donenfeld <Jason@xxxxxxxxx>

Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>

--
Kees Cook