From patchwork Fri Feb 28 16:18:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Schatzberg X-Patchwork-Id: 11412751 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 56CA117E0 for ; Fri, 28 Feb 2020 16:19:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 229C22467B for ; Fri, 28 Feb 2020 16:19:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QI2MdFg7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 229C22467B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 501CE6B0006; Fri, 28 Feb 2020 11:19:12 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 48BAA6B0007; Fri, 28 Feb 2020 11:19:12 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32C396B000A; Fri, 28 Feb 2020 11:19:12 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0138.hostedemail.com [216.40.44.138]) by kanga.kvack.org (Postfix) with ESMTP id 14C1D6B0006 for ; Fri, 28 Feb 2020 11:19:12 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B353D183B95B6 for ; Fri, 28 Feb 2020 16:19:11 +0000 (UTC) X-FDA: 76540045302.20.arm22_6d4f3d5ce604f X-Spam-Summary: 2,0,0,0c099762aa7c2d2d,d41d8cd98f00b204,schatzberg.dan@gmail.com,,RULES_HIT:41:355:379:387:541:560:800:960:973:988:989:1260:1311:1314:1345:1437:1515:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3870:4321:5007:6261:6653:7514:7903:9413:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:12986:13069:13215:13229:13311:13357:13894:14093:14096:14181:14384:14394:14687:14721:21433:21444:21627:21666:21740:30054,0,RBL:209.85.222.195:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: arm22_6d4f3d5ce604f X-Filterd-Recvd-Size: 4278 Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 28 Feb 2020 16:19:11 +0000 (UTC) Received: by mail-qk1-f195.google.com with SMTP id e16so3465355qkl.6 for ; Fri, 28 Feb 2020 08:19:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rcHTuvAOaz4tYd8jn3eVp37XThhB3BUEsbS4Oq9/Ti0=; b=QI2MdFg70JdoM+0mtQmYlNhBY/R8I9De/XO55Qw2Aao6kcTVTMq66d9TtSgvYAY4XB BaHg+Ai8Xprd5PReqzMNqv8qJ0TxbdScIwdt/+I8pg0Li+9l+3XxcJzQ0DPS5DE3Kyyv 3NkiviaIPMf8s5ck94+/g2GdvDwk6ZhhldsS81Op1D/3iDZTfiYk6wZUr/e6Qk6V771j kBTr+gJQF1SZ66Q1Z1V/mrSWNwXYRSa6wCbKlc9ljGGAOFF6O38H/sVNa0aWsRc+Gk8w 2PV2u5+0uDmXyxZSxHd1trnKBXMRt8rWJ8j2WHIIr8wXshZtDrG51SU50ckNeoxddIo0 d7aQ== 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:mime-version :content-transfer-encoding; bh=rcHTuvAOaz4tYd8jn3eVp37XThhB3BUEsbS4Oq9/Ti0=; b=JXttnA16TuV3XTjEaJo+IpHYicWOl7NJHYYi+CwfMeaFdN1EyFP01GK4N2OCgPaR7X FZygAOxyY+9e8NLbIkvrpfJDdOBLTnuA/iI8H6EEHb//uD4Ddnni9Ln776ZZISuqfpuF V+u4JJaxFH8ZSSb9f2lGDovnLCUQuCeg7Fom0Ib5jL+NN8pNPMGhFcJlrCCL+eF18sWg StMIXuSpAZD3kK7ha8CtrTQYWGsBep4xycf4ZYrjXid4kjUvSRpcgerw7vGsWQvLmsq5 sByP8eJjRcV/EgG7tYBZmbWCUuxvjKj/lRXgGDhN6td76KOOAqexZv1XyXKmrAK4GAlT gFWg== X-Gm-Message-State: APjAAAUvODGnKMlBgyx3V6+rTkLZClOp5qjdXDcB93dcCNH4mS1dozi5 Fj0G2Fl3AIADGbyV59q2P/w= X-Google-Smtp-Source: APXvYqx9HquH0V8YJNmUsDuBlRTdbBRa4Lu0KOkH0veOcWdu40Metz2v89QhDe8kIJa7O4HO1oxbUA== X-Received: by 2002:a37:61c3:: with SMTP id v186mr5114393qkb.96.1582906750449; Fri, 28 Feb 2020 08:19:10 -0800 (PST) Received: from dschatzberg-fedora-PC0Y6AEN.thefacebook.com ([2620:10d:c091:500::3:7b95]) by smtp.gmail.com with ESMTPSA id 133sm5368724qkh.109.2020.02.28.08.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 08:19:09 -0800 (PST) From: Dan Schatzberg To: Cc: Jens Axboe , Andrew Morton , Johannes Weiner , Qian Cai , linux-block@vger.kernel.org (open list:BLOCK LAYER), linux-mm@kvack.org (open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)), linux-kernel@vger.kernel.org (open list), Dan Schatzberg Subject: [PATCH] loop: Fix irq lock ordering bug Date: Fri, 28 Feb 2020 11:18:47 -0500 Message-Id: <20200228161847.28107-1-schatzberg.dan@gmail.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: "loop: Use worker per cgroup instead of kworker" in patch series "Charge loop device i/o to issuing cgroup", v3. introduced a lock ordering bug. The previously existing lo->lo_lock was always acquired as spin_lock_irq but never actually used in irq context. The above patch started to use this lock in irq context which triggered a lockdep warning on sysfs reading. Fix this by executing file_path outside of the lock. Signed-off-by: Dan Schatzberg --- drivers/block/loop.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index eb766db48685..366658e60064 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -768,12 +768,18 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf) { ssize_t ret; char *p = NULL; + struct file *filp = NULL; spin_lock_irq(&lo->lo_lock); if (lo->lo_backing_file) - p = file_path(lo->lo_backing_file, buf, PAGE_SIZE - 1); + filp = get_file(lo->lo_backing_file); spin_unlock_irq(&lo->lo_lock); + if (filp) { + p = file_path(filp, buf, PAGE_SIZE - 1); + fput(filp); + } + if (IS_ERR_OR_NULL(p)) ret = PTR_ERR(p); else {