]> asedeno.scripts.mit.edu Git - linux.git/commit
locking/lockdep: Fix buffer overrun problem in stack_trace[]
authorWaiman Long <longman@redhat.com>
Fri, 20 Dec 2019 13:51:28 +0000 (08:51 -0500)
committerIngo Molnar <mingo@kernel.org>
Wed, 25 Dec 2019 09:42:32 +0000 (10:42 +0100)
commitd91f3057263ceb691ef527e71b41a56b17f6c869
treebd51ce11e68a6a0c8b90a72c71b15a6d64be4a38
parent46cf053efec6a3a5f343fead837777efe8252a46
locking/lockdep: Fix buffer overrun problem in stack_trace[]

If the lockdep code is really running out of the stack_trace entries,
it is likely that buffer overrun can happen and the data immediately
after stack_trace[] will be corrupted.

If there is less than LOCK_TRACE_SIZE_IN_LONGS entries left before
the call to save_trace(), the max_entries computation will leave it
with a very large positive number because of its unsigned nature. The
subsequent call to stack_trace_save() will then corrupt the data after
stack_trace[]. Fix that by changing max_entries to a signed integer
and check for negative value before calling stack_trace_save().

Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 12593b7467f9 ("locking/lockdep: Reduce space occupied by stack traces")
Link: https://lkml.kernel.org/r/20191220135128.14876-1-longman@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/locking/lockdep.c