All of lore.kernel.org
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: Zhang Boyang <zhangboyang.id@gmail.com>, linux-kernel@vger.kernel.org
Cc: Ferdinand Blomqvist <ferdinand.blomqvist@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Kees Cook <keescook@chromium.org>,
	Ivan Djelic <ivan.djelic@parrot.com>,
	Boris Brezillon <boris.brezillon@bootlin.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>
Subject: Re: [PATCH v2 5/5] rslib: Fix integer overflow on large fcr or prim
Date: Sat, 18 Jun 2022 18:26:12 -0700	[thread overview]
Message-ID: <3e720964-6f71-b325-8929-874e61666892@infradead.org> (raw)
In-Reply-To: <20220617144624.158973-6-zhangboyang.id@gmail.com>

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@gmail.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

      reply	other threads:[~2022-06-19  1:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17 14:46 rslib: Several improvements Zhang Boyang
2022-06-17 14:46 ` [PATCH v2 1/5] rslib: Fix incorrect documentation of rs_modnn() Zhang Boyang
2022-06-17 14:46 ` [PATCH v2 2/5] rslib: Fix obvious documentation mistakes Zhang Boyang
2022-06-17 14:46 ` [PATCH v2 3/5] rslib: Replace hard-coded 1 with alpha_to[0] Zhang Boyang
2022-06-17 14:46 ` [PATCH v2 4/5] rslib: Improve the performance of encode_rs.c Zhang Boyang
2022-06-19  1:29   ` Randy Dunlap
2022-06-17 14:46 ` [PATCH v2 5/5] rslib: Fix integer overflow on large fcr or prim Zhang Boyang
2022-06-19  1:26   ` Randy Dunlap [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3e720964-6f71-b325-8929-874e61666892@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=boris.brezillon@bootlin.com \
    --cc=ferdinand.blomqvist@gmail.com \
    --cc=ivan.djelic@parrot.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=tglx@linutronix.de \
    --cc=zhangboyang.id@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.