Go to file
Elad Nachman 631217c761 kni: fix kernel deadlock with bifurcated device
KNI runs userspace callback with rtnl lock held, this is not working
fine with some devices that needs to interact with kernel interface in
the callback, like Mellanox devices.

The solution is releasing the rtnl lock before calling the userspace
callback. But it requires two consideration:

1. The rtnl lock needs to released before 'kni->sync_lock', otherwise it
   causes deadlock with multiple KNI devices, please check below the A.
   for the details of the deadlock condition.

2. When rtnl lock is released for interface down event, it cause a
   regression and deadlock, so can't release the rtnl lock for interface
   down event, please check below B. for the details.

As a solution, interface down event is handled asynchronously and for
all other events rtnl lock is released before processing the callback.

A. KNI sync lock is being locked while rtnl is held.
If two threads are calling kni_net_process_request() ,
then the first one will take the sync lock, release rtnl lock then sleep.
The second thread will try to lock sync lock while holding rtnl.
The first thread will wake, and try to lock rtnl, resulting in a
deadlock.  The remedy is to release rtnl before locking the KNI sync
lock.
Since in between nothing is accessing Linux network-wise, no rtnl
locking is needed.

B. There is a race condition in __dev_close_many() processing the
close_list while the application terminates.
It looks like if two KNI interfaces are terminating,
and one releases the rtnl lock, the other takes it,
updating the close_list in an unstable state,
causing the close_list to become a circular linked list,
hence list_for_each_entry() will endlessly loop inside
__dev_close_many() .

To summarize:
request != interface down : unlock rtnl, send request to user-space,
wait for response, send the response error code to caller in user-space.

request == interface down: send request to user-space, return immediately
with error code of 0 (success) to user-space.

Fixes: 3fc5ca2f63 ("kni: initial import")
Cc: stable@dpdk.org

Signed-off-by: Elad Nachman <eladv6@gmail.com>
2021-04-21 01:05:37 +02:00
.ci build: update minimum required Meson version 2021-04-16 18:51:51 +02:00
.github/workflows ci: bump ABI reference version 2021-04-16 14:09:03 +02:00
app test/cmdline: silence clang 12 warning 2021-04-21 00:44:24 +02:00
buildtools buildtools: fix all drivers disabled on Windows 2021-04-17 12:49:23 +02:00
config config/arm: add Marvell CN10K 2021-04-21 00:26:20 +02:00
devtools eventdev: introduce crypto adapter enqueue API 2021-04-17 18:49:52 +02:00
doc hash: add predictable RSS 2021-04-20 23:13:23 +02:00
drivers event/octeontx2: support crypto adapter forward mode 2021-04-17 18:50:06 +02:00
examples pipeline: auto-detect endianness of action arguments 2021-04-20 21:55:43 +02:00
kernel kni: fix kernel deadlock with bifurcated device 2021-04-21 01:05:37 +02:00
lib kni: support async user request 2021-04-21 01:05:15 +02:00
license license: fix typos 2021-04-13 13:56:52 +02:00
usertools usertools: show hugepages requested/set on failure 2021-03-25 18:07:47 +01:00
.editorconfig devtools: add EditorConfig file 2020-02-22 21:05:22 +01:00
.gitattributes improve git diff 2016-11-13 15:25:12 +01:00
.gitignore regex/mlx5: introduce driver for BlueField 2 2020-07-21 19:04:05 +02:00
.travis.yml ci: bump ABI reference version 2021-04-16 14:09:03 +02:00
ABI_VERSION version: 21.05-rc0 2021-02-15 11:08:19 +01:00
MAINTAINERS hash: add predictable RSS 2021-04-20 23:13:23 +02:00
Makefile build: create dummy Makefile 2020-09-07 23:51:57 +02:00
meson_options.txt config/arm: add platform config option 2021-04-15 22:34:37 +02:00
meson.build build: update minimum required Meson version 2021-04-16 18:51:51 +02:00
README license: introduce SPDX identifiers 2018-01-04 22:41:38 +01:00
VERSION version: 21.05-rc0 2021-02-15 11:08:19 +01:00

DPDK is a set of libraries and drivers for fast packet processing.
It supports many processor architectures and both FreeBSD and Linux.

The DPDK uses the Open Source BSD-3-Clause license for the core libraries
and drivers. The kernel components are GPL-2.0 licensed.

Please check the doc directory for release notes,
API documentation, and sample application information.

For questions and usage discussions, subscribe to: users@dpdk.org
Report bugs and issues to the development mailing list: dev@dpdk.org