remarkable-linux/include
Nicolas Schichan 5dbe7c178d net: fix kernel deadlock with interface rename and netdev name retrieval.
When the kernel (compiled with CONFIG_PREEMPT=n) is performing the
rename of a network interface, it can end up waiting for a workqueue
to complete. If userland is able to invoke a SIOCGIFNAME ioctl or a
SO_BINDTODEVICE getsockopt in between, the kernel will deadlock due to
the fact that read_secklock_begin() will spin forever waiting for the
writer process (the one doing the interface rename) to update the
devnet_rename_seq sequence.

This patch fixes the problem by adding a helper (netdev_get_name())
and using it in the code handling the SIOCGIFNAME ioctl and
SO_BINDTODEVICE setsockopt.

The netdev_get_name() helper uses raw_seqcount_begin() to avoid
spinning forever, waiting for devnet_rename_seq->sequence to become
even. cond_resched() is used in the contended case, before retrying
the access to give the writer process a chance to finish.

The use of raw_seqcount_begin() will incur some unneeded work in the
reader process in the contended case, but this is better than
deadlocking the system.

Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-26 13:42:54 -07:00
..
acpi ACPI / PM: Allow device power states to be used for CONFIG_PM unset 2013-05-22 00:19:28 +02:00
asm-generic Merge branch 'fixes' of git://git.kernel.org/pub/scm/virt/kvm/kvm 2013-06-11 11:16:43 -07:00
clocksource ARM: late Exynos multiplatform changes 2013-05-07 11:28:42 -07:00
crypto crypto: sha512 - Expose generic sha512 routine to be callable from other modules 2013-04-25 21:00:57 +08:00
drm Merge branch 'drm-radeon-sun-hainan' of git://people.freedesktop.org/~airlied/linux 2013-05-21 08:50:57 -07:00
dt-bindings ARM: dt: create a DT header for the GIC 2013-04-05 12:23:24 -06:00
keys
linux net: fix kernel deadlock with interface rename and netdev name retrieval. 2013-06-26 13:42:54 -07:00
math-emu
media Merge branch 'topic/omap3isp' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 2013-05-01 09:57:04 -07:00
memory
misc
net ip_tunnel: remove __net_init/exit from exported functions 2013-06-13 03:00:59 -07:00
pcmcia
ras
rdma
rxrpc
scsi Merge branch 'postmerge' into for-linus 2013-05-10 07:54:01 -07:00
sound ASoC: dapm: Treat DAI widgets like AIF widgets for power 2013-06-07 15:54:50 +01:00
target target: Propigate up ->cmd_kref put return via transport_generic_free_cmd 2013-05-31 01:21:23 -07:00
trace Fixed regressions (two stability regressions and a performance 2013-05-14 09:30:54 -07:00
uapi netlink: export netlink_diag.h header 2013-06-19 18:30:27 -07:00
video Merge branch 'fbdev-3.10-fixes' of git://gitorious.org/linux-omap-dss2/linux into linux-fbdev/for-3.10-fixes 2013-05-29 17:00:34 +08:00
xen xenbus: delay xenbus frontend resume if xenstored is not running 2013-05-29 09:04:19 -04:00
Kbuild UAPI: remove empty Kbuild files 2013-04-30 17:04:09 -07:00