public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephan Mueller <smueller@chronox.de>
To: Vinod <vkoul@kernel.org>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Matt Mackall <mpm@selenic.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-arm-msm@vger.kernel.org, Stephen Boyd <swboyd@chromium.org>,
	Timur Tabi <timur@codeaurora.org>
Subject: Re: [PATCH v3 3/6] crypto: Add Qcom prng driver
Date: Wed, 04 Jul 2018 08:16:25 +0200	[thread overview]
Message-ID: <2060153.p9Cf2LoRhr@tauon.chronox.de> (raw)
In-Reply-To: <20180704061035.GY22377@vkoul-mobl>

Am Mittwoch, 4. Juli 2018, 08:10:35 CEST schrieb Vinod:

Hi Vinod,

> On 04-07-18, 09:40, Vinod wrote:
> > Hi Stephan,
> > 
> > On 03-07-18, 15:28, Stephan Mueller wrote:
> > > Am Dienstag, 3. Juli 2018, 08:04:31 CEST schrieb Vinod Koul:
> > > > +static int qcom_rng_read(struct qcom_rng *rng, void *data, size_t
> > > > max)
> > > > +{
> > > > +	size_t currsize = 0;
> > > > +	u32 *retdata = data;
> > > 
> > > How can you be sure that this cast is appropriate? I.e. how is it
> > > guaranteed that data is 4-byte aligned?
> > 
> > While reading we check the alignment:
> >                /* make sure we stay on 32bit boundary */
> >                if ((max - currsize) < WORD_SZ)
> >                
> >                        break;

I am not sure I follow your argument.

You cast a void (or u8 pointer into u32:

+       u32 *retdata = data;

You use it:

+       *retdata++ = val;

Followed by your check.

What I mean is that the initial cast and then the subsequent write operation 
is only guaranteed to work if the initial pointer is alighed on a 4 byte 
boundary. However, since it is an u8 pointer, it is not guaranteed to be 
aligned.

So, I guess you want to use memcpy (at least if it is not aligned).

Ciao
Stephan

  reply	other threads:[~2018-07-04  6:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-03  6:04 [PATCH v3 0/6] crypto: Add Qcom PRNG support Vinod Koul
2018-07-03  6:04 ` [PATCH v3 1/6] hwrng: remove msm hw_random driver Vinod Koul
2018-07-03  6:04 ` [PATCH v3 2/6] dt-bindings: crypto: Move prng binding to crypto Vinod Koul
2018-07-03  6:04 ` [PATCH v3 3/6] crypto: Add Qcom prng driver Vinod Koul
2018-07-03 13:28   ` Stephan Mueller
2018-07-04  4:10     ` Vinod
2018-07-04  6:10       ` Vinod
2018-07-04  6:16         ` Stephan Mueller [this message]
2018-07-04 13:42         ` Timur Tabi
2018-07-04 16:02   ` Stephan Mueller
2018-07-05  6:01     ` Vinod
2018-07-03  6:04 ` [PATCH v3 4/6] dt-bindings: crypto: Add new compatible qcom,prng-ee Vinod Koul
2018-07-03  6:04 ` [PATCH v3 5/6] crypto: qcom: Add support for prng-ee Vinod Koul
2018-07-03  6:04 ` [PATCH v3 6/6] crypto: qcom: Add ACPI support Vinod Koul
2018-07-03 14:10   ` Timur Tabi
2018-07-04  4:11     ` Vinod
2018-07-03 17:08   ` Jeffrey Hugo
2018-07-04  4:13     ` Vinod
2018-07-05 14:26       ` Jeffrey Hugo

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=2060153.p9Cf2LoRhr@tauon.chronox.de \
    --to=smueller@chronox.de \
    --cc=arnd@arndb.de \
    --cc=bjorn.andersson@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=swboyd@chromium.org \
    --cc=timur@codeaurora.org \
    --cc=vkoul@kernel.org \
    /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