linux-stable/drivers/block
Minchan Kim d72e9a7a93 zram: do not use copy_page with non-page aligned address
The copy_page is optimized memcpy for page-alinged address.  If it is
used with non-page aligned address, it can corrupt memory which means
system corruption.  With zram, it can happen with

1. 64K architecture
2. partial IO
3. slub debug

Partial IO need to allocate a page and zram allocates it via kmalloc.
With slub debug, kmalloc(PAGE_SIZE) doesn't return page-size aligned
address.  And finally, copy_page(mem, cmem) corrupts memory.

So, this patch changes it to memcpy.

Actuaully, we don't need to change zram_bvec_write part because zsmalloc
returns page-aligned address in case of PAGE_SIZE class but it's not
good to rely on the internal of zsmalloc.

Note:
 When this patch is merged to stable, clear_page should be fixed, too.
 Unfortunately, recent zram removes it by "same page merge" feature so
 it's hard to backport this patch to -stable tree.

I will handle it when I receive the mail from stable tree maintainer to
merge this patch to backport.

Fixes: 42e99bd ("zram: optimize memory operations with clear_page()/copy_page()")
Link: http://lkml.kernel.org/r/1492042622-12074-2-git-send-email-minchan@kernel.org
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-04-13 18:24:21 -07:00
..
aoe block: Use pointer to backing_dev_info from request_queue 2017-02-02 08:20:48 -07:00
drbd Merge branch 'WIP.sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-03-03 10:16:38 -08:00
mtip32xx block: mtip32xx: set error code on failure 2016-12-01 08:01:14 -07:00
paride scripts/spelling.txt: add "overide" pattern and fix typo instances 2017-03-09 17:01:09 -08:00
rsxx block: convert to device_add_disk() 2016-06-27 12:26:08 -07:00
xen-blkback xen: modify xenstore watch event interface 2017-02-09 11:26:49 -05:00
zram zram: do not use copy_page with non-page aligned address 2017-04-13 18:24:21 -07:00
amiflop.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
ataflop.c
brd.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
cciss.c scsi: cciss: correct check map error. 2017-02-23 17:10:32 -05:00
cciss.h SCSI misc on 20170220 2017-02-21 11:51:42 -08:00
cciss_cmd.h
cciss_scsi.c cciss: Remove kmalloc cast 2017-02-22 11:54:49 -07:00
cciss_scsi.h
cryptoloop.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
DAC960.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
DAC960.h
floppy.c block: fold cmd_type into the REQ_OP_ space 2017-01-31 14:00:44 -07:00
hd.c block: fold cmd_type into the REQ_OP_ space 2017-01-31 14:00:44 -07:00
Kconfig virtio_blk: make SCSI passthrough support configurable 2017-01-31 10:53:10 -07:00
loop.c Merge branch 'rebased-statx' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-03-03 11:38:56 -08:00
loop.h block: loop: support DIO & AIO 2015-09-23 11:01:16 -06:00
Makefile drivers:block: cpqarray clean up 2016-03-15 15:59:47 -07:00
mg_disk.c block: fold cmd_type into the REQ_OP_ space 2017-01-31 14:00:44 -07:00
nbd.c nbd: replace kill_bdev() with __invalidate_device() 2017-03-24 15:42:47 -06:00
null_blk.c Merge branch 'for-4.11/next' into for-4.11/linus-merge 2017-02-17 14:08:19 -07:00
osdblk.c block: fold cmd_type into the REQ_OP_ space 2017-01-31 14:00:44 -07:00
pktcdvd.c block: Use pointer to backing_dev_info from request_queue 2017-02-02 08:20:48 -07:00
ps3disk.c block: fold cmd_type into the REQ_OP_ space 2017-01-31 14:00:44 -07:00
ps3vram.c block: convert to device_add_disk() 2016-06-27 12:26:08 -07:00
rbd.c rbd: supported_features bus attribute 2017-03-07 14:30:38 +01:00
rbd_types.h rbd: RBD_V{1,2}_DATA_FORMAT macros 2017-02-20 12:16:15 +01:00
skd_main.c skd: implement trivial scsi ioctls directly 2017-01-31 10:53:03 -07:00
skd_s1120.h
smart1,2.h
sunvdc.c sunvdc: Add support for setting physical sector size 2017-02-23 08:24:08 -08:00
swim.c
swim3.c sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h> 2017-03-02 08:42:32 +01:00
swim_asm.S
sx8.c block: fold cmd_type into the REQ_OP_ space 2017-01-31 14:00:44 -07:00
umem.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
umem.h
virtio_blk.c virtio, vhost: optimizations, fixes 2017-03-02 13:53:13 -08:00
xen-blkfront.c Merge branch 'for-4.11/next' into for-4.11/linus-merge 2017-02-17 14:08:19 -07:00
xsysace.c block: fold cmd_type into the REQ_OP_ space 2017-01-31 14:00:44 -07:00
z2ram.c