From: Jonathan Cameron <jic23@kernel.org>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org
Subject: Re: [PATCH 2/4] iio: magnetometer: ak8974: add_device_randomness(fw + serial)
Date: Sun, 20 Aug 2017 11:22:42 +0100 [thread overview]
Message-ID: <20170820112242.3008c3f8@archlinux> (raw)
In-Reply-To: <a90b0e9c8886114903498890a0ae2c66cb19b5f3.1502977929.git.mirq-linux@rere.qmqm.pl>
On Thu, 17 Aug 2017 15:56:11 +0200
Michał Mirosław <mirq-linux@rere.qmqm.pl> wrote:
> Mix device-specific data into randomness pool.
>
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Hmm. I wondered about the firmware version as a source of randomness, but
will leave it in here.
Applied to the togreg branch of iio.git and pushed out as testing.
Thanks,
Jonathan
> ---
> drivers/iio/magnetometer/ak8974.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c
> index 76091da20a0c..ab204f8560e3 100644
> --- a/drivers/iio/magnetometer/ak8974.c
> +++ b/drivers/iio/magnetometer/ak8974.c
> @@ -20,6 +20,7 @@
> #include <linux/mutex.h>
> #include <linux/delay.h>
> #include <linux/bitops.h>
> +#include <linux/random.h>
> #include <linux/regmap.h>
> #include <linux/regulator/consumer.h>
> #include <linux/pm_runtime.h>
> @@ -466,10 +467,12 @@ static int ak8974_detect(struct ak8974 *ak8974)
> ret = regmap_read(ak8974->map, AMI305_VER, &fw);
> if (ret)
> return ret;
> + add_device_randomness(&fw, sizeof(fw));
The firmware version seems rather to guessable to really count as randomness.
presumably it would constant for a particular batch of chips.
> fw &= 0x7f; /* only bits 0 thru 6 valid */
> ret = ak8974_get_u16_val(ak8974, AMI305_SN, &sn);
> if (ret)
> return ret;
> + add_device_randomness(&sn, sizeof(sn));
This is better. The serial number should be hard to guess on a particular
part.
Jonathan
> dev_info(&ak8974->i2c->dev,
> "detected %s, FW ver %02x, S/N: %04x\n",
> name, fw, sn);
next prev parent reply other threads:[~2017-08-20 10:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-17 13:56 [PATCH 0/4] iio: magnetometer: ak8974: support AMI306 Michał Mirosław
2017-08-17 13:56 ` [PATCH 1/4] iio: magnetometer: ak8974: support AMI306 variant Michał Mirosław
2017-08-20 10:19 ` Jonathan Cameron
2017-08-17 13:56 ` [PATCH 2/4] iio: magnetometer: ak8974: add_device_randomness(fw + serial) Michał Mirosław
2017-08-20 10:22 ` Jonathan Cameron [this message]
2017-08-20 11:10 ` Linus Walleij
2017-08-20 14:18 ` Jonathan Cameron
2017-08-17 13:56 ` [PATCH 3/4] iio: magnetometer: ak8974: mark INT_CLEAR as precious Michał Mirosław
2017-08-17 13:56 ` [PATCH 4/4] iio: magnetometer: ak8974: debug AMI306 calibration data Michał Mirosław
2017-08-20 10:25 ` Jonathan Cameron
2017-08-20 10:28 ` Jonathan Cameron
2017-08-20 14:40 ` Jonathan Cameron
2017-08-18 21:42 ` [PATCH 0/4] iio: magnetometer: ak8974: support AMI306 Linus Walleij
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=20170820112242.3008c3f8@archlinux \
--to=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
--cc=pmeerw@pmeerw.net \
/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).