pktgen: do not sleep with the thread lock held.
Paolo Abeni authored
[ Upstream commit 720f1de4 ]

Currently, the process issuing a "start" command on the pktgen procfs
interface, acquires the pktgen thread lock and never release it, until
all pktgen threads are completed. The above can blocks indefinitely any
other pktgen command and any (even unrelated) netdevice removal - as
the pktgen netdev notifier acquires the same lock.

The issue is demonstrated by the following script, reported by Matteo:

ip -b - <<'EOF'
	link add type dummy
	link add type veth
	link set dummy0 up
EOF
modprobe pktgen
echo reset >/proc/net/pktgen/pgctrl
{
	echo rem_device_all
	echo add_device dummy0
} >/proc/net/pktgen/kpktgend_0
echo count 0 >/proc/net/pktgen/dummy0
echo start >/proc/net/pktgen/pgctrl &
sleep 1
rmmod veth

Fix the above releasing the thread lock around the sleep call.

Additionally we must prevent racing with forcefull rmmod - as the
thread lock no more protects from them. Instead, acquire a self-ref...
44657dbb
Name Last commit Last update
..
6lowpan 6lowpan: iphc: reset mac_header after decompress to fix panic
802 net: Kill dev_rebuild_header
8021q vlan: disable SIOCSHWTSTAMP in container
9p 9p: do not trust pdu content for stat item size
appletalk appletalk: Fix use-after-free in atalk_proc_exit
atm net: atm: Fix potential Spectre v1 vulnerabilities
ax25 ax25: fix possible use-after-free
batman-adv batman-adv: fix uninit-value in batadv_interface_tx()
bluetooth Bluetooth: Align minimum encryption key size for LE and BR/EDR connections
bridge bridge: Fix error path for kobject_init_and_add()
caif net: caif: Add a missing rcu_read_unlock() in caif_flow_cb
can can: bcm: check timer values before ktime conversion
ceph libceph: handle an empty authorize reply
core pktgen: do not sleep with the thread lock held.
dcb net: dcb: For wild-card lookups, use priority -1, not 0
dccp dccp: do not use ipv6 header for ipv4 flow
decnet dn_getsockoptdecnet: move nf_{get/set}sockopt outside sock lock
dns_resolver KEYS: DNS: fix parsing multiple options
dsa net: dsa: slave: Don't propagate flag changes on down slave interfaces
ethernet net: introduce device min_header_len
hsr net/hsr: fix possible crash in add_timer()
ieee802154 inet: frags: fix ip6frag_low_thresh boundary
ipv4 xfrm4: Fix uninitialized memory read in _decode_session4
ipv6 ipv6: Consider sk_bound_dev_if when binding a raw socket to an address
ipx ipx: call ipxitf_put() in ioctl error path
irda
iucv
key
l2tp
l3mdev
lapb
llc
mac80211
mac802154
mpls
netfilter
netlabel
netlink
netrom
nfc
openvswitch
packet
phonet
rds
rfkill
rose
rxrpc
sched
sctp
sunrpc
switchdev
tipc
unix
vmw_vsock
wimax
wireless
x25
xfrm
Kconfig
Makefile
compat.c
socket.c
sysctl_net.c