From patchwork Sat Oct 22 13:53:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 9390749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 20D6E600CB for ; Sat, 22 Oct 2016 13:58:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12AF828C6E for ; Sat, 22 Oct 2016 13:58:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04C4C28C78; Sat, 22 Oct 2016 13:58:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ABA2428C6E for ; Sat, 22 Oct 2016 13:58:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bxwmU-0007G2-TC; Sat, 22 Oct 2016 13:56:14 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bxwmQ-0007DX-W7 for linux-arm-kernel@lists.infradead.org; Sat, 22 Oct 2016 13:56:11 +0000 Received: by mail-wm0-x241.google.com with SMTP id d128so2837145wmf.0 for ; Sat, 22 Oct 2016 06:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=r1pK6aB98hLqkbHK69/ELhUPpD8DcvuPuIZkEJd+Njk=; b=dD0hN2xyh01xgueurR7UNNCdYdiBfzxNB+E8fd2oE3kYH9mjD5uRlodjGtm0v4i+tf G6F3yKPzuaZW8UG/5VbhamnXc8m8/BKanau7VvljtDDwQ1rDTrkelWvI+M1a6qbaZsqI L2AlpLmoiUTcM8LoHD8QfxmLjlpCKm1o6o2pR/2Mg3jeS7pf2xVlWCPF4T2vL4Dy1de8 urrPKXDj02vYOITVJ0+jh1aX3fO+rmbe/1WuK1kTEQd/SRQd8ptIE8npLbGODxjECKNk 0ivhDM2I3pBGzP5c4RHVJzLVNJaTblkdqzedoywtpKqC6FOpAj7vQSwzGQo+OYBM5HDT 1K6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=r1pK6aB98hLqkbHK69/ELhUPpD8DcvuPuIZkEJd+Njk=; b=Q35GBlJthBWZAIUtYbazwqD/c7uA2RR18ATjtIoqQcZ+veKv5E8Vourfz1gl+GMRv1 yH/q88xHIn4HaWayZdvspJGbJchCApfmXWipFJCt7Irtm24noPoL5513hmBmGlqHb8p8 3Wc4O8PGI6tlvGZl20gKP99qI/Wtz2DVl1vCjMt6WWvetANuqMb1oZmSpzMm1ZNJRV2N yiAVnafZ9oRO3UFvv7XuyT4OOYdLwkBv14tLyHCS/XtrbeUVN7REJ+wMULoAPBXYUYR2 eJt6w61uP3C1+xi4+oQAAW/xD8Esu1dOmql4q6MG6OL7e8DwCrxL106JuZMiev7xG4Lj XZ5A== X-Gm-Message-State: ABUngve9iskpnQ0dzwLcJONzJ8wflqz740X1JqxXEfyP4eikkcico4HYeg/0LDEAyPQG5A== X-Received: by 10.194.55.65 with SMTP id q1mr4599950wjp.45.1477144548770; Sat, 22 Oct 2016 06:55:48 -0700 (PDT) Received: from Red.local (LFbn-1-7035-57.w90-116.abo.wanadoo.fr. [90.116.208.57]) by smtp.googlemail.com with ESMTPSA id q134sm3951900wme.3.2016.10.22.06.55.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 22 Oct 2016 06:55:48 -0700 (PDT) From: Corentin Labbe To: srinivas.kandagatla@linaro.org, maxime.ripard@free-electrons.com, wens@csie.org Subject: [PATCH] nvmem: sunxi-sid: SID content is not a valid source of randomness Date: Sat, 22 Oct 2016 15:53:28 +0200 Message-Id: <1477144408-15896-1-git-send-email-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.7.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161022_065611_245400_1B1FDB0A X-CRM114-Status: GOOD ( 12.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corentin Labbe , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Since SID's content is constant over reboot, it must not be used as source of randomness. This patch remove the use of SID content as source of randomness. Signed-off-by: Corentin Labbe --- drivers/nvmem/sunxi_sid.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/drivers/nvmem/sunxi_sid.c b/drivers/nvmem/sunxi_sid.c index 1567ccc..c82d5d1 100644 --- a/drivers/nvmem/sunxi_sid.c +++ b/drivers/nvmem/sunxi_sid.c @@ -21,8 +21,6 @@ #include #include #include -#include -#include static struct nvmem_config econfig = { .name = "sunxi-sid", @@ -70,8 +68,6 @@ static int sunxi_sid_probe(struct platform_device *pdev) struct resource *res; struct nvmem_device *nvmem; struct sunxi_sid *sid; - int ret, i, size; - char *randomness; sid = devm_kzalloc(dev, sizeof(*sid), GFP_KERNEL); if (!sid) @@ -82,7 +78,6 @@ static int sunxi_sid_probe(struct platform_device *pdev) if (IS_ERR(sid->base)) return PTR_ERR(sid->base); - size = resource_size(res) - 1; econfig.size = resource_size(res); econfig.dev = dev; econfig.reg_read = sunxi_sid_read; @@ -91,25 +86,9 @@ static int sunxi_sid_probe(struct platform_device *pdev) if (IS_ERR(nvmem)) return PTR_ERR(nvmem); - randomness = kzalloc(sizeof(u8) * (size), GFP_KERNEL); - if (!randomness) { - ret = -EINVAL; - goto err_unreg_nvmem; - } - - for (i = 0; i < size; i++) - randomness[i] = sunxi_sid_read_byte(sid, i); - - add_device_randomness(randomness, size); - kfree(randomness); - platform_set_drvdata(pdev, nvmem); return 0; - -err_unreg_nvmem: - nvmem_unregister(nvmem); - return ret; } static int sunxi_sid_remove(struct platform_device *pdev)