alistair23-linux/include/trace/events
Theodore Ts'o c2c814fc9a memcg: fix a crash in wb_workfn when a device disappears
commit 68f23b8906 upstream.

Without memcg, there is a one-to-one mapping between the bdi and
bdi_writeback structures.  In this world, things are fairly
straightforward; the first thing bdi_unregister() does is to shutdown
the bdi_writeback structure (or wb), and part of that writeback ensures
that no other work queued against the wb, and that the wb is fully
drained.

With memcg, however, there is a one-to-many relationship between the bdi
and bdi_writeback structures; that is, there are multiple wb objects
which can all point to a single bdi.  There is a refcount which prevents
the bdi object from being released (and hence, unregistered).  So in
theory, the bdi_unregister() *should* only get called once its refcount
goes to zero (bdi_put will drop the refcount, and when it is zero,
release_bdi gets called, which calls bdi_unregister).

Unfortunately, del_gendisk() in block/gen_hd.c never got the memo about
the Brave New memcg World, and calls bdi_unregister directly.  It does
this without informing the file system, or the memcg code, or anything
else.  This causes the root wb associated with the bdi to be
unregistered, but none of the memcg-specific wb's are shutdown.  So when
one of these wb's are woken up to do delayed work, they try to
dereference their wb->bdi->dev to fetch the device name, but
unfortunately bdi->dev is now NULL, thanks to the bdi_unregister()
called by del_gendisk().  As a result, *boom*.

Fortunately, it looks like the rest of the writeback path is perfectly
happy with bdi->dev and bdi->owner being NULL, so the simplest fix is to
create a bdi_dev_name() function which can handle bdi->dev being NULL.
This also allows us to bulletproof the writeback tracepoints to prevent
them from dereferencing a NULL pointer and crashing the kernel if one is
tracing with memcg's enabled, and an iSCSI device dies or a USB storage
stick is pulled.

The most common way of triggering this will be hotremoval of a device
while writeback with memcg enabled is going on.  It was triggering
several times a day in a heavily loaded production environment.

Google Bug Id: 145475544

Link: https://lore.kernel.org/r/20191227194829.150110-1-tytso@mit.edu
Link: http://lkml.kernel.org/r/20191228005211.163952-1-tytso@mit.edu
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: Chris Mason <clm@fb.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-02-11 04:35:11 -08:00
..
9p.h
afs.h afs: Fix use-after-loss-of-ref 2020-01-17 19:48:41 +01:00
alarmtimer.h
asoc.h
bcache.h
block.h
bpf_test_run.h selftests: bpf: test writable buffers in raw tps 2019-04-26 19:04:19 -07:00
bridge.h
btrfs.h btrfs: tracepoints: Fix bad entry members of qgroup events 2019-10-17 14:09:37 +02:00
cachefiles.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 36 2019-05-24 17:27:11 +02:00
cgroup.h cgroup: add tracing points for cgroup v2 freezer 2019-04-19 11:26:49 -07:00
clk.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
cma.h
compaction.h mm, compaction: some tracepoints should be defined only when CONFIG_COMPACTION is set 2019-05-14 09:47:46 -07:00
context_tracking.h
cpuhp.h treewide: Switch printk users from %pf and %pF to %ps and %pS, respectively 2019-04-09 14:19:06 +02:00
devfreq.h trace: events: add devfreq trace event file 2019-04-16 09:29:18 +09:00
devlink.h devlink: Add support for direct reporter health state update 2019-03-04 11:00:43 -08:00
dma_fence.h tracing: Fix header include guards in trace event headers 2019-07-30 21:49:06 -04:00
erofs.h erofs: use erofs_inode naming 2019-09-05 20:10:07 +02:00
ext4.h
f2fs.h f2fs-for-5.3-rc1 2019-07-12 17:28:24 -07:00
fib.h net: Replace nhc_has_gw with nhc_gw_family 2019-04-08 15:22:40 -07:00
fib6.h ipv6: Add fib6_type and fib6_flags to fib6_result 2019-04-17 23:11:30 -07:00
filelock.h locks: revise generic_add_lease tracepoint 2019-07-22 06:54:41 -04:00
filemap.h
fs_dax.h
fscache.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 36 2019-05-24 17:27:11 +02:00
fsi.h
fsi_master_ast_cf.h
fsi_master_gpio.h
gpio.h tracing: stop making gpio tracing configurable 2019-04-08 15:11:48 +02:00
host1x.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 1 2019-05-21 11:28:39 +02:00
hswadsp.h
huge_memory.h mm: khugepaged: add trace status description for SCAN_PAGE_HAS_PRIVATE 2020-01-23 08:22:41 +01:00
hwmon.h
i2c.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 36 2019-05-24 17:27:11 +02:00
ib_mad.h IB/MAD: Add SMP details to MAD tracing 2019-03-27 15:52:01 -03:00
ib_umad.h IB/UMAD: Add umad trace points 2019-03-27 15:52:01 -03:00
initcall.h
intel-sst.h
intel_iommu.h iommu/vt-d: Add trace events for device dma map/unmap 2019-09-11 12:34:30 +02:00
intel_ish.h
iocost.h blkcg: blk-iocost: predeclare used structs 2019-08-29 09:43:34 -06:00
iommu.h
ipi.h
irq.h
irq_matrix.h
iscsi.h
jbd2.h
kmem.h mm, tracing: Print symbol name for call_site in trace events 2019-09-28 17:13:39 -04:00
kvm.h
kyber.h
libata.h
lock.h
mce.h
mdio.h
migrate.h
mlxsw.h mlxsw: spectrum_acl: Rename rehash_dis trace 2019-03-31 11:01:23 -07:00
mmc.h
mmflags.h
module.h
napi.h tracing: Fix header include guards in trace event headers 2019-07-30 21:49:06 -04:00
nbd.h nbd: add tracepoints for send/receive timing 2019-04-26 19:04:19 -07:00
neigh.h neighbor: Add tracepoint to __neigh_create 2019-05-22 17:50:24 -07:00
net.h net: add a generic tracepoint for TX queue timeout 2019-05-04 00:41:41 -04:00
net_probe_common.h
nilfs2.h
nmi.h
objagg.h
oom.h
page_isolation.h
page_pool.h page_pool: add tracepoints for page_pool with details need by XDP 2019-06-19 11:23:13 -04:00
page_ref.h
pagemap.h
percpu.h
power.h PM: QoS: Get rid of unused flags 2019-08-21 00:38:54 +02:00
power_cpu_migrate.h
preemptirq.h tracing: Change offset type to s32 in preempt/irq tracepoints 2020-01-14 20:08:22 +01:00
printk.h
pwc.h media: usb: pwc: Introduce TRACE_EVENTs for pwc_isoc_handler() 2019-01-16 11:15:11 -05:00
qdisc.h tracing: Fix header include guards in trace event headers 2019-07-30 21:49:06 -04:00
random.h random: only read from /dev/random after its pool has received 128 bits 2019-04-17 10:30:21 -04:00
rcu.h rcu/nocb: Use rcu_segcblist for no-CBs CPUs 2019-08-13 14:35:49 -07:00
rdma.h
regulator.h
rpcgss.h SUNRPC: Introduce trace points in rpc_auth_gss.ko 2019-02-14 09:20:40 -05:00
rpcrdma.h xprtrdma: Add unique trace points for posting Local Invalidate WRs 2020-01-17 19:48:38 +01:00
rpm.h
rseq.h
rtc.h
rxrpc.h rxrpc: Fix trace-after-put looking at the put call record 2019-10-07 11:05:05 +01:00
sched.h sched/debug: Add sched_overutilized tracepoint 2019-06-24 19:23:42 +02:00
scsi.h
sctp.h
signal.h
siox.h
skb.h
smbus.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 36 2019-05-24 17:27:11 +02:00
sock.h tcp: annotate sk->sk_wmem_queued lockless reads 2019-10-13 10:13:08 -07:00
spi.h spi/trace: Cap buffer contents at 64 bytes 2019-05-02 10:37:52 +09:00
spmi.h
sunrpc.h NFS client updates for Linux 5.2 2019-05-09 14:33:15 -07:00
sunvnet.h
swiotlb.h
syscalls.h syscalls: Remove start and number from syscall_get_arguments() args 2019-04-05 09:26:43 -04:00
target.h
task.h
tcp.h tcp: remove redundant new line from tcp_event_sk_skb 2019-11-09 19:41:50 -08:00
tegra_apb_dma.h tracing: Fix header include guards in trace event headers 2019-07-30 21:49:06 -04:00
thermal.h
thermal_power_allocator.h
thp.h
timer.h timer/trace: Improve timer tracing 2019-03-24 20:29:33 +01:00
tlb.h
udp.h
ufs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284 2019-06-05 17:36:37 +02:00
v4l2.h
vb2.h
vmscan.h mm/vmscan: simplify trace_reclaim_flags and trace_shrink_flags 2019-05-14 09:47:51 -07:00
vsock_virtio_transport_common.h
wbt.h block: Fix writeback throttling W=1 compiler warnings 2019-12-31 16:43:47 +01:00
workqueue.h treewide: Switch printk users from %pf and %pF to %ps and %pS, respectively 2019-04-09 14:19:06 +02:00
writeback.h memcg: fix a crash in wb_workfn when a device disappears 2020-02-11 04:35:11 -08:00
xdp.h page_pool: do not release pool until inflight == 0. 2019-12-18 16:09:07 +01:00
xen.h tracing: xen: Ordered comparison of function pointers 2020-01-29 16:45:30 +01:00