android_kernel_samsung_univ.../drivers
Lars Ellenberg df0fe72e2e drbd: fix access after free
commit 64dafbc9530c10300acffc57fae3269d95fa8f93 upstream.

We have
  struct drbd_requests { ... struct bio *private_bio;  ... }
to hold a bio clone for local submission.

On local IO completion, we put that bio, and in case we want to use the
result later, we overload that member to hold the ERR_PTR() of the
completion result,

Which, before v4.3, used to be the passed in "int error",
so we could first bio_put(), then assign.

v4.3-rc1~100^2~21 4246a0b63b block: add a bi_error field to struct bio
changed that:
  	bio_put(req->private_bio);
 -	req->private_bio = ERR_PTR(error);
 +	req->private_bio = ERR_PTR(bio->bi_error);

Which introduces an access after free,
because it was non obvious that req->private_bio == bio.

Impact of that was mostly unnoticable, because we only use that value
in a multiple-failure case, and even then map any "unexpected" error
code to EIO, so worst case we could potentially mask a more specific
error with EIO in a multiple failure case.

Unless the pointed to memory region was unmapped, as is the case with
CONFIG_DEBUG_PAGEALLOC, in which case this results in

  BUG: unable to handle kernel paging request

v4.13-rc1~70^2~75 4e4cbee93d56 block: switch bios to blk_status_t
changes it further to
  	bio_put(req->private_bio);
  	req->private_bio = ERR_PTR(blk_status_to_errno(bio->bi_status));

And blk_status_to_errno() now contains a WARN_ON_ONCE() for unexpected
values, which catches this "sometimes", if the memory has been reused
quickly enough for other things.

Should also go into stable since 4.3, with the trivial change around 4.13.

Cc: stable@vger.kernel.org
Fixes: 4246a0b63b block: add a bi_error field to struct bio
Reported-by: Sarah Newman <srn@prgmr.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-11 16:03:48 +02:00
..
accessibility
acpi ACPICA: acpi: acpica: fix acpi operand cache leak in nseval.c 2018-05-30 07:49:11 +02:00
amba ARM: amba: Don't read past the end of sysfs "driver_override" buffer 2018-05-02 07:53:42 -07:00
android
ata libata: Drop SanDisk SD7UB3Q*G1001 NOLPM quirk 2018-07-03 11:21:26 +02:00
atm atm: zatm: fix memcmp casting 2018-07-03 11:21:24 +02:00
auxdisplay
base driver core: Don't ignore class_dir_create_and_add() failure. 2018-07-03 11:21:25 +02:00
bcma
block drbd: fix access after free 2018-07-11 16:03:48 +02:00
bluetooth Bluetooth: hci_qca: Avoid missing rampatch failure with userspace fw loader 2018-07-03 11:21:28 +02:00
bus
cdrom cdrom: do not call check_disk_change() inside cdrom_open() 2018-05-30 07:49:13 +02:00
char ipmi:bt: Set the timeout before doing a capabilities check 2018-07-03 11:21:28 +02:00
clk clk: samsung: exynos3250: Fix PLL rates 2018-05-30 07:49:16 +02:00
clocksource clocksource/drivers/fsl_ftm_timer: Fix error return checking 2018-05-30 07:49:01 +02:00
connector
cpufreq cpufreq: Fix new policy initialization during limits updates via sysfs 2018-07-03 11:21:26 +02:00
cpuidle cpuidle: powernv: Fix promotion from snooze if next state disabled 2018-07-03 11:21:29 +02:00
crypto crypto: vmx - Remove overly verbose printk from AES init routines 2018-06-16 09:54:27 +02:00
dca
devfreq
dio
dma dmaengine: usb-dmac: fix endless loop in usb_dmac_chan_terminate_all() 2018-06-06 16:46:22 +02:00
dma-buf
edac
eisa
extcon
firewire firewire-ohci: work around oversized DMA reads on JMicron controllers 2018-05-30 07:48:52 +02:00
firmware firmware: dmi_scan: Fix handling of empty DMI strings 2018-05-30 07:48:56 +02:00
fmc
fpga
gpio gpio: No NULL owner 2018-06-16 09:54:26 +02:00
gpu drm: set FMODE_UNSIGNED_OFFSET for drm files 2018-06-13 16:15:27 +02:00
hid HID: roccat: prevent an out of bounds read in kovaplus_profile_activated() 2018-05-30 07:48:54 +02:00
hsi
hv
hwmon hwmon: (pmbus/adm1275) Accept negative page register values 2018-05-30 07:49:13 +02:00
hwspinlock
hwtracing hwtracing: stm: fix build error on some arches 2018-06-06 16:46:23 +02:00
i2c i2c: rcar: fix resume by always initializing registers before transfer 2018-07-11 16:03:47 +02:00
ide cdrom: do not call check_disk_change() inside cdrom_open() 2018-05-30 07:49:13 +02:00
idle
iio iio:buffer: make length types match kfifo types 2018-07-03 11:21:30 +02:00
infiniband RDMA/mlx4: Discard unknown SQP work requests 2018-07-03 11:21:29 +02:00
input Input: elantech - fix V4 report decoding for module with middle key 2018-07-03 11:21:34 +02:00
iommu x86/cpufeature: Remove unused and seldomly used cpu_has_xx macros 2018-06-16 09:54:24 +02:00
ipack
irqchip irqchip/gic-v3: Change pr_debug message to pr_devel 2018-05-30 07:48:57 +02:00
isdn isdn: eicon: fix a missing-check bug 2018-06-13 16:15:28 +02:00
leds
lguest
lightnvm
macintosh
mailbox
mcb
md dm thin: handle running out of data space vs concurrent discard 2018-07-03 11:21:35 +02:00
media media: dvb_frontend: fix locking issues at dvb_frontend_get_event() 2018-07-03 11:21:33 +02:00
memory
memstick
message scsi: mptfusion: Add bounds check in mptctl_hp_targetinfo() 2018-05-30 07:48:58 +02:00
mfd mfd: intel-lpss: Program REMAP register in PIO mode 2018-07-03 11:21:32 +02:00
misc vmw_balloon: fixing double free when batching mode is off 2018-06-16 09:54:26 +02:00
mmc mmc: sdhci-iproc: fix 32bit writes for TRANSFER_MODE register 2018-05-30 07:48:51 +02:00
mtd ubi: fastmap: Correctly handle interrupted erasures in EBA 2018-07-11 16:03:47 +02:00
net ath10k: fix rfc1042 header retrieval in QCA4019 with eth decap mode 2018-07-11 16:03:47 +02:00
nfc
ntb ntb_transport: Fix bug with max_mw_size parameter 2018-05-30 07:48:55 +02:00
nubus
nvdimm linvdimm, pmem: Preserve read-only setting for pmem devices 2018-07-03 11:21:31 +02:00
nvme nvme-pci: initialize queue memory before interrupts 2018-07-11 16:03:47 +02:00
nvmem
of of: unittest: for strings, account for trailing \0 in property length field 2018-07-03 11:21:29 +02:00
oprofile
parisc parisc/pci: Switch LBA PCI bus from Hard Fail to Soft Fail mode 2018-05-30 07:49:10 +02:00
parport
pci PCI: pciehp: Clear Presence Detect and Data Link Layer Status Changed on resume 2018-07-03 11:21:30 +02:00
pcmcia
perf
phy
pinctrl
platform
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator regulator: of: Add a missing 'of_node_put()' in an error handling path of 'of_regulator_match()' 2018-05-30 07:49:17 +02:00
remoteproc
reset
rpmsg
rtc rtc: tx4939: avoid unintended sign extension on a 24 bit shift 2018-05-30 07:49:14 +02:00
s390 scsi: zfcp: fix missing REC trigger trace on enqueue without ERP thread 2018-07-03 11:21:31 +02:00
sbus
scsi scsi: sg: mitigate read/write abuse 2018-07-11 16:03:48 +02:00
sfi
sh
sn
soc
spi spi: Fix scatterlist elements size in spi_map_buf 2018-07-03 11:21:35 +02:00
spmi
ssb
staging staging: android: ion: Return an ERR_PTR in ion_map_kernel 2018-07-11 16:03:47 +02:00
target
tc
thermal
thunderbolt
tty n_tty: Access echo_* variables carefully. 2018-07-11 16:03:47 +02:00
uio
usb USB: serial: cp210x: add Silicon Labs IDs for Windows Update 2018-07-11 16:03:46 +02:00
uwb
vfio vfio/pci: Virtualize Maximum Read Request Size 2018-04-24 09:32:09 +02:00
vhost
video video: uvesafb: Fix integer overflow in allocation 2018-07-03 11:21:34 +02:00
virt
virtio
vlynq
vme
w1 1wire: family module autoload fails because of upper/lower case mismatch. 2018-07-03 11:21:27 +02:00
watchdog watchdog: f71808e_wdt: Fix magic close handling 2018-05-30 07:49:03 +02:00
xen xen: Remove unnecessary BUG_ON from __unbind_from_irq() 2018-07-03 11:21:34 +02:00
zorro zorro: Set up z->dev.dma_mask for the DMA API 2018-05-30 07:49:11 +02:00
Kconfig
Makefile