Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1935272ybl; Sat, 31 Aug 2019 05:05:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJTYb2kAFtTBC4v6hGZjYu3mgwFuz0hYB5U3p3qv2nYznGqPgtQosmXBeYRVp8mDBz+wPJ X-Received: by 2002:aa7:92d1:: with SMTP id k17mr23092013pfa.160.1567253102597; Sat, 31 Aug 2019 05:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567253102; cv=none; d=google.com; s=arc-20160816; b=MGrA6E88wEJ/DucwQwVZHoaa2wdOSfAIvQkJ+3UmZkYk39zEeNZ3ClY6dGjJDiXSr+ +JIVuXFrfLh5yyk6tyofPqr2Zd0LXBfn9iH6IC+/CqMJQf1zOFjn0amXBp5YEBvam15+ ln873RXF2DIcCgUJdjx7cut3KWBMOM+RrX7HWei7SVmlNy9bPif83f71uqB2ek+ZWPSO LZp0tRLvqSOH5t5gioHDqmNOZlWvCNqDGMsnwPkliqYx14Nk7+hxEyN2W5ckQJ022vzm XdaqKVAOqnQrsfbfpcdcFi+BX3V5pTQinrGUuJbdCV4ErR2vgULxvJRX25Otn4Q71ixD Ggnw== 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 :message-id:date:subject:cc:to:from; bh=Py3ZcBM//Ly57QLnFsVCrtnMaT/P3vzUDzb/44S/lVo=; b=KvwGQcD7WPwrVYLz+Ilnt5BhxqzaTf1fBcmBQyVZqbJ5qlZ7leFS/OV25mIObktl31 DZkiHOansBzU6kwfV46ZZ46SY9qboMzA0q9scs3jFpxh5hktyK2vOe9wll0Uh0zFYmdX ANlJGnvxiXWnE/nt6LnVMOwUNgZlJrhotV8eAexULJ17ImFIJAhYHe9yh5p5WkbuDH92 3pe/wICFguh7gKEFNBwoCWRqcZmgjeah+a87U+gSEP4BVqI5K99C3dfuhSk4FM029k4q ybXwkg+cr+vqh+HyuMVx8dTVfyBZ5uec3xaHatkB5o53E6VikVSZBlQHrN+58ud/pQGh +ZsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 w11si9383353pfj.59.2019.08.31.05.04.26; Sat, 31 Aug 2019 05:05:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726453AbfHaMEZ (ORCPT + 99 others); Sat, 31 Aug 2019 08:04:25 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:48774 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726354AbfHaMEZ (ORCPT ); Sat, 31 Aug 2019 08:04:25 -0400 X-Greylist: delayed 501 seconds by postgrey-1.27 at vger.kernel.org; Sat, 31 Aug 2019 08:04:24 EDT Received: from localhost.localdomain (p57BC9339.dip0.t-ipconnect.de [87.188.147.57]) by mail.bugwerft.de (Postfix) with ESMTPSA id 07A9A29F9FC; Sat, 31 Aug 2019 11:51:42 +0000 (UTC) From: Daniel Mack To: mpm@selenic.com, herbert@gondor.apana.org.au, gregkh@linuxfoundation.org Cc: linux-crypto@vger.kernel.org, Daniel Mack Subject: [PATCH] hw_random: timeriomem_rng: relax check on memory resource size Date: Sat, 31 Aug 2019 13:55:55 +0200 Message-Id: <20190831115555.11708-1-daniel@zonque.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The timeriomem_rng driver only accesses the first 4 bytes of the given memory area and currently, it also forces that memory resource to be exactly 4 bytes in size. This, however, is problematic when used with device-trees that are generated from things like FPGA toolchains, where the minimum size of an exposed memory block may be something like 4k. Hence, let's only check for what's needed for the driver to operate properly; namely that we have enough memory available to read the random data from. Signed-off-by: Daniel Mack --- Documentation/devicetree/bindings/rng/timeriomem_rng.txt | 2 +- drivers/char/hw_random/timeriomem-rng.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/rng/timeriomem_rng.txt b/Documentation/devicetree/bindings/rng/timeriomem_rng.txt index 214940093b55..fb4846160047 100644 --- a/Documentation/devicetree/bindings/rng/timeriomem_rng.txt +++ b/Documentation/devicetree/bindings/rng/timeriomem_rng.txt @@ -12,7 +12,7 @@ Optional properties: which disables using this rng to automatically fill the kernel's entropy pool. -N.B. currently 'reg' must be four bytes wide and aligned +N.B. currently 'reg' must be at least four bytes wide and 32-bit aligned Example: diff --git a/drivers/char/hw_random/timeriomem-rng.c b/drivers/char/hw_random/timeriomem-rng.c index f615684028af..dc0194d85d80 100644 --- a/drivers/char/hw_random/timeriomem-rng.c +++ b/drivers/char/hw_random/timeriomem-rng.c @@ -120,9 +120,9 @@ static int timeriomem_rng_probe(struct platform_device *pdev) if (!res) return -ENXIO; - if (res->start % 4 != 0 || resource_size(res) != 4) { + if (res->start % 4 != 0 || resource_size(res) < 4) { dev_err(&pdev->dev, - "address must be four bytes wide and aligned\n"); + "address must be at least four bytes wide and 32-bit aligned\n"); return -EINVAL; } -- 2.21.0