From patchwork Wed Oct 17 14:03:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 149073 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp696673lji; Wed, 17 Oct 2018 07:03:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV612s3THfpWXI73WaLiN30ZJxNJQNYIX6Ueq/g219RxNxynoiybBEp7TolS181EJP+D4bkPO X-Received: by 2002:a63:4107:: with SMTP id o7-v6mr24873363pga.256.1539785017147; Wed, 17 Oct 2018 07:03:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539785017; cv=none; d=google.com; s=arc-20160816; b=NZ/jL6e1PXP9K4kz1RpjV5iemUpZKuluaQ2hYf6qu602tmdjOg5gs+gSHp92JRlwrm OSUMTvrDFOFnv29d3G2R/PwrA05jswsYxQlgX90x6DrIaZ2EoAQBzTY9gm/V46OKPfPY oHMntrU5G5TM5yLk4a/PqwSHVBlzpWY9V64lBko05as0Zf72MHdvZIbZZqp71akYcxGK ASQtxEDgYzvpaofFw3sdIRxFulUBF5E6Qjt8XNQHRWC2TYDdaQJnKvG2qAUDfgFl1WUJ MoB0EOoeS6/cZdBHYZlJbcKUzsctOMFh9HLJVfhpmt+RxcyJUxKfT+6u2dBap29MQUcp L1OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FYD5OgbslaSN2IMFW2M3a1vvfCw0/W1XvkhV0Wehs50=; b=UmQGGbkRt2j/N/jeGPnBJ0bE+vR6YsDa0m+Ow69ZUtRpMDp73uYyf+lgaXO2Zuis/7 Iv62pK/w/jZTsO5BQuPRq8XkqrRIeWXn7pO8Y5d88b6TGXrqDH1znKabrqsfy/7S13gY aaVOl2ykvMGUhJlVkF4Urys3dUoGCltnlUTEXYtAIeA1D/WYptJlM7rF4Tw4UFFktH8N jyJWBtuqB/Ky4rnIw/1PN7RxfjkTkvkeKd89XRsvM/lPsT+T+Jm4chHR5/7WkGdb7oPj Xi+Qc8S2Zi22x8aat4EKFimWJkx4gmr7tRo90sbMPq5YWh/5lBwhAAvf3GI/GSU98NE0 b45w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O4IetBcJ; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l4-v6si15752437pgg.503.2018.10.17.07.03.36; Wed, 17 Oct 2018 07:03:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O4IetBcJ; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727050AbeJQV70 (ORCPT + 2 others); Wed, 17 Oct 2018 17:59:26 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:32860 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727061AbeJQV70 (ORCPT ); Wed, 17 Oct 2018 17:59:26 -0400 Received: by mail-lf1-f68.google.com with SMTP id o21-v6so19915990lfe.0 for ; Wed, 17 Oct 2018 07:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FYD5OgbslaSN2IMFW2M3a1vvfCw0/W1XvkhV0Wehs50=; b=O4IetBcJP4FShQawjKO6gD6lkk5p+jXVhrvJjpxnlEbgSrp6i/UyAMQVXvVlNYshZa EguhuuvDlRAJCOPsDRf0dztrSz2A7vIkoDmMjSp2yUrhMgf9aU7SipV+RsEUNZozm+Hj f8KkWtM8gK//jIKmnWh8upOytH4pJ5PUNe+3k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FYD5OgbslaSN2IMFW2M3a1vvfCw0/W1XvkhV0Wehs50=; b=jTH7CKoQ6bJR30tcyy8sLug6og5k39+SwChZEV0SR8ImlS5k6InumJJ7CZthcEruKH 6p7YClpDJeDjx88gVHr/5A7J/8HKELsHc0DBRkxXjmMh4QD4lU+OCQTc+jF9O+K/UuU0 CcudYuheSroyfJ7LcxvrIvGbGIG3ZrGVf8vln9pCJwHxfY3Ofc00bqClF9i8fjMeO6P/ brvmK+O70wKaAVssETLYkfOTgRsKZ75pLjsvV5UghgGuUJg+ZbMXFwO/SMH7J3nmpUU2 IylfrdOdZXx5XbkHznRScZVqCivZpJALER0MRN+Sb2MxAMQCoGZtq/aO+AMUBZ8rcHaw WQmw== X-Gm-Message-State: ABuFfoixIEu6MpFV9BiFw9Sh0/m3cIkogWmwq95QZIMHA3ZUO+c8JN+m cq2NHdfmOrqfjPw8TUdZojxM2Q== X-Received: by 2002:a19:c189:: with SMTP id r131-v6mr14739969lff.59.1539785012982; Wed, 17 Oct 2018 07:03:32 -0700 (PDT) Received: from localhost (c-732171d5.07-21-73746f28.bbcust.telenor.se. [213.113.33.115]) by smtp.gmail.com with ESMTPSA id o101-v6sm3931820lfg.53.2018.10.17.07.03.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Oct 2018 07:03:32 -0700 (PDT) From: Anders Roxell To: linux@armlinux.org.uk, gregkh@linuxfoundation.org, akpm@linux-foundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, tj@kernel.org, Anders Roxell , Arnd Bergmann Subject: [PATCH 2/2] writeback: don't decrement wb->refcnt if !wb->bdi Date: Wed, 17 Oct 2018 16:03:11 +0200 Message-Id: <20181017140311.28679-2-anders.roxell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181017140311.28679-1-anders.roxell@linaro.org> References: <20181017140311.28679-1-anders.roxell@linaro.org> MIME-Version: 1.0 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org When enabling CONFIG_DEBUG_TEST_DRIVER_REMOVE devtmpfs gets killed because we try to remove a file and decrement the wb reference count before the noop_backing_device_info gets initialized. Since 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 bdi->wb hasn't been initialized yet. [ 0.332075] Serial: AMBA PL011 UART driver [ 0.485276] 9000000.pl011: ttyAMA0 at MMIO 0x9000000 (irq = 39, base_baud = 0) is a PL011 rev1 [ 0.502382] console [ttyAMA0] enabled [ 0.515710] Unable to handle kernel paging request at virtual address 0000800074c12000 [ 0.516053] Mem abort info: [ 0.516222] ESR = 0x96000004 [ 0.516417] Exception class = DABT (current EL), IL = 32 bits [ 0.516641] SET = 0, FnV = 0 [ 0.516826] EA = 0, S1PTW = 0 [ 0.516984] Data abort info: [ 0.517149] ISV = 0, ISS = 0x00000004 [ 0.517339] CM = 0, WnR = 0 [ 0.517553] [0000800074c12000] user address but active_mm is swapper [ 0.517928] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 0.518305] Modules linked in: [ 0.518839] CPU: 0 PID: 13 Comm: kdevtmpfs Not tainted 4.19.0-rc5-next-20180928-00002-g2ba39ab0cd01-dirty #82 [ 0.519307] Hardware name: linux,dummy-virt (DT) [ 0.519681] pstate: 80000005 (Nzcv daif -PAN -UAO) [ 0.519959] pc : __destroy_inode+0x94/0x2a8 [ 0.520212] lr : __destroy_inode+0x78/0x2a8 [ 0.520401] sp : ffff0000098c3b20 [ 0.520590] x29: ffff0000098c3b20 x28: 00000000087a3714 [ 0.520904] x27: 0000000000002000 x26: 0000000000002000 [ 0.521179] x25: ffff000009583000 x24: 0000000000000000 [ 0.521467] x23: ffff80007bb52000 x22: ffff80007bbaa7c0 [ 0.521737] x21: ffff0000093f9338 x20: 0000000000000000 [ 0.522033] x19: ffff80007bbb05d8 x18: 0000000000000400 [ 0.522376] x17: 0000000000000000 x16: 0000000000000000 [ 0.522727] x15: 0000000000000400 x14: 0000000000000400 [ 0.523068] x13: 0000000000000001 x12: 0000000000000001 [ 0.523421] x11: 0000000000000000 x10: 0000000000000970 [ 0.523749] x9 : ffff0000098c3a60 x8 : ffff80007bbab190 [ 0.524017] x7 : ffff80007bbaa880 x6 : 0000000000000c88 [ 0.524305] x5 : ffff0000093d96c8 x4 : 61c8864680b583eb [ 0.524567] x3 : ffff0000093d6180 x2 : ffffffffffffffff [ 0.524872] x1 : 0000800074c12000 x0 : 0000800074c12000 [ 0.525207] Process kdevtmpfs (pid: 13, stack limit = 0x(____ptrval____)) [ 0.525529] Call trace: [ 0.525806] __destroy_inode+0x94/0x2a8 [ 0.526108] destroy_inode+0x34/0x88 [ 0.526370] evict+0x144/0x1c8 [ 0.526636] iput+0x184/0x230 [ 0.526871] dentry_unlink_inode+0x118/0x130 [ 0.527152] d_delete+0xd8/0xe0 [ 0.527420] vfs_unlink+0x240/0x270 [ 0.527665] handle_remove+0x1d8/0x330 [ 0.527875] devtmpfsd+0x138/0x1c8 [ 0.528085] kthread+0x14c/0x158 [ 0.528291] ret_from_fork+0x10/0x18 [ 0.528720] Code: 92800002 aa1403e0 d538d081 8b010000 (c85f7c04) [ 0.529367] ---[ end trace 5a3dee47727f877c ]--- Rework so that wb_put have an extra check if wb->bdi before decrement wb->refcnt and also add a WARN_ON to get a warning if it happens again in other drivers. Fixes: 52ebea749aae ("writeback: make backing_dev_info host cgroup-specific bdi_writebacks") Cc: Arnd Bergmann Co-developed-by: Arnd Bergmann Signed-off-by: Anders Roxell --- include/linux/backing-dev-defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.19.1 Signed-off-by: Arnd, please. diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h index 9a6bc0951cfa..20721550d32a 100644 --- a/include/linux/backing-dev-defs.h +++ b/include/linux/backing-dev-defs.h @@ -258,7 +258,7 @@ static inline void wb_get(struct bdi_writeback *wb) */ static inline void wb_put(struct bdi_writeback *wb) { - if (wb != &wb->bdi->wb) + if (!WARN_ON(!wb->bdi) && wb != &wb->bdi->wb) percpu_ref_put(&wb->refcnt); }