From: LABBE Corentin <clabbe.montjoie@gmail.com>
To: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
Cc: mpm@selenic.com, "Herbert Xu" <herbert@gondor.apana.org.au>,
robh+dt@kernel.org, mark.rutland@arm.com,
"Ralf Baechle" <ralf@linux-mips.org>,
davem@davemloft.net, geert@linux-m68k.org,
"Andrew Morton" <akpm@linux-foundation.org>,
"Greg KH" <gregkh@linuxfoundation.org>,
mchehab@kernel.org, "Guenter Roeck" <linux@roeck-us.net>,
boris.brezillon@free-electrons.com, harvey.hunt@imgtec.com,
alex.smith@imgtec.com,
"Daniel Thompson" <daniel.thompson@linaro.org>,
"Lee Jones" <lee.jones@linaro.org>,
"Florian Fainelli" <f.fainelli@gmail.com>,
kieran@ksquared.org.uk, "Krzysztof Kozlowski" <krzk@kernel.org>,
joshua.henderson@microchip.com, yendapally.reddy@broadcom.com,
narmstrong@baylibre.com, wangkefeng.wang@huawei.com,
"Christian Lamparter" <chunkeey@googlemail.com>,
"Álvaro Fernández Rojas" <noltari@gmail.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
pankaj.dev@st.com, "Mathieu Poirier" <mathieu.poirier@linaro.org>,
linux-crypto@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mips@linux-mips.org
Subject: Re: [PATCH] Add Ingenic JZ4780 hardware RNG driver
Date: Thu, 18 Aug 2016 13:53:00 +0200 [thread overview]
Message-ID: <20160818115300.GA6621@Red> (raw)
In-Reply-To: <CANc+2y55ZCkauwKNtuuCxLx-WOtm8z+A_EBKsYSjEUdc+ZbZTQ@mail.gmail.com>
On Thu, Aug 18, 2016 at 10:44:18AM +0530, PrasannaKumar Muralidharan wrote:
> >> +static int jz4780_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
> >> +{
> >> + struct jz4780_rng *jz4780_rng = container_of(rng, struct jz4780_rng,
> >> + rng);
> >> + u32 *data = buf;
> >> + *data = jz4780_rng_readl(jz4780_rng, REG_RNG_DATA);
> >> + return 4;
> >> +}
> >
> > If max is less than 4, its bad
>
> Data will be 4 bytes.
>
No, according to comment in include/linux/hw_random.h "drivers can fill up to max bytes of data"
So you cannot write more than max bytes without risking buffer overflow.
And if max > 4, hwrng client need to recall your read function.
The better example I found is tpm_get_random() in drivers/char/tpm/tpm-interface.c for handling both problem.
Regards
next prev parent reply other threads:[~2016-08-18 11:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-17 15:35 [PATCH] Add Ingenic JZ4780 hardware RNG driver PrasannaKumar Muralidharan
2016-08-17 16:01 ` Daniel Thompson
2016-08-17 16:13 ` PrasannaKumar Muralidharan
2016-08-17 19:06 ` Corentin LABBE
2016-08-18 5:14 ` PrasannaKumar Muralidharan
2016-08-18 11:53 ` LABBE Corentin [this message]
2016-08-18 12:19 ` Daniel Thompson
2016-08-19 0:59 ` Rob Herring
2016-08-19 9:47 ` Jeffrey Walton
2016-08-19 12:54 ` PrasannaKumar Muralidharan
2016-08-19 10:55 ` Jeffrey Walton
2016-08-19 13:09 ` PrasannaKumar Muralidharan
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=20160818115300.GA6621@Red \
--to=clabbe.montjoie@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alex.smith@imgtec.com \
--cc=boris.brezillon@free-electrons.com \
--cc=chunkeey@googlemail.com \
--cc=daniel.thompson@linaro.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=harvey.hunt@imgtec.com \
--cc=herbert@gondor.apana.org.au \
--cc=joshua.henderson@microchip.com \
--cc=kieran@ksquared.org.uk \
--cc=krzk@kernel.org \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linux@roeck-us.net \
--cc=mark.rutland@arm.com \
--cc=mathieu.poirier@linaro.org \
--cc=mchehab@kernel.org \
--cc=mpm@selenic.com \
--cc=narmstrong@baylibre.com \
--cc=noltari@gmail.com \
--cc=pankaj.dev@st.com \
--cc=prasannatsmkumar@gmail.com \
--cc=ralf@linux-mips.org \
--cc=robh+dt@kernel.org \
--cc=wangkefeng.wang@huawei.com \
--cc=yendapally.reddy@broadcom.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).