Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp443792imm; Tue, 3 Jul 2018 23:18:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfhyU0g/Z+ayNCaM8bnvp9W84k0ZvN5QkKHCEPd8XlpEegEWfGTO0p+WojMfefiSrCJ71Wf X-Received: by 2002:a63:6092:: with SMTP id u140-v6mr668868pgb.433.1530685101632; Tue, 03 Jul 2018 23:18:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530685101; cv=none; d=google.com; s=arc-20160816; b=IXZY7Y2dU8grBa7RE84Cf4Ttrpu0V1iZybK4hZVyWioeIuK7gRV27SX0bmx/lPvwMQ L21QD+PJM+aZQQ7KFXJyKut62iXARc8d1/yVWtKgeQ2x9/gy976TSQBjZhbIYt3rEf2+ naaTIlfuwTgHEgxYiW+S28eh94kywrAWiK3iXk2yxC/pDBvG3wjdV0In/kqLQbO/P8az lISoUzDOk7DUZ+WykscOlnKnyb7lvhg0figLd8RJfF5WAhFJbM791m17mkaYem7bC+ae Ox/YH5tDwRVLF9go5h6JlrnfgdyzaR5vDFURMzig0Url6SpGzOt75SfxK+XTRvmEzxKQ h3/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=YjKD8OXrCs3fNtPVis7IK2pWTSZo+eF7j0s4yztq97A=; b=ibApdQ0bINAm7tLscOkYdSngkkJ/9YDHBtni/Nlt3isDptdACuRLtAm4y2jmHZzi4c D56fy14DaMehitkHACzEgyK4ET1ZUh4WEOV4jjWjDhhQjGdQbUg9i6H6aBj25iP0XiIr 1YZjq1LwQYfPhtrHetC93hPd2VbahokXgk3MtCWZXcCcXDZLVszWrXNXDb4oZi7/C1EC i1AU1rqBG6bzQLncDhBDsB15e0FuB17AfYwJ4A5WtIJCvG5dtIG7EV5dv1aoWb6B/2NT EFrPXIxP7AJc8ZBgON4/ozxjI/V19M/FVKwLsKU2KF1Cjugs/bcGdSRHqKmKYHte23qw Zdaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chronox.de header.s=strato-dkim-0002 header.b=S349S7ZE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a10-v6si2820997pli.122.2018.07.03.23.18.07; Tue, 03 Jul 2018 23:18:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@chronox.de header.s=strato-dkim-0002 header.b=S349S7ZE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933284AbeGDGQq (ORCPT + 99 others); Wed, 4 Jul 2018 02:16:46 -0400 Received: from mo4-p01-ob.smtp.rzone.de ([85.215.255.50]:21864 "EHLO mo4-p01-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932204AbeGDGQp (ORCPT ); Wed, 4 Jul 2018 02:16:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1530685003; s=strato-dkim-0002; d=chronox.de; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=YjKD8OXrCs3fNtPVis7IK2pWTSZo+eF7j0s4yztq97A=; b=S349S7ZEg1ky7+3fU1CtV2oWpRZ/pafC6LEuyAIVASPAPpd+dF+6I/JYRG5PIyDh04 LCkGCyvqBTxM+FvKWKu0EfwWjcja4iJfgdZiAKaelu0+Jr6WSVage1WXC63AjcMJKS6m sBKRCjMhovIgvkH37BJ71OdekFGuSsdkza+XBoj7SnfX2Nz632A+80F83MmEqQGGGTOP ZR2P0i8hyARA7ccu2QGND1pSlAU1dPlY7+60ayMM0eA/S34BOXEbrHV7pCy5sqr09657 /kqa/+Py8MQbzQVcD6SWB/i9Yt7eESkJhTJZFugAtIj/5A5cKTyA4NOVfc+LWxfeS+3e gT8A== X-RZG-AUTH: ":P2ERcEykfu11Y98lp/T7+hdri+uKZK8TKWEqNyiHySGSa9k9zT8DNpa83PTIZGritxBCMxjzJPOoq+WpsG/2//HRFk/qN+Jd3w==" X-RZG-CLASS-ID: mo00 Received: from tauon.chronox.de by smtp.strato.de (RZmta 43.11 AUTH) with ESMTPSA id n00f9fu646GR3jI (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Wed, 4 Jul 2018 08:16:27 +0200 (CEST) From: Stephan Mueller To: Vinod Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson , Matt Mackall , Herbert Xu , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Stephen Boyd , Timur Tabi Subject: Re: [PATCH v3 3/6] crypto: Add Qcom prng driver Date: Wed, 04 Jul 2018 08:16:25 +0200 Message-ID: <2060153.p9Cf2LoRhr@tauon.chronox.de> In-Reply-To: <20180704061035.GY22377@vkoul-mobl> References: <20180703060434.19293-1-vkoul@kernel.org> <20180704041059.GT22377@vkoul-mobl> <20180704061035.GY22377@vkoul-mobl> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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