android_kernel_oneplus_msm8998/block
xiao jin e6ea77dd5a block: blk_init_allocated_queue() set q->fq as NULL in the fail case
commit 54648cf1ec2d7f4b6a71767799c45676a138ca24 upstream.

We find the memory use-after-free issue in __blk_drain_queue()
on the kernel 4.14. After read the latest kernel 4.18-rc6 we
think it has the same problem.

Memory is allocated for q->fq in the blk_init_allocated_queue().
If the elevator init function called with error return, it will
run into the fail case to free the q->fq.

Then the __blk_drain_queue() uses the same memory after the free
of the q->fq, it will lead to the unpredictable event.

The patch is to set q->fq as NULL in the fail case of
blk_init_allocated_queue().

Fixes: commit 7c94e1c157 ("block: introduce blk_flush_queue to drive flush machinery")
Cc: <stable@vger.kernel.org>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: xiao jin <jin.xiao@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[groeck: backport to v4.4.y/v4.9.y (context change)]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Alessio Balsini <balsini@android.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-11 12:20:46 +02:00
..
partitions partitions/aix: fix usage of uninitialized lv_info and lvname structures 2018-09-19 22:48:59 +02:00
bio-integrity.c bio-integrity: Do not allocate integrity context for bio w/o data 2018-04-13 19:50:17 +02:00
bio.c block: do not leak memory in bio_copy_user_iov() 2019-04-27 09:33:55 +02:00
blk-cgroup.c block,blkcg: use __GFP_NOWARN for best-effort allocations in blkcg 2018-09-19 22:48:56 +02:00
blk-core.c block: blk_init_allocated_queue() set q->fq as NULL in the fail case 2019-08-11 12:20:46 +02:00
blk-exec.c
blk-flush.c Revert "blk-flush: Queue through IO scheduler when flush not required" 2015-11-25 10:12:54 -07:00
blk-integrity.c block: fix blk_integrity_register to use template's interval_exp if not 0 2017-05-20 14:27:00 +02:00
blk-ioc.c
blk-iopoll.c
blk-lib.c
blk-map.c Don't feed anything but regular iovec's to blk_rq_map_user_iov 2016-12-10 19:07:26 +01:00
blk-merge.c block: make sure a big bio is split into at most 256 bvecs 2016-09-15 08:27:51 +02:00
blk-mq-cpu.c
blk-mq-cpumap.c
blk-mq-sysfs.c
blk-mq-tag.c
blk-mq-tag.h
blk-mq.c blk-mq: fix kernel oops in blk_mq_tag_idle() 2018-04-13 19:50:22 +02:00
blk-mq.h
blk-settings.c block: Initialize max_dev_sectors to 0 2016-03-09 15:34:49 -08:00
blk-softirq.c
blk-sysfs.c Merge branch 'mkp-fixes' into fixes 2015-12-03 09:32:33 -08:00
blk-tag.c
blk-throttle.c blk-throttle: make sure expire time isn't too big 2018-03-22 09:23:22 +01:00
blk-timeout.c block: fix blk_abort_request for blk-mq drivers 2015-11-24 15:24:10 -07:00
blk.h
bounce.c
bsg-lib.c Revert "bsg-lib: don't free job in bsg_prepare_job" 2017-10-21 17:09:03 +02:00
bsg.c sg_write()/bsg_write() is not fit to be called under KERNEL_DS 2017-01-09 08:07:53 +01:00
cfq-iosched.c block,blkcg: use __GFP_NOWARN for best-effort allocations in blkcg 2018-09-19 22:48:56 +02:00
cmdline-parser.c
compat_ioctl.c take floppy compat ioctls to sodding floppy.c 2019-08-04 09:34:51 +02:00
deadline-iosched.c
elevator.c
genhd.c block: fix del_gendisk() vs blkdev_ioctl crash 2017-04-27 09:09:34 +02:00
ioctl.c
ioprio.c block: fix use-after-free in sys_ioprio_get() 2016-08-10 11:49:28 +02:00
Kconfig
Kconfig.iosched
Makefile
noop-iosched.c
partition-generic.c block: fix an error code in add_partition() 2018-04-13 19:50:10 +02:00
scsi_ioctl.c block: allow WRITE_SAME commands with the SG_IO ioctl 2017-03-30 09:35:20 +02:00
t10-pi.c