zram: avoid access beyond the zram device
authorJiang Liu <liuj97@gmail.com>
Thu, 6 Jun 2013 16:07:26 +0000 (00:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jun 2014 23:02:06 +0000 (16:02 -0700)
commitf3ec6e7a5ba399b324470aae720b3696049fb3e2
tree393dff554e649ff2c8cd4f6e9f55074fb6562871
parent11fc2ee51436c4bbcf9872ed3d31457490e071de
zram: avoid access beyond the zram device

commit 12a7ad3b810e77137d0caf97a6dd97591e075b30 upstream.

Function valid_io_request() should verify the entire request are within
the zram device address range. Otherwise it may cause invalid memory
access when accessing/modifying zram->meta->table[index] because the
'index' is out of range. Then it may access non-exist memory, randomly
modify memory belong to other subsystems, which is hard to track down.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Jianguo Wu <wujianguo@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/zram/zram_drv.c