+ writeback-dont-decrement-wb-refcnt-if-wb-bdi.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: writeback: don't decrement wb->refcnt if !wb->bdi
has been added to the -mm tree.  Its filename is
     writeback-dont-decrement-wb-refcnt-if-wb-bdi.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/writeback-dont-decrement-wb-refcnt-if-wb-bdi.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/writeback-dont-decrement-wb-refcnt-if-wb-bdi.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Anders Roxell <anders.roxell@xxxxxxxxxx>
Subject: writeback: don't decrement wb->refcnt if !wb->bdi

This happened while running in qemu-system-aarch64, the AMBA PL011 UART
driver when enabling CONFIG_DEBUG_TEST_DRIVER_REMOVE. 
arch_initcall(pl011_init) came before subsys_initcall(default_bdi_init),
devtmpfs' handle_remove() crashes because the reference count is a NULL
pointer only because wb->bdi hasn't been initialized yet.

Rework so that wb_put have an extra check if wb->bdi before decrement
wb->refcnt and also add a WARN_ON_ONCE to get a warning if it happens
again in other drivers.

Link: http://lkml.kernel.org/r/20181030113545.30999-2-anders.roxell@xxxxxxxxxx
Fixes: 52ebea749aae ("writeback: make backing_dev_info host cgroup-specific bdi_writebacks")
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
Signed-off-by: Anders Roxell <anders.roxell@xxxxxxxxxx>
Co-developed-by: Arnd Bergmann <arnd@xxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 include/linux/backing-dev-defs.h |    8 ++++++++
 1 file changed, 8 insertions(+)

--- a/include/linux/backing-dev-defs.h~writeback-dont-decrement-wb-refcnt-if-wb-bdi
+++ a/include/linux/backing-dev-defs.h
@@ -258,6 +258,14 @@ static inline void wb_get(struct bdi_wri
  */
 static inline void wb_put(struct bdi_writeback *wb)
 {
+	if (WARN_ON_ONCE(!wb->bdi)) {
+		/*
+		 * A driver bug might cause a file to be removed before bdi was
+		 * initialized.
+		 */
+		return;
+	}
+
 	if (wb != &wb->bdi->wb)
 		percpu_ref_put(&wb->refcnt);
 }
_

Patches currently in -mm which might be from anders.roxell@xxxxxxxxxx are

writeback-dont-decrement-wb-refcnt-if-wb-bdi.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux