From patchwork Tue Nov 8 12:37:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 13036222 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D84CC4332F for ; Tue, 8 Nov 2022 12:39:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=UkpRuyV5vQdNCRkIPIgwQq34TPSfXoIkecOTq7GBYBg=; b=lfDgoiHQY6M1ma bU/etHI3ZiHA+X1ZA9bjIj36NXUVhHuLrJvW6dKacD8wLCzZVIdzgoL1ADa6qr/4+qU69/plzzb38 sWyl+ULu4aLGuuJI0wlUdfvTW6agI8fvfhfcHHmlTpnoIkIwZ4zyABqr17Wsgark1i9GD0OCC8Ox7 m/re1X+nl6z79Y1frPSuTTaDUsppoje+ZcArtpnpn58JBv16w4HzRkTFYWl1XYiKuS9znmft+9YmR h7/GKPosQfFntoc9LwIfhvHYUuH0wFJJRX0GZctUznLlgof1HcZwgwrbbA1fZ8Nvpsb6LlI3nDoRA hL7ripmKpSt0OHFNYyMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1osNrx-005GmL-8n; Tue, 08 Nov 2022 12:38:21 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1osNru-005Glb-7Q for linux-arm-kernel@lists.infradead.org; Tue, 08 Nov 2022 12:38:19 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8BB5AB81A9C; Tue, 8 Nov 2022 12:38:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F421C433D6; Tue, 8 Nov 2022 12:38:14 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="OLxlnuHB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1667911092; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=9uRK7wMr7Y44nZE6XoPp8VtGCCuJKO228edFPqgNojo=; b=OLxlnuHBDuXNTQOvr+YyCidRIfsBFwbL91Hy82KeAOIzDCsJD+YCfcpRpZn+Z1kmXAsJ74 dj+1Dk2XKV+1f4Xm/6XmoSklg6vTuvZK+VF6F5X/odNL05Y78Zt4Dcm7FIUvhRaONNyaWp SaxK9jlqzgR0IvVgza8cphFR5WlKRxw= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 4ac5c731 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 8 Nov 2022 12:38:11 +0000 (UTC) From: "Jason A. Donenfeld" To: linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.org, arnd@arndb.de, olof@lixom.net, soc@kernel.org, linux@armlinux.org.uk Cc: "Jason A. Donenfeld" , stable@vger.kernel.org, kernel test robot Subject: [PATCH RESEND] ARM: ux500: do not directly dereference __iomem Date: Tue, 8 Nov 2022 13:37:55 +0100 Message-Id: <20221108123755.207438-1-Jason@zx2c4.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221108_043818_428122_DCCF6149 X-CRM114-Status: GOOD ( 14.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Sparse reports that calling add_device_randomness() on `uid` is a violation of address spaces. And indeed the next usage uses readl() properly, but that was left out when passing it toadd_device_ randomness(). So instead copy the whole thing to the stack first. Fixes: 4040d10a3d44 ("ARM: ux500: add DB serial number to entropy pool") Cc: Linus Walleij Cc: stable@vger.kernel.org Link: https://lore.kernel.org/all/202210230819.loF90KDh-lkp@intel.com/ Reported-by: kernel test robot Signed-off-by: Jason A. Donenfeld --- drivers/soc/ux500/ux500-soc-id.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/soc/ux500/ux500-soc-id.c b/drivers/soc/ux500/ux500-soc-id.c index a9472e0e5d61..27d6e25a0115 100644 --- a/drivers/soc/ux500/ux500-soc-id.c +++ b/drivers/soc/ux500/ux500-soc-id.c @@ -167,20 +167,18 @@ ATTRIBUTE_GROUPS(ux500_soc); static const char *db8500_read_soc_id(struct device_node *backupram) { void __iomem *base; - void __iomem *uid; const char *retstr; + u32 uid[5]; base = of_iomap(backupram, 0); if (!base) return NULL; - uid = base + 0x1fc0; + memcpy_fromio(uid, base + 0x1fc0, sizeof(uid)); /* Throw these device-specific numbers into the entropy pool */ - add_device_randomness(uid, 0x14); + add_device_randomness(uid, sizeof(uid)); retstr = kasprintf(GFP_KERNEL, "%08x%08x%08x%08x%08x", - readl((u32 *)uid+0), - readl((u32 *)uid+1), readl((u32 *)uid+2), - readl((u32 *)uid+3), readl((u32 *)uid+4)); + uid[0], uid[1], uid[2], uid[3], uid[4]); iounmap(base); return retstr; }