Josh Poimboeuf
3ec24776bf
livepatch: allow removal of a disabled patch
...
Currently we do not allow patch module to unload since there is no
method to determine if a task is still running in the patched code.
The consistency model gives us the way because when the unpatching
finishes we know that all tasks were marked as safe to call an original
function. Thus every new call to the function calls the original code
and at the same time no task can be somewhere in the patched code,
because it had to leave that code to be marked as safe.
We can safely let the patch module go after that.
Completion is used for synchronization between module removal and sysfs
infrastructure in a similar way to commit 942e443127 ("module: Fix
mod->mkobj.kobj potentially freed too early").
Note that we still do not allow the removal for immediate model, that is
no consistency model. The module refcount may increase in this case if
somebody disables and enables the patch several times. This should not
cause any harm.
With this change a call to try_module_get() is moved to
__klp_enable_patch from klp_register_patch to make module reference
counting symmetric (module_put() is in a patch disable path) and to
allow to take a new reference to a disabled module when being enabled.
Finally, we need to be very careful about possible races between
klp_unregister_patch(), kobject_put() functions and operations
on the related sysfs files.
kobject_put(&patch->kobj) must be called without klp_mutex. Otherwise,
it might be blocked by enabled_store() that needs the mutex as well.
In addition, enabled_store() must check if the patch was not
unregisted in the meantime.
There is no need to do the same for other kobject_put() callsites
at the moment. Their sysfs operations neither take the lock nor
they access any data that might be freed in the meantime.
There was an attempt to use kobjects the right way and prevent these
races by design. But it made the patch definition more complicated
and opened another can of worms. See
https://lkml.kernel.org/r/1464018848-4303-1-git-send-email-pmladek@suse.com
[Thanks to Petr Mladek for improving the commit message.]
Signed-off-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2017-03-08 09:38:43 +01:00
..
ABI
livepatch: change to a per-task consistency model
2017-03-08 09:36:21 +01:00
accounting
acpi
scripts/spelling.txt: add "followings" pattern and fix typo instances
2017-02-27 18:43:47 -08:00
admin-guide
scripts/spelling.txt: add "an user" pattern and fix typo instances
2017-02-27 18:43:46 -08:00
aoe
arm
arm: sunxi: add support for V3s SoC
2017-01-20 21:31:34 +01:00
arm64
arm64: Work around Falkor erratum 1003
2017-02-10 11:22:12 +00:00
auxdisplay
backlight
blackfin
block
A slightly quieter cycle for documentation this time around.
2017-02-22 18:51:29 -08:00
blockdev
scripts/spelling.txt: add "followings" pattern and fix typo instances
2017-02-27 18:43:47 -08:00
bus-devices
cdrom
cdrom: Make device operations read-only
2017-02-14 08:29:56 -07:00
cgroup-v1
Merge branch 'for-4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
2017-02-27 21:41:08 -08:00
cma
connector
console
core-api
cpu-freq
A slightly quieter cycle for documentation this time around.
2017-02-22 18:51:29 -08:00
cpuidle
cris
crypto
crypto: doc - fix typo
2017-02-15 13:23:49 +08:00
dev-tools
Improve sparse documentation
2017-02-15 15:09:13 -07:00
device-mapper
scripts/spelling.txt: add "explictely" pattern and fix typo instances
2017-02-27 18:43:47 -08:00
devicetree
ARM: SoC: late DT updates for v4.11
2017-03-03 16:15:48 -08:00
dmaengine
doc-guide
DocBook
A few fixes for the docs tree, including one for a 4.11 build regression.
2017-03-04 11:32:18 -08:00
driver-api
Less anger inducing pull request for 4.11
2017-02-23 18:58:18 -08:00
driver-model
irqdesc: Add a resource managed version of irq_alloc_descs()
2017-02-10 14:39:20 +01:00
early-userspace
EDID
extcon
fault-injection
fb
features
filesystems
livepatch: add /proc/<pid>/patch_state
2017-03-08 09:38:19 +01:00
firmware_class
fmc
fpga
fpga: Add scatterlist based programming
2017-02-10 15:20:44 +01:00
frv
gpio
gpio: random documentation update
2017-01-31 15:43:05 +01:00
gpu
Less anger inducing pull request for 4.11
2017-02-23 18:58:18 -08:00
hid
hwmon
A slightly quieter cycle for documentation this time around.
2017-02-22 18:51:29 -08:00
i2c
i2c: i801: Add support for Intel Gemini Lake
2017-02-09 17:39:16 +01:00
ia64
ide
iio
infiniband
input
Documentation: input: fix path to input code definitions
2017-02-12 15:19:00 -07:00
ioctl
rpmsg updates for v4.11
2017-02-23 09:41:03 -08:00
isdn
kbuild
kdump
laptops
leds
leds: class: Add new optional brightness_hw_changed attribute
2017-01-29 19:59:42 +01:00
livepatch
livepatch: allow removal of a disabled patch
2017-03-08 09:38:43 +01:00
locking
m68k
md
MD: add doc for raid5-cache
2017-02-13 09:17:54 -08:00
media
A few fixes for the docs tree, including one for a 4.11 build regression.
2017-03-04 11:32:18 -08:00
memory-devices
metag
mic
mips
misc-devices
mmc
mn10300
mtd
namespaces
netlabel
networking
scripts/spelling.txt: add "an user" pattern and fix typo instances
2017-02-27 18:43:46 -08:00
nfc
nios2
nvdimm
nvmem
parisc
PCI
A few fixes for the docs tree, including one for a 4.11 build regression.
2017-03-04 11:32:18 -08:00
pcmcia
perf
perf: add qcom l2 cache perf events driver
2017-02-08 19:32:24 +00:00
phy
platform
power
More power management updates for v4.11-rc1
2017-03-02 17:33:52 -08:00
powerpc
pps
prctl
process
pti
ptp
rapidio
RCU
Merge branches 'doc.2017.01.15b', 'dyntick.2017.01.23a', 'fixes.2017.01.23a', 'srcu.2017.01.25a' and 'torture.2017.01.15b' into HEAD
2017-01-25 12:56:05 -08:00
s390
Documentation: Update path to sysrq.txt
2017-03-03 15:48:38 -07:00
scheduler
sched/Documentation/sched-rt-group: Fix incorrect example
2017-01-22 10:34:17 +01:00
scsi
scripts/spelling.txt: add "varible" pattern and fix typo instances
2017-02-27 18:43:47 -08:00
security
KEYS: Differentiate uses of rcu_dereference_key() and user_key_payload()
2017-03-02 10:09:00 +11:00
serial
sh
sound
scripts/spelling.txt: add "followings" pattern and fix typo instances
2017-02-27 18:43:47 -08:00
sparc
Documentation/sparc: Steps for sending break on sunhv console
2017-02-23 08:27:25 -08:00
sphinx
sphinx-static
spi
spi: spi-ep93xx: simplify GPIO chip selects
2017-02-16 20:10:26 +00:00
sysctl
A few fixes for the docs tree, including one for a 4.11 build regression.
2017-03-04 11:32:18 -08:00
target
thermal
timers
time: Remove CONFIG_TIMER_STATS
2017-02-10 11:15:08 +01:00
trace
trace-vmscan-postprocess: sync with tracepoints updates
2017-02-22 16:41:29 -08:00
translations
doc/ko_KR/memory-barriers: Update control-dependencies section
2017-03-03 15:54:55 -07:00
usb
A slightly quieter cycle for documentation this time around.
2017-02-22 18:51:29 -08:00
virtual
A few fixes for the docs tree, including one for a 4.11 build regression.
2017-03-04 11:32:18 -08:00
vm
scripts/spelling.txt: add "an user" pattern and fix typo instances
2017-02-27 18:43:46 -08:00
w1
watchdog
watchdog: Introduce watchdog_stop_on_unregister helper
2017-02-24 14:00:23 -08:00
wimax
x86
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
2017-02-28 11:46:00 -08:00
xtensa
.gitignore
00-INDEX
Documentation: move MD related doc into a separate dir
2017-02-13 09:17:53 -08:00
bcache.txt
bt8xxgpio.txt
btmrvl.txt
bus-virt-phys-mapping.txt
cachetlb.txt
cgroup-v2.txt
Merge branch 'cgroup/for-4.11-rdmacg' into cgroup/for-4.11
2017-02-02 13:50:35 -05:00
Changes
circular-buffers.txt
clk.txt
CodingStyle
conf.py
Documentation/sphinx: fix primary_domain configuration
2017-03-03 16:12:30 -07:00
cpu-load.txt
cputopology.txt
crc32.txt
dcdbas.txt
debugging-modules.txt
debugging-via-ohci1394.txt
dell_rbu.txt
digsig.txt
DMA-API-HOWTO.txt
DMA-API.txt
DMA-attributes.txt
common: DMA-mapping: add DMA_ATTR_PRIVILEGED attribute
2017-01-19 15:56:19 +00:00
DMA-ISA-LPC.txt
Documentation: DMA-ISA-LPC.txt
2017-02-12 15:20:07 -07:00
docutils.conf
dontdiff
Documentation: dontdiff: Update with additional entries
2017-01-26 15:08:06 -07:00
efi-stub.txt
eisa.txt
flexible-arrays.txt
futex-requeue-pi.txt
gcc-plugins.txt
highuid.txt
hw_random.txt
hwspinlock.txt
index.rst
docs/zh_CN: Add coding-style into docs build system
2017-01-26 15:30:34 -07:00
Intel-IOMMU.txt
intel_txt.txt
io-mapping.txt
io_ordering.txt
iostats.txt
IPMI.txt
IRQ-affinity.txt
IRQ-domain.txt
IRQ.txt
irqflags-tracing.txt
isa.txt
isapnp.txt
kernel-doc-nano-HOWTO.txt
kernel-per-CPU-kthreads.txt
kobject.txt
kprobes.txt
kref.txt
kselftest.txt
scripts/spelling.txt: add "an user" pattern and fix typo instances
2017-02-27 18:43:46 -08:00
ldm.txt
lockup-watchdogs.txt
logo.gif
logo.txt
lzo.txt
mailbox.txt
Makefile
Makefile.sphinx
Add a target to check broken external links in the Documentation
2017-02-15 15:22:47 -07:00
memory-barriers.txt
memory-hotplug.txt
scripts/spelling.txt: add "followings" pattern and fix typo instances
2017-02-27 18:43:47 -08:00
men-chameleon-bus.txt
nommu-mmap.txt
ntb.txt
numastat.txt
padata.txt
parport-lowlevel.txt
percpu-rw-semaphore.txt
phy.txt
pi-futex.txt
pinctrl.txt
pnp.txt
preempt-locking.txt
printk-formats.txt
pwm.txt
rbtree.txt
remoteproc.txt
rfkill.txt
robust-futex-ABI.txt
robust-futexes.txt
rpmsg.txt
rtc.txt
SAK.txt
sgi-ioc4.txt
siphash.txt
SM501.txt
smsc_ece1099.txt
static-keys.txt
jump_label: Reduce the size of struct static_key
2017-02-15 09:02:26 -05:00
SubmittingPatches
svga.txt
sync_file.txt
this_cpu_ops.txt
unaligned-memory-access.txt
unshare.txt
vfio-mediated-device.txt
vfio.txt
video-output.txt
xillybus.txt
xz.txt
zorro.txt