Re: BUG: KCSAN: data-race in add_device_randomness+0x20d/0x290

From: Jason A. Donenfeld
Date: Mon Feb 07 2022 - 17:21:08 EST


Narrowing this a bit by looking at the disassembly from as similar as
a config as I could infer, there are three calls to _tsan_read1():

1. ... = lfsr;
2. ... = dest_buf[i % CHACHA_KEY_SIZE];
3. ... ^= src_buf[i % len] ...

1. lfsr, as you mentioned, appears protected by primary_crng.lock.
2. dest_buf is &primary_crng.state, which /should/ be protected by
primary_crng.lock. The only place where it's not is rand_initialize(),
but this is an early boot function that should complete well in
advance of where we are.
3. That would be tsk->se.sum_exec_runtime...