android_kernel_motorola_sm6375/drivers
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Valentine Fatiev 21358b3e77 IB/ipoib: Fix double free of skb in case of multicast traffic in CM mode
[ Upstream commit 1acba6a817852d4aa7916d5c4f2c82f702ee9224 ]

When connected mode is set, and we have connected and datagram traffic in
parallel, ipoib might crash with double free of datagram skb.

The current mechanism assumes that the order in the completion queue is
the same as the order of sent packets for all QPs. Order is kept only for
specific QP, in case of mixed UD and CM traffic we have few QPs (one UD and
few CM's) in parallel.

The problem:
----------------------------------------------------------

Transmit queue:
-----------------
UD skb pointer kept in queue itself, CM skb kept in spearate queue and
uses transmit queue as a placeholder to count the number of total
transmitted packets.

0   1   2   3   4  5  6  7  8   9  10  11 12 13 .........127
------------------------------------------------------------
NL ud1 UD2 CM1 ud3 cm2 cm3 ud4 cm4 ud5 NL NL NL ...........
------------------------------------------------------------
    ^                                  ^
   tail                               head

Completion queue (problematic scenario) - the order not the same as in
the transmit queue:

  1  2  3  4  5  6  7  8  9
------------------------------------
 ud1 CM1 UD2 ud3 cm2 cm3 ud4 cm4 ud5
------------------------------------

1. CM1 'wc' processing
   - skb freed in cm separate ring.
   - tx_tail of transmit queue increased although UD2 is not freed.
     Now driver assumes UD2 index is already freed and it could be used for
     new transmitted skb.

0   1   2   3   4  5  6  7  8   9  10  11 12 13 .........127
------------------------------------------------------------
NL NL  UD2 CM1 ud3 cm2 cm3 ud4 cm4 ud5 NL NL NL ...........
------------------------------------------------------------
        ^   ^                       ^
      (Bad)tail                    head
(Bad - Could be used for new SKB)

In this case (due to heavy load) UD2 skb pointer could be replaced by new
transmitted packet UD_NEW, as the driver assumes its free.  At this point
we will have to process two 'wc' with same index but we have only one
pointer to free.

During second attempt to free the same skb we will have NULL pointer
exception.

2. UD2 'wc' processing
   - skb freed according the index we got from 'wc', but it was already
     overwritten by mistake. So actually the skb that was released is the
     skb of the new transmitted packet and not the original one.

3. UD_NEW 'wc' processing
   - attempt to free already freed skb. NUll pointer exception.

The fix:
-----------------------------------------------------------------------

The fix is to stop using the UD ring as a placeholder for CM packets, the
cyclic ring variables tx_head and tx_tail will manage the UD tx_ring, a
new cyclic variables global_tx_head and global_tx_tail are introduced for
managing and counting the overall outstanding sent packets, then the send
queue will be stopped and waken based on these variables only.

Note that no locking is needed since global_tx_head is updated in the xmit
flow and global_tx_tail is updated in the NAPI flow only.  A previous
attempt tried to use one variable to count the outstanding sent packets,
but it did not work since xmit and NAPI flows can run at the same time and
the counter will be updated wrongly. Thus, we use the same simple cyclic
head and tail scheme that we have today for the UD tx_ring.

Fixes: 2c104ea683 ("IB/ipoib: Get rid of the tx_outstanding variable in all modes")
Link: https://lore.kernel.org/r/20200527134705.480068-1-leon@kernel.org
Signed-off-by: Valentine Fatiev <valentinef@mellanox.com>
Signed-off-by: Alaa Hleihel <alaa@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Acked-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-06-03 08:21:26 +02:00
..
accessibility
acpi
amba
android
ata
atm
auxdisplay
base component: Silence bind error on -EPROBE_DEFER 2020-05-27 17:46:31 +02:00
bcma
block
bluetooth
bus
cdrom
char
clk clk: qcom: gcc: Fix parent for gpll0_out_even 2020-06-03 08:21:23 +02:00
clocksource
connector
counter
cpufreq
cpuidle
crypto
dax device-dax: don't leak kernel memory to user space after unloading kmem 2020-05-27 17:46:48 +02:00
dca
devfreq
dio
dma dmaengine: owl: Use correct lock in owl_dma_get_pchan() 2020-05-27 17:46:43 +02:00
dma-buf
edac
eisa
extcon
firewire
firmware tpm: check event log version before reading final events 2020-05-27 17:46:52 +02:00
fpga
fsi
gnss
gpio gpio: bcm-kona: Fix return value of bcm_kona_gpio_probe() 2020-06-03 08:21:21 +02:00
gpu drm/amd/display: drop cursor position check in atomic test 2020-06-03 08:21:25 +02:00
greybus
hid HID: quirks: Add HID_QUIRK_NO_INIT_REPORTS quirk for Dell K12A keyboard-dock 2020-05-27 17:46:34 +02:00
hsi
hv
hwmon hwmon: (nct7904) Fix incorrect range of temperature limit registers 2020-06-03 08:21:14 +02:00
hwspinlock
hwtracing
i2c
i3c
ide
idle
iio iio: adc: stm32-dfsdm: fix device used to request dma 2020-05-27 17:46:51 +02:00
infiniband IB/ipoib: Fix double free of skb in case of multicast traffic in CM mode 2020-06-03 08:21:26 +02:00
input Input: synaptics-rmi4 - fix error return code in rmi_driver_probe() 2020-06-03 08:21:17 +02:00
interconnect
iommu iommu/amd: Call domain_flush_complete() in update_domain() 2020-05-27 17:46:35 +02:00
ipack ipack: tpci200: fix error return code in tpci200_register() 2020-05-27 17:46:47 +02:00
irqchip
isdn
leds
lightnvm
macintosh
mailbox
mcb
md
media media: fdp1: Fix R-Car M3-N naming in debug message 2020-05-27 17:46:44 +02:00
memory
memstick
message
mfd
misc mei: release me_cl object reference 2020-05-27 17:46:47 +02:00
mmc mmc: block: Fix use-after-free issue for rpmb 2020-06-03 08:21:20 +02:00
mtd mtd: Fix mtd not registered due to nvmem name collision 2020-05-27 17:46:22 +02:00
mux
net drivers: net: hamradio: Fix suspicious RCU usage warning in bpqether.c 2020-06-03 08:21:15 +02:00
nfc
ntb
nubus
nvdimm
nvme
nvmem
of
opp
oprofile
parisc
parport
pci
pcmcia
perf
phy
pinctrl
platform platform/x86: asus-nb-wmi: Do not load on Asus T100TA and T200TA 2020-05-27 17:46:35 +02:00
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio rapidio: fix an error in get_user_pages_fast() error handling 2020-05-27 17:46:48 +02:00
ras
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi scsi: qla2xxx: Do not log message when reading port speed via sysfs 2020-05-27 17:46:40 +02:00
sfi
sh
siox
slimbus
soc soc: mediatek: cmdq: return send msg error code 2020-06-03 08:21:19 +02:00
soundwire
spi
spmi
ssb
staging staging: greybus: Fix uninitialized scalar variable 2020-05-27 17:46:45 +02:00
target scsi: target: Put lun_ref at end of tmr processing 2020-05-27 17:46:40 +02:00
tc
tee
thermal
thunderbolt
tty tty: serial: add missing spin_lock_init for SiFive serial console 2020-05-27 17:46:46 +02:00
uio
usb usb: gadget: legacy: fix redundant initialization warnings 2020-06-03 08:21:12 +02:00
vfio
vhost vhost/vsock: fix packet delivery order to monitoring devices 2020-05-27 17:46:31 +02:00
video
virt
virtio
visorbus
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile