OSDN Git Service

[PATCH] random device reseed bugfix, possibly security problem
authorPaX Team <pageexec@freemail.hu>
Mon, 18 Jun 2007 08:56:16 +0000 (10:56 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 22 Jul 2007 12:45:09 +0000 (14:45 +0200)
commit66438bd5651e892bc485c32762f7ce75637b686b
tree504bcaa0f7e55bffeeb5bd12c44257329fad3383
parentcf6878a64f760225e959450fc3c009f72fe0884e
[PATCH] random device reseed bugfix, possibly security problem

hello,

recently while trying to figure out something i ran across
some code in drivers/char/random.c:xfer_secondary_pool() which
looked wrong and further investigation of history confirmed
it as well.

the problem is that xfer_secondary_pool() used to use a local
buffer in the past that was used during the reseed operation
however when this buffer was moved out to the caller site, the
sizeof(tmp) code wasn't properly adjusted, therefore the sizeof
now operates on a pointer type (vs. array) and gives the wrong
result.

in this case it means that when the code thinks it reseeds the
entire buffer (0x154 bytes on i386/sha1), it only reseeds
sizeof(ptr), 4 bytes on i386.

since all this 'catastrophic reseeding' has something to do with
some (maybe theoretical) attack (i'm not a crypto guy to tell ;),
i can imagine that this error has some security consequences,
please treat it as such until confirmed otherwise.

the commit that introduced the bug:
  http://linux.bkbits.net:8080/linux-2.6/?PAGE=cset&REV=1.889.325.12

the attached fix has been in PaX/grsecurity for a few weeks now
and seems to work.

2.6 doesn't have this bug as the buffer in question is again
local to the function that uses sizeof on it (i haven't checked
when it was fixed).
drivers/char/random.c