* Re: [PATCH 6/6] hw_random: credit entropy for low quality sources of randomness
@ 2022-01-25 13:52 kernel test robot
2022-01-27 5:45 ` kernel test robot
0 siblings, 1 reply; 4+ messages in thread
From: kernel test robot @ 2022-01-25 13:52 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 18113 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20220124202951.28579-6-linux@dominikbrodowski.net>
References: <20220124202951.28579-6-linux@dominikbrodowski.net>
TO: Dominik Brodowski <linux@dominikbrodowski.net>
Hi Dominik,
I love your patch! Perhaps something to improve:
[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on v5.17-rc1 next-20220125]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Dominik-Brodowski/hw_random-explicit-ordering-of-initcalls/20220125-051254
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 515a2f507491e7c3818e74ef4f4e088c1fecb190
:::::: branch date: 17 hours ago
:::::: commit date: 17 hours ago
config: riscv-randconfig-c006-20220124 (https://download.01.org/0day-ci/archive/20220125/202201252124.ZlTUIMTI-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 997e128e2a78f5a5434fc75997441ae1ee76f8a4)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/a0f46724fe340bab80dd4a8bf4a9f413c6a294f1
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dominik-Brodowski/hw_random-explicit-ordering-of-initcalls/20220125-051254
git checkout a0f46724fe340bab80dd4a8bf4a9f413c6a294f1
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
drivers/gpu/drm/nouveau/nvkm/core/mm.c:26:26: note: expanded from macro 'node'
#define node(root, dir) ((root)->nl_entry.dir == &mm->nodes) ? NULL : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/nouveau/nvkm/core/mm.c:207:10: note: '?' condition is false
next = node(this, next);
^
drivers/gpu/drm/nouveau/nvkm/core/mm.c:26:25: note: expanded from macro 'node'
#define node(root, dir) ((root)->nl_entry.dir == &mm->nodes) ? NULL : \
^
drivers/gpu/drm/nouveau/nvkm/core/mm.c:208:7: note: Assuming 'next' is null
if (next && next->type != type) {
^~~~
drivers/gpu/drm/nouveau/nvkm/core/mm.c:208:12: note: Left side of '&&' is false
if (next && next->type != type) {
^
drivers/gpu/drm/nouveau/nvkm/core/mm.c:215:7: note: Assuming 's' is <= 'e'
if (s > e || a < size_min)
^~~~~
drivers/gpu/drm/nouveau/nvkm/core/mm.c:215:7: note: Left side of '||' is false
drivers/gpu/drm/nouveau/nvkm/core/mm.c:215:16: note: Assuming 'a' is >= 'size_min'
if (s > e || a < size_min)
^~~~~~~~~~~~
drivers/gpu/drm/nouveau/nvkm/core/mm.c:215:3: note: Taking false branch
if (s > e || a < size_min)
^
drivers/gpu/drm/nouveau/nvkm/core/mm.c:218:8: note: Assuming '__UNIQUE_ID___x265' is >= '__UNIQUE_ID___y266'
a = min(a, size_max);
^
include/linux/minmax.h:45:19: note: expanded from macro 'min'
#define min(x, y) __careful_cmp(x, y, <)
^~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:38:3: note: expanded from macro '__careful_cmp'
__cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:33:3: note: expanded from macro '__cmp_once'
__cmp(unique_x, unique_y, op); })
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:28:26: note: expanded from macro '__cmp'
#define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
^~~~~~~~~~
drivers/gpu/drm/nouveau/nvkm/core/mm.c:218:8: note: '?' condition is false
a = min(a, size_max);
^
include/linux/minmax.h:45:19: note: expanded from macro 'min'
#define min(x, y) __careful_cmp(x, y, <)
^
include/linux/minmax.h:38:3: note: expanded from macro '__careful_cmp'
__cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
^
include/linux/minmax.h:33:3: note: expanded from macro '__cmp_once'
__cmp(unique_x, unique_y, op); })
^
include/linux/minmax.h:28:26: note: expanded from macro '__cmp'
#define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
^
drivers/gpu/drm/nouveau/nvkm/core/mm.c:222:7: note: Assuming 'c' is 0
if (c && !region_tail(mm, this, c))
^
drivers/gpu/drm/nouveau/nvkm/core/mm.c:222:9: note: Left side of '&&' is false
if (c && !region_tail(mm, this, c))
^
drivers/gpu/drm/nouveau/nvkm/core/mm.c:225:10: note: Calling 'region_tail'
this = region_tail(mm, this, a);
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/nouveau/nvkm/core/mm.c:165:6: note: Assuming 'size' is not equal to field 'length'
if (a->length == size)
^~~~~~~~~~~~~~~~~
drivers/gpu/drm/nouveau/nvkm/core/mm.c:165:2: note: Taking false branch
if (a->length == size)
^
drivers/gpu/drm/nouveau/nvkm/core/mm.c:169:15: note: Assuming 'b' is not equal to null
if (unlikely(b == NULL))
^
include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
# define unlikely(x) __builtin_expect(!!(x), 0)
^
drivers/gpu/drm/nouveau/nvkm/core/mm.c:169:2: note: Taking false branch
if (unlikely(b == NULL))
^
drivers/gpu/drm/nouveau/nvkm/core/mm.c:178:2: note: Calling 'list_add'
list_add(&b->nl_entry, &a->nl_entry);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:88:24: note: Passing null pointer value via 3rd parameter 'next'
__list_add(new, head, head->next);
^~~~~~~~~~
include/linux/list.h:88:2: note: Calling '__list_add'
__list_add(new, head, head->next);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:69:6: note: Assuming the condition is false
if (!__list_add_valid(new, prev, next))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:69:2: note: Taking false branch
if (!__list_add_valid(new, prev, next))
^
include/linux/list.h:72:13: note: Access to field 'prev' results in a dereference of a null pointer (loaded from variable 'next')
next->prev = new;
~~~~ ^
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
>> drivers/char/hw_random/core.c:455:4: warning: Value stored to 'entropy_credit' is never read [clang-analyzer-deadcode.DeadStores]
entropy_credit = entropy;
^ ~~~~~~~
drivers/char/hw_random/core.c:455:4: note: Value stored to 'entropy_credit' is never read
entropy_credit = entropy;
^ ~~~~~~~
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
drivers/char/hw_random/ixp4xx-rng.c:44:17: warning: Value stored to 'dev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct device *dev = &pdev->dev;
^~~ ~~~~~~~~~~
drivers/char/hw_random/ixp4xx-rng.c:44:17: note: Value stored to 'dev' during its initialization is never read
struct device *dev = &pdev->dev;
^~~ ~~~~~~~~~~
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
Suppressed 9 warnings (9 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
drivers/gpu/drm/radeon/r100.c:2557:2: warning: Value stored to 'tmp' is never read [clang-analyzer-deadcode.DeadStores]
tmp = RREG32(RADEON_BUS_CNTL);
^
drivers/gpu/drm/radeon/r100.c:2557:2: note: Value stored to 'tmp' is never read
drivers/gpu/drm/radeon/r100.c:2881:3: warning: Value stored to 'tmp' is never read [clang-analyzer-deadcode.DeadStores]
tmp = RREG32(RADEON_CLOCK_CNTL_DATA);
^
drivers/gpu/drm/radeon/r100.c:2881:3: note: Value stored to 'tmp' is never read
drivers/gpu/drm/radeon/r100.c:3821:3: warning: 3rd function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
WREG32(R_0003F8_CRTC2_GEN_CNTL, save->CRTC2_GEN_CNTL);
^
drivers/gpu/drm/radeon/radeon.h:2549:24: note: expanded from macro 'WREG32'
#define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v), false)
^
drivers/gpu/drm/radeon/r100.c:3937:6: note: Assuming the condition is false
if (rdev->flags & RADEON_IS_PCI)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/entropy_credit +455 drivers/char/hw_random/core.c
844dd05fec172d Michael Buesch 2006-06-26 424
be4000bc4644d0 Torsten Duwe 2014-06-14 425 static int hwrng_fillfn(void *unused)
be4000bc4644d0 Torsten Duwe 2014-06-14 426 {
be4000bc4644d0 Torsten Duwe 2014-06-14 427 long rc;
be4000bc4644d0 Torsten Duwe 2014-06-14 428
08e97aec700aef Herbert Xu 2019-11-17 429 while (!kthread_should_stop()) {
a0f46724fe340b Dominik Brodowski 2022-01-24 430 size_t entropy, entropy_credit = 0; /* in 1/1024 of a bit */
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 431 struct hwrng *rng;
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 432
502e9986132b25 Dominik Brodowski 2022-01-24 433 if (!current_quality)
502e9986132b25 Dominik Brodowski 2022-01-24 434 break;
502e9986132b25 Dominik Brodowski 2022-01-24 435
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 436 rng = get_current_rng();
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 437 if (IS_ERR(rng) || !rng)
be4000bc4644d0 Torsten Duwe 2014-06-14 438 break;
9372b35e11149c Rusty Russell 2014-12-08 439 mutex_lock(&reading_mutex);
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 440 rc = rng_get_data(rng, rng_fillbuf,
be4000bc4644d0 Torsten Duwe 2014-06-14 441 rng_buffer_size(), 1);
9372b35e11149c Rusty Russell 2014-12-08 442 mutex_unlock(&reading_mutex);
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 443 put_rng(rng);
be4000bc4644d0 Torsten Duwe 2014-06-14 444 if (rc <= 0) {
be4000bc4644d0 Torsten Duwe 2014-06-14 445 pr_warn("hwrng: no data available\n");
be4000bc4644d0 Torsten Duwe 2014-06-14 446 msleep_interruptible(10000);
be4000bc4644d0 Torsten Duwe 2014-06-14 447 continue;
be4000bc4644d0 Torsten Duwe 2014-06-14 448 }
a0f46724fe340b Dominik Brodowski 2022-01-24 449
a0f46724fe340b Dominik Brodowski 2022-01-24 450 /* If we cannot credit at least one bit of entropy,
a0f46724fe340b Dominik Brodowski 2022-01-24 451 * keep track of the remainder for the next iteration
a0f46724fe340b Dominik Brodowski 2022-01-24 452 */
a0f46724fe340b Dominik Brodowski 2022-01-24 453 entropy = rc * current_quality * 8 + entropy_credit;
a0f46724fe340b Dominik Brodowski 2022-01-24 454 if ((entropy >> 10) == 0)
a0f46724fe340b Dominik Brodowski 2022-01-24 @455 entropy_credit = entropy;
a0f46724fe340b Dominik Brodowski 2022-01-24 456
9372b35e11149c Rusty Russell 2014-12-08 457 /* Outside lock, sure, but y'know: randomness. */
be4000bc4644d0 Torsten Duwe 2014-06-14 458 add_hwgenerator_randomness((void *)rng_fillbuf, rc,
a0f46724fe340b Dominik Brodowski 2022-01-24 459 entropy >> 10);
be4000bc4644d0 Torsten Duwe 2014-06-14 460 }
9dda727d37ff6c Torsten Duwe 2014-06-16 461 hwrng_fill = NULL;
be4000bc4644d0 Torsten Duwe 2014-06-14 462 return 0;
be4000bc4644d0 Torsten Duwe 2014-06-14 463 }
be4000bc4644d0 Torsten Duwe 2014-06-14 464
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 6/6] hw_random: credit entropy for low quality sources of randomness
2022-01-25 13:52 [PATCH 6/6] hw_random: credit entropy for low quality sources of randomness kernel test robot
@ 2022-01-27 5:45 ` kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-01-27 5:45 UTC (permalink / raw)
To: Dominik Brodowski; +Cc: llvm, kbuild-all
Hi Dominik,
Thanks for your patch! Perhaps something to improve:
[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on v5.17-rc1 next-20220125]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Dominik-Brodowski/hw_random-explicit-ordering-of-initcalls/20220125-051254
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 515a2f507491e7c3818e74ef4f4e088c1fecb190
config: riscv-randconfig-c006-20220124 (https://download.01.org/0day-ci/archive/20220125/202201252124.ZlTUIMTI-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 997e128e2a78f5a5434fc75997441ae1ee76f8a4)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/a0f46724fe340bab80dd4a8bf4a9f413c6a294f1
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dominik-Brodowski/hw_random-explicit-ordering-of-initcalls/20220125-051254
git checkout a0f46724fe340bab80dd4a8bf4a9f413c6a294f1
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
>> drivers/char/hw_random/core.c:455:4: warning: Value stored to 'entropy_credit' is never read [clang-analyzer-deadcode.DeadStores]
entropy_credit = entropy;
^ ~~~~~~~
vim +/entropy_credit +455 drivers/char/hw_random/core.c
844dd05fec172d Michael Buesch 2006-06-26 424
be4000bc4644d0 Torsten Duwe 2014-06-14 425 static int hwrng_fillfn(void *unused)
be4000bc4644d0 Torsten Duwe 2014-06-14 426 {
be4000bc4644d0 Torsten Duwe 2014-06-14 427 long rc;
be4000bc4644d0 Torsten Duwe 2014-06-14 428
08e97aec700aef Herbert Xu 2019-11-17 429 while (!kthread_should_stop()) {
a0f46724fe340b Dominik Brodowski 2022-01-24 430 size_t entropy, entropy_credit = 0; /* in 1/1024 of a bit */
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 431 struct hwrng *rng;
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 432
502e9986132b25 Dominik Brodowski 2022-01-24 433 if (!current_quality)
502e9986132b25 Dominik Brodowski 2022-01-24 434 break;
502e9986132b25 Dominik Brodowski 2022-01-24 435
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 436 rng = get_current_rng();
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 437 if (IS_ERR(rng) || !rng)
be4000bc4644d0 Torsten Duwe 2014-06-14 438 break;
9372b35e11149c Rusty Russell 2014-12-08 439 mutex_lock(&reading_mutex);
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 440 rc = rng_get_data(rng, rng_fillbuf,
be4000bc4644d0 Torsten Duwe 2014-06-14 441 rng_buffer_size(), 1);
9372b35e11149c Rusty Russell 2014-12-08 442 mutex_unlock(&reading_mutex);
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 443 put_rng(rng);
be4000bc4644d0 Torsten Duwe 2014-06-14 444 if (rc <= 0) {
be4000bc4644d0 Torsten Duwe 2014-06-14 445 pr_warn("hwrng: no data available\n");
be4000bc4644d0 Torsten Duwe 2014-06-14 446 msleep_interruptible(10000);
be4000bc4644d0 Torsten Duwe 2014-06-14 447 continue;
be4000bc4644d0 Torsten Duwe 2014-06-14 448 }
a0f46724fe340b Dominik Brodowski 2022-01-24 449
a0f46724fe340b Dominik Brodowski 2022-01-24 450 /* If we cannot credit at least one bit of entropy,
a0f46724fe340b Dominik Brodowski 2022-01-24 451 * keep track of the remainder for the next iteration
a0f46724fe340b Dominik Brodowski 2022-01-24 452 */
a0f46724fe340b Dominik Brodowski 2022-01-24 453 entropy = rc * current_quality * 8 + entropy_credit;
a0f46724fe340b Dominik Brodowski 2022-01-24 454 if ((entropy >> 10) == 0)
a0f46724fe340b Dominik Brodowski 2022-01-24 @455 entropy_credit = entropy;
a0f46724fe340b Dominik Brodowski 2022-01-24 456
9372b35e11149c Rusty Russell 2014-12-08 457 /* Outside lock, sure, but y'know: randomness. */
be4000bc4644d0 Torsten Duwe 2014-06-14 458 add_hwgenerator_randomness((void *)rng_fillbuf, rc,
a0f46724fe340b Dominik Brodowski 2022-01-24 459 entropy >> 10);
be4000bc4644d0 Torsten Duwe 2014-06-14 460 }
9dda727d37ff6c Torsten Duwe 2014-06-16 461 hwrng_fill = NULL;
be4000bc4644d0 Torsten Duwe 2014-06-14 462 return 0;
be4000bc4644d0 Torsten Duwe 2014-06-14 463 }
be4000bc4644d0 Torsten Duwe 2014-06-14 464
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 6/6] hw_random: credit entropy for low quality sources of randomness
@ 2022-01-27 5:45 ` kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-01-27 5:45 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 5247 bytes --]
Hi Dominik,
Thanks for your patch! Perhaps something to improve:
[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on v5.17-rc1 next-20220125]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Dominik-Brodowski/hw_random-explicit-ordering-of-initcalls/20220125-051254
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 515a2f507491e7c3818e74ef4f4e088c1fecb190
config: riscv-randconfig-c006-20220124 (https://download.01.org/0day-ci/archive/20220125/202201252124.ZlTUIMTI-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 997e128e2a78f5a5434fc75997441ae1ee76f8a4)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/a0f46724fe340bab80dd4a8bf4a9f413c6a294f1
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dominik-Brodowski/hw_random-explicit-ordering-of-initcalls/20220125-051254
git checkout a0f46724fe340bab80dd4a8bf4a9f413c6a294f1
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
>> drivers/char/hw_random/core.c:455:4: warning: Value stored to 'entropy_credit' is never read [clang-analyzer-deadcode.DeadStores]
entropy_credit = entropy;
^ ~~~~~~~
vim +/entropy_credit +455 drivers/char/hw_random/core.c
844dd05fec172d Michael Buesch 2006-06-26 424
be4000bc4644d0 Torsten Duwe 2014-06-14 425 static int hwrng_fillfn(void *unused)
be4000bc4644d0 Torsten Duwe 2014-06-14 426 {
be4000bc4644d0 Torsten Duwe 2014-06-14 427 long rc;
be4000bc4644d0 Torsten Duwe 2014-06-14 428
08e97aec700aef Herbert Xu 2019-11-17 429 while (!kthread_should_stop()) {
a0f46724fe340b Dominik Brodowski 2022-01-24 430 size_t entropy, entropy_credit = 0; /* in 1/1024 of a bit */
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 431 struct hwrng *rng;
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 432
502e9986132b25 Dominik Brodowski 2022-01-24 433 if (!current_quality)
502e9986132b25 Dominik Brodowski 2022-01-24 434 break;
502e9986132b25 Dominik Brodowski 2022-01-24 435
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 436 rng = get_current_rng();
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 437 if (IS_ERR(rng) || !rng)
be4000bc4644d0 Torsten Duwe 2014-06-14 438 break;
9372b35e11149c Rusty Russell 2014-12-08 439 mutex_lock(&reading_mutex);
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 440 rc = rng_get_data(rng, rng_fillbuf,
be4000bc4644d0 Torsten Duwe 2014-06-14 441 rng_buffer_size(), 1);
9372b35e11149c Rusty Russell 2014-12-08 442 mutex_unlock(&reading_mutex);
3a2c0ba5ad00c0 Rusty Russell 2014-12-08 443 put_rng(rng);
be4000bc4644d0 Torsten Duwe 2014-06-14 444 if (rc <= 0) {
be4000bc4644d0 Torsten Duwe 2014-06-14 445 pr_warn("hwrng: no data available\n");
be4000bc4644d0 Torsten Duwe 2014-06-14 446 msleep_interruptible(10000);
be4000bc4644d0 Torsten Duwe 2014-06-14 447 continue;
be4000bc4644d0 Torsten Duwe 2014-06-14 448 }
a0f46724fe340b Dominik Brodowski 2022-01-24 449
a0f46724fe340b Dominik Brodowski 2022-01-24 450 /* If we cannot credit at least one bit of entropy,
a0f46724fe340b Dominik Brodowski 2022-01-24 451 * keep track of the remainder for the next iteration
a0f46724fe340b Dominik Brodowski 2022-01-24 452 */
a0f46724fe340b Dominik Brodowski 2022-01-24 453 entropy = rc * current_quality * 8 + entropy_credit;
a0f46724fe340b Dominik Brodowski 2022-01-24 454 if ((entropy >> 10) == 0)
a0f46724fe340b Dominik Brodowski 2022-01-24 @455 entropy_credit = entropy;
a0f46724fe340b Dominik Brodowski 2022-01-24 456
9372b35e11149c Rusty Russell 2014-12-08 457 /* Outside lock, sure, but y'know: randomness. */
be4000bc4644d0 Torsten Duwe 2014-06-14 458 add_hwgenerator_randomness((void *)rng_fillbuf, rc,
a0f46724fe340b Dominik Brodowski 2022-01-24 459 entropy >> 10);
be4000bc4644d0 Torsten Duwe 2014-06-14 460 }
9dda727d37ff6c Torsten Duwe 2014-06-16 461 hwrng_fill = NULL;
be4000bc4644d0 Torsten Duwe 2014-06-14 462 return 0;
be4000bc4644d0 Torsten Duwe 2014-06-14 463 }
be4000bc4644d0 Torsten Duwe 2014-06-14 464
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 6/6] hw_random: credit entropy for low quality sources of randomness
2022-01-24 20:29 [PATCH 1/6] hw_random: explicit ordering of initcalls Dominik Brodowski
@ 2022-01-24 20:29 ` Dominik Brodowski
0 siblings, 0 replies; 4+ messages in thread
From: Dominik Brodowski @ 2022-01-24 20:29 UTC (permalink / raw)
To: Matt Mackall, Herbert Xu; +Cc: linux-kernel, linux-crypto, Jason A . Donenfeld
In case the entropy quality is low, there may be less than one bit to
credit in the call to add_hwgenerator_randomness(): The number of bytes
returned by rng_get_data() multiplied by the current quality (in entropy
bits per 1024 bits of input) must be larger than 128 to credit at least
one bit. However, imx-rngc.c sets the quality to 19, but may return less
than 32 bytes; hid_u2fzero.c sets the quality to 1; and users may override
the quality setting manually.
In case there is less than one bit to credit, keep track of it and add
that credit to the next iteration.
Cc: Matt Mackall <mpm@selenic.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
drivers/char/hw_random/core.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index bc9f95cbac92..6d7f05641c7c 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -427,6 +427,7 @@ static int hwrng_fillfn(void *unused)
long rc;
while (!kthread_should_stop()) {
+ size_t entropy, entropy_credit = 0; /* in 1/1024 of a bit */
struct hwrng *rng;
if (!current_quality)
@@ -445,9 +446,17 @@ static int hwrng_fillfn(void *unused)
msleep_interruptible(10000);
continue;
}
+
+ /* If we cannot credit at least one bit of entropy,
+ * keep track of the remainder for the next iteration
+ */
+ entropy = rc * current_quality * 8 + entropy_credit;
+ if ((entropy >> 10) == 0)
+ entropy_credit = entropy;
+
/* Outside lock, sure, but y'know: randomness. */
add_hwgenerator_randomness((void *)rng_fillbuf, rc,
- rc * current_quality * 8 >> 10);
+ entropy >> 10);
}
hwrng_fill = NULL;
return 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-27 5:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25 13:52 [PATCH 6/6] hw_random: credit entropy for low quality sources of randomness kernel test robot
2022-01-27 5:45 ` kernel test robot
2022-01-27 5:45 ` kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2022-01-24 20:29 [PATCH 1/6] hw_random: explicit ordering of initcalls Dominik Brodowski
2022-01-24 20:29 ` [PATCH 6/6] hw_random: credit entropy for low quality sources of randomness Dominik Brodowski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.