aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rapidio
diff options
context:
space:
mode:
authorAndrey Ryabinin <a.ryabinin@samsung.com>2014-08-08 14:22:07 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-08 15:57:24 -0700
commit93b7aca35dd7bf0c3ba7ea0542b556bcfdb28e76 (patch)
treed7f8872fd8e21b4ad301bda4de482ef41014c480 /drivers/rapidio
parentfs/proc/vmcore.c:mmap_vmcore: skip non-ram pages reported by hypervisors (diff)
downloadlinux-dev-93b7aca35dd7bf0c3ba7ea0542b556bcfdb28e76.tar.xz
linux-dev-93b7aca35dd7bf0c3ba7ea0542b556bcfdb28e76.zip
lib/idr.c: fix out-of-bounds pointer dereference
I'm working on address sanitizer project for kernel. Recently we started experiments with stack instrumentation, to detect out-of-bounds read/write bugs on stack. Just after booting I've hit out-of-bounds read on stack in idr_for_each (and in __idr_remove_all as well): struct idr_layer **paa = &pa[0]; while (id >= 0 && id <= max) { ... while (n < fls(id)) { n += IDR_BITS; p = *--paa; <--- here we are reading pa[-1] value. } } Despite the fact that after this dereference we are exiting out of loop and never use p, such behaviour is undefined and should be avoided. Fix this by moving pointer derference to the beggining of the loop, right before we will use it. Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com> Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com> Cc: Tejun Heo <tj@kernel.org> Cc: Alexey Preobrazhensky <preobr@google.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Konstantin Khlebnikov <koct9i@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rapidio')
0 files changed, 0 insertions, 0 deletions