linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] bdi: fix use-after-free for bdi device
@ 2020-03-23 13:22 Yufen Yu
  2020-03-23 13:22 ` [PATCH v3 1/4] bdi: use bdi_dev_name() to get device name Yufen Yu
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Yufen Yu @ 2020-03-23 13:22 UTC (permalink / raw)
  To: axboe, linux-block; +Cc: tj, jack, bvanassche, tytso, gregkh

Hi, all 

We have reported a use-after-free crash for bdi device in __blkg_prfill_rwstat().
The bug is caused by printing device kobj->name while the device and kobj->name
has been freed by bdi_unregister().

In fact, commit 68f23b8906 "memcg: fix a crash in wb_workfn when a device disappears"
has tried to address the issue, but the code is till somewhat racy after that commit.

In this patchset, we try to protect bdi->dev with spinlock, and copy device name
into buffer, avoiding use-after-free. 

V2:
  https://www.spinics.net/lists/linux-fsdevel/msg163206.html
  Rry to protect device lifetime with RCU.

V1:
  https://www.spinics.net/lists/linux-block/msg49693.html
  Add a new spinlock and copy kobj->name into caller buffer.
  Or using synchronize_rcu() to wait until reader complete.

Yufen Yu (4):
  bdi: use bdi_dev_name() to get device name
  bdi: add new bdi_get_dev_name()
  bdi: replace bdi_dev_name() with bdi_get_dev_name()
  bdi: protect bdi->dev with spinlock

 block/bfq-iosched.c              |  6 +++--
 block/blk-cgroup-rwstat.c        |  6 +++--
 block/blk-cgroup.c               | 19 +++++-----------
 block/blk-iocost.c               | 14 +++++++-----
 block/blk-iolatency.c            |  5 +++--
 block/blk-throttle.c             |  6 +++--
 fs/ceph/debugfs.c                |  2 +-
 fs/fs-writeback.c                |  4 +++-
 include/linux/backing-dev-defs.h |  1 +
 include/linux/backing-dev.h      | 23 +++++++++++++++++++
 include/linux/blk-cgroup.h       |  1 -
 include/trace/events/wbt.h       |  8 +++----
 include/trace/events/writeback.h | 38 ++++++++++++++------------------
 mm/backing-dev.c                 |  9 ++++++--
 14 files changed, 85 insertions(+), 57 deletions(-)

-- 
2.17.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-03-23 16:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23 13:22 [PATCH v3 0/4] bdi: fix use-after-free for bdi device Yufen Yu
2020-03-23 13:22 ` [PATCH v3 1/4] bdi: use bdi_dev_name() to get device name Yufen Yu
2020-03-23 16:52   ` Christoph Hellwig
2020-03-23 13:22 ` [PATCH v3 2/4] bdi: add new bdi_get_dev_name() Yufen Yu
2020-03-23 13:22 ` [PATCH v3 3/4] bdi: replace bdi_dev_name() with bdi_get_dev_name() Yufen Yu
2020-03-23 16:54   ` Christoph Hellwig
2020-03-23 13:22 ` [PATCH v3 4/4] bdi: protect bdi->dev with spinlock Yufen Yu
2020-03-23 14:04   ` Greg KH
2020-03-23 14:10     ` Yufen Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).