freebsd-dev/sys
Hans Petter Selasky c6ccb08686 ibcore: Fix a use-after-free in ucma_resolve_ip().
There is a race condition between ucma_close() and ucma_resolve_ip():

CPU0                            CPU1
ucma_resolve_ip():              ucma_close():

ctx = ucma_get_ctx(file, cmd.id);

        list_for_each_entry_safe(ctx, tmp, &file->ctx_list, list) {
                mutex_lock(&mut);
                idr_remove(&ctx_idr, ctx->id);
                mutex_unlock(&mut);
                ...
                mutex_lock(&mut);
                if (!ctx->closing) {
                        mutex_unlock(&mut);
                        rdma_destroy_id(ctx->cm_id);
                ...
                ucma_free_ctx(ctx);
        }

ret = rdma_resolve_addr();
ucma_put_ctx(ctx);

Before idr_remove(), ucma_get_ctx() could still find the ctx
and after rdma_destroy_id(), rdma_resolve_addr() may still
access id_priv pointer. Also, ucma_put_ctx() may use ctx after
ucma_free_ctx() too.

ucma_close() should call ucma_put_ctx() too which tests the
refcnt and waits for the last one releasing it. The similar
pattern is already used by ucma_destroy_id().

Linux commit:
5fe23f262e0548ca7f19fb79f89059a60d087d22

MFC after:	1 week
Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-07-12 14:22:32 +02:00
..
amd64 igc(4): Introduce new driver for the Intel I225 Ethernet controller. 2021-07-12 14:57:18 +10:00
arm Revert "Pass the syscall number to capsicum permission-denied signals" 2021-07-10 20:26:01 +01:00
arm64 Revert "Pass the syscall number to capsicum permission-denied signals" 2021-07-10 20:26:01 +01:00
bsm
cam cam: enable kern.cam.ada.enable_uma_ccbs by default 2021-07-07 09:40:34 +01:00
cddl
compat LinuxKPI: Force the usleep_range() function to sleep instead of spinning on the timer. 2021-07-10 21:59:31 +02:00
conf igc(4): Introduce new driver for the Intel I225 Ethernet controller. 2021-07-12 14:57:18 +10:00
contrib zfs: merge openzfs/zfs@bdd11cbb9 (master) into main 2021-07-07 23:31:52 +02:00
crypto ossl: Use crypto_cursor_segment(). 2021-05-25 16:59:19 -07:00
ddb
dev mlx5core: Make sure error code is propagated on error. 2021-07-12 14:22:31 +02:00
dts dts: Bump the freebsd branding version to 5.13 2021-07-01 18:48:56 +02:00
fs nfscl: Add a Linux compatible "nconnect" mount option 2021-07-08 17:39:04 -07:00
gdb
geom geom_label: Remove an old sysinstall(8) workaround 2021-07-05 16:15:32 +01:00
gnu
i386 igc(4): Introduce new driver for the Intel I225 Ethernet controller. 2021-07-12 14:57:18 +10:00
isa newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf 2021-06-22 20:52:06 -06:00
kern cache: add cache_enter_time_flags 2021-07-12 07:03:14 +02:00
kgssapi
libkern
mips Revert "Pass the syscall number to capsicum permission-denied signals" 2021-07-10 20:26:01 +01:00
modules igc(4): Introduce new driver for the Intel I225 Ethernet controller. 2021-07-12 14:57:18 +10:00
net pf: add DIOCGETSTATESV2 2021-07-09 10:29:53 +02:00
net80211 net80211: ieee80211_probereq_ie fix length calculation for hw scans 2021-06-28 12:17:11 +00:00
netgraph Consistently use the SOLISTENING() macro 2021-06-14 17:32:27 -04:00
netinet libalias: fix divide by zero causing panic 2021-07-10 13:08:18 +02:00
netinet6 sctp: Fix errno in case of association setup failures 2021-07-09 23:19:25 +02:00
netipsec ipsec: globalize lft zone and zero out buffers at allocation time 2021-06-28 08:14:26 +00:00
netpfil pf: bound DIOCGETSTATESV2 memory use 2021-07-09 10:30:02 +02:00
netsmb netsmb: Avoid a read-after-free in smb_t2_request_int() 2021-05-26 10:45:40 -04:00
nfs
nfsclient
nfsserver
nlm
ofed ibcore: Fix a use-after-free in ucma_resolve_ip(). 2021-07-12 14:22:32 +02:00
opencrypto crypto: Remove now-unused crypto_cursor_seg{base,len}. 2021-06-16 15:23:16 -07:00
powerpc Revert "Pass the syscall number to capsicum permission-denied signals" 2021-07-10 20:26:01 +01:00
riscv Revert "Pass the syscall number to capsicum permission-denied signals" 2021-07-10 20:26:01 +01:00
rpc Consistently use the SOLISTENING() macro 2021-06-14 17:32:27 -04:00
security mac: cheaper check for ifnet_create_mbuf and ifnet_check_transmit 2021-06-29 15:06:45 +02:00
sys cache: add cache_enter_time_flags 2021-07-12 07:03:14 +02:00
teken
tests tests: Revise FIB lookups per second benchmarking routines 2021-06-17 08:49:09 +02:00
tools
ufs ffs_softdep: force sync if journal is low in journal_check_space 2021-06-23 23:47:05 +03:00
vm uma: Fix a few problems with KASAN integration 2021-07-09 20:38:50 -04:00
x86 x86: Mark the trapframe as initialized in ipi_bitmap_handler() 2021-07-09 20:38:50 -04:00
xdr
xen
Makefile