[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3e720964-6f71-b325-8929-874e61666892@infradead.org>
Date: Sat, 18 Jun 2022 18:26:12 -0700
From: Randy Dunlap <rdunlap@...radead.org>
To: Zhang Boyang <zhangboyang.id@...il.com>,
linux-kernel@...r.kernel.org
Cc: Ferdinand Blomqvist <ferdinand.blomqvist@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
Kees Cook <keescook@...omium.org>,
Ivan Djelic <ivan.djelic@...rot.com>,
Boris Brezillon <boris.brezillon@...tlin.com>,
Miquel Raynal <miquel.raynal@...tlin.com>
Subject: Re: [PATCH v2 5/5] rslib: Fix integer overflow on large fcr or prim
Hi--
Somehow some of the kernel-doc notation in these files has been
entered incorrectly and you are propagating that mistake...
Please see below for more.
On 6/17/22 07:46, Zhang Boyang wrote:
> Signed-off-by: Zhang Boyang <zhangboyang.id@...il.com>
> ---
> include/linux/rslib.h | 22 ++++++++++++
> lib/reed_solomon/decode_rs.c | 60 +++++++++++++++++++--------------
> lib/reed_solomon/reed_solomon.c | 30 ++++++++++++-----
> lib/reed_solomon/test_rslib.c | 8 ++---
> 4 files changed, 82 insertions(+), 38 deletions(-)
>
> diff --git a/include/linux/rslib.h b/include/linux/rslib.h
> index 44ec7c6f24b2..29abfb2de257 100644
> --- a/include/linux/rslib.h
> +++ b/include/linux/rslib.h
> @@ -127,6 +129,26 @@ static inline int rs_modnn(struct rs_codec *rs, int x)
> return x;
> }
>
> +/** modulo replacement for galois field arithmetics
/**
* rs_modnn_mul() - modulo replacement for galois field arithmetics
> + *
> + * @rs: Pointer to the RS codec
> + * @a: 0 <= a <= nn ; a*b is the value to reduce
> + * @b: 0 <= b <= nn ; a*b is the value to reduce
> + *
> + * Same as rs_modnn(a*b), but avoid interger overflow when calculating a*b
integer a * b
> +*/
> +static inline int rs_modnn_mul(struct rs_codec *rs, int a, int b)
> +{
> + /* nn <= 0xFFFF, so (a * b) will not overflow uint32_t */
> + uint32_t x = (uint32_t)a * (uint32_t)b;
> + uint32_t nn = (uint32_t)rs->nn;
> + while (x >= nn) {
> + x -= nn;
> + x = (x >> rs->mm) + (x & nn);
> + }
> + return (int)x;
> +}
> +
> /** modulo replacement for galois field arithmetics
/**
* rs_modnn() - modulo replacement for galois field arithmetics
> *
> * @rs: Pointer to the RS codec
--
~Randy
Powered by blists - more mailing lists