From patchwork Tue Dec 25 05:56:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 1018351 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mit.edu Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mit.edu header.i=@mit.edu header.b="WdANjraQ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43P53C2Db3z9sCr for ; Tue, 25 Dec 2018 16:57:10 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725830AbeLYF5G (ORCPT ); Tue, 25 Dec 2018 00:57:06 -0500 Received: from mail-eopbgr700093.outbound.protection.outlook.com ([40.107.70.93]:60095 "EHLO NAM04-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725823AbeLYF5G (ORCPT ); Tue, 25 Dec 2018 00:57:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wDO6KGsGHGKBqeYZW7N/ovrYkhoGur6oRGmtS0sYJb0=; b=WdANjraQMO67Ue3kyKNWlUlXJ1kaCey5FAVGDyHXTlChxpWnscsLT2wW/GPPcGibcWDeU1N0fQomVlRQTk3HkIqVeuHKB1AT4PHvC7Ent2abwr5CLu1EmZI1n4gPjhplspsgm2UoaAURgdFPWiKPJe8VqdHAAF2Y4dkIj8IqJbU= Received: from SN2PR01CA0037.prod.exchangelabs.com (2603:10b6:804:2::47) by MWHPR01MB2399.prod.exchangelabs.com (2603:10b6:300:3c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.21; Tue, 25 Dec 2018 05:57:01 +0000 Received: from DM3NAM03FT065.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::202) by SN2PR01CA0037.outlook.office365.com (2603:10b6:804:2::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1446.19 via Frontend Transport; Tue, 25 Dec 2018 05:57:00 +0000 Authentication-Results: spf=pass (sender IP is 18.9.28.11) smtp.mailfrom=mit.edu; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=mit.edu; Received-SPF: Pass (protection.outlook.com: domain of mit.edu designates 18.9.28.11 as permitted sender) receiver=protection.outlook.com; client-ip=18.9.28.11; helo=outgoing.mit.edu; Received: from outgoing.mit.edu (18.9.28.11) by DM3NAM03FT065.mail.protection.outlook.com (10.152.82.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1446.11 via Frontend Transport; Tue, 25 Dec 2018 05:57:00 +0000 Received: from callcc.thunk.org ([107.181.182.234]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id wBP5ut6M021389 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Dec 2018 00:56:57 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id 93DC47A4904; Tue, 25 Dec 2018 00:56:55 -0500 (EST) From: Theodore Ts'o To: Ext4 Developers List CC: Theodore Ts'o , Subject: [PATCH] ext4: fix a potential fiemap/page fault deadlock w/ inline_data Date: Tue, 25 Dec 2018 00:56:53 -0500 Message-ID: <20181225055653.9382-1-tytso@mit.edu> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:18.9.28.11; IPV:CAL; SCL:-1; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(396003)(39860400002)(376002)(346002)(136003)(2980300002)(199004)(189003)(8676002)(50226002)(486006)(126002)(186003)(8936002)(6266002)(246002)(90966002)(50466002)(476003)(36756003)(2616005)(14444005)(6916009)(26005)(51416003)(336012)(48376002)(54906003)(106002)(786003)(42186006)(316002)(305945005)(52956003)(36906005)(86362001)(47776003)(1076003)(356004)(5660300001)(75432002)(26826003)(2906002)(4326008)(88552002)(2870700001)(478600001)(106466001)(103686004); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR01MB2399; H:outgoing.mit.edu; FPR:; SPF:Pass; LANG:en; PTR:outgoing-auth-1.mit.edu; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT065; 1:5evDyHi9+sQ8qaIKnDCRC0gxuafC71kqw7zAJnJsPx3rLX7KEfHm1HRV7LAdPWHmm6DgYUBGPXiOJ6ibXzQopffY4Fd0wVrMOETJQLJ/Movka2sCMEd4y3J1UtxCuL9y X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 74b06fc8-404d-4ada-fd50-08d66a2dc990 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4608076)(2017052603328)(7153060); SRVR:MWHPR01MB2399; X-Microsoft-Exchange-Diagnostics: 1; MWHPR01MB2399; 3:17MCuUpy9sIfgSD3h/f+aBCZ3HOUNNExwNNe10+RkBgMuJsnxi4D7ppoA4Flge6OP8ROlWJ9lGuYYpifkRixFqFnx5ivjDK33Cxfco4ZweExy0OK4D0TgxRQEORgXE857nq4cikJJOKfb7bx3u4uCe+7o5pIi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fYA/VmQQT+fNGZC/FQ9DApeCey9RKMa4JwbHY5rQ9NgoGB5/7adTn3x7DxLxJ3Mm5ygQGnA0ticCJlcw6JVgFwUTMnVKe9WUI/JY6x07jHxyRpFWm2hvpqeL39COGWf3N6l/2lNedRsjXMmJFX9X+SQhqQsDJQGUECtfVa9N/8r8zkgQdTWwhMsuDFByVFrusnFILaw1UckTPx/De4yUk/+dz3kRa+Kq0iRmwElWkyGTgru/Wai9uOCBoobvhYUT8x4BRfQSKXtMP8BZw25; 4:20DH7KHKce802b+BiGRZ1oySSz7khPLOnJrOug70Huqa0djrwr68YQymX04uoh+06ouBbyzHpuEtLcSuVotiWPszGWoMc8WwJytGiNT5zNt6LDmwMWfiPYzN4vOXGcuyY612nJQD37n3D4F6mqb2XtVtXPUYnagXY2r7ZE5EPboq1Y9pzky/vndMoexw4DZ/m+ltKbFEgh3WgM4m58/cYohlAPF6Ds3WBx3dtnblqOD6QDo3ds0JtdJk9zo/qPReiT0vcMed2qRJ5oeGoz5LXA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(2401047)(8121501046)(3231475)(944501520)(52105112)(93006095)(93004095)(10201501046)(3002001)(6041310)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(201702281529075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:MWHPR01MB2399; BCL:0; PCL:0; RULEID:; SRVR:MWHPR01MB2399; X-Forefront-PRVS: 08978A8F5C X-Microsoft-Exchange-Diagnostics: 1; MWHPR01MB2399; 23:P3yEcaNgTP4YPCyJilat7rb6dODIu0w/lWtWvGI0wmowB9sb+EKgQYHb3e5CiEIL3oEAUoY6lxJTBQly1TJXeubYQD2BUKx3oUfpc9noi+2cIPQZLreIxGiPyfGGJ0mfTEml6/0LUOzYDjHZ4/SQ8mbuqYRfaJ5i/QSiyXNiw6UY/Q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: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: mit.edu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2018 05:57:00.4798 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74b06fc8-404d-4ada-fd50-08d66a2dc990 X-MS-Exchange-CrossTenant-Id: 64afd9ba-0ecf-4acf-bc36-935f6235ba8b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=64afd9ba-0ecf-4acf-bc36-935f6235ba8b; Ip=[18.9.28.11]; Helo=[outgoing.mit.edu] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR01MB2399 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org The ext4_inline_data_fiemap() function calls fiemap_fill_next_extent() while still holding the xattr semaphore. This is not necessary and it triggers a circular lockdep warning. This is because fiemap_fill_next_extent() could trigger a page fault when it writes into page which triggers a page fault. If that page is mmaped from the inline file in question, this could very well result in a deadlock. This problem can be reproduced using generic/519 with a file system configuration which has the inline_data feature enabled. Signed-off-by: Theodore Ts'o Cc: stable@kernel.org --- fs/ext4/inline.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index 27373d88b5f0..56f6e1782d5f 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -1890,12 +1890,12 @@ int ext4_inline_data_fiemap(struct inode *inode, physical += (char *)ext4_raw_inode(&iloc) - iloc.bh->b_data; physical += offsetof(struct ext4_inode, i_block); - if (physical) - error = fiemap_fill_next_extent(fieinfo, start, physical, - inline_len, flags); brelse(iloc.bh); out: up_read(&EXT4_I(inode)->xattr_sem); + if (physical) + error = fiemap_fill_next_extent(fieinfo, start, physical, + inline_len, flags); return (error < 0 ? error : 0); }