Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5181887imu; Tue, 15 Jan 2019 12:42:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN47ULit0YKn3vgcYbxMurDB7WcyXmJNbDwehArDTwk1HJYM41JC4EXfhsz/OeYWW6RtAZf/ X-Received: by 2002:a65:6148:: with SMTP id o8mr5460581pgv.451.1547584927825; Tue, 15 Jan 2019 12:42:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547584927; cv=none; d=google.com; s=arc-20160816; b=is8myrwdqr3JMrdTaF9chkwdv2z4FqsFMl7AR+EJM1FJfKyB/BjFMAyH8usieiTOIh ivO75Zp/+jLzmZvVt8SB/TPC+jUDqDLOVlesPdAq/bPpZjROUGyrUx0CqCFdHHINDvBa ZbDXjZiLoe7g7glnxS024y2izXZ/lNZ20XvX8BxR214CWmfQ069/rKd7gIM3kRLOdgez 2tUti0aHKEjWsnO43JRUHQDhGs9r+H/FUqy6kbH20HxM/c0EdgpqcUm3Jl8soCiljMsF jKDysWFrMtN34RVT35+tFz64y2cS38alDu8Xiy29TSEBJC6fHiV3K0FGbqOLzb/gwexm uJsQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jKc39lrBPZM6RSewTxsjyFFPolq+kV7iwojK9fi9VaU=; b=coDEY+ZeeZgkcT5ZFHHLGL+C2YHbZcw7YXBn+6LvupE1YZDITg/hvFJzLgoLKIWJ58 /+K+ztvXIVz6fG3DraAuYEyKuujVtlfT9qvnYKu22IfbPi8C6QWuFGMG78KsHgzjOXBf JXcYkwPoCCcVo+UhEXNfWR4sy8roi0XZrMLEnI8XTpt7ETCFAkiwpECeDnMm5fqWIlEk zFskbA2FKO5G80g/o08rxHhcnfTrGxaEuEIOsWijte6xSyfFglcmM1WqNorEgtBT//yc y9WVf8zwQ4CWcghf35gudY0DNQe6CQup4FDszbRe9x9/RqWvvYaHgZN6rzlXVhPIad7/ W4BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WoatfrP4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h129si4501927pfb.253.2019.01.15.12.41.49; Tue, 15 Jan 2019 12:42:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=WoatfrP4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732645AbfAOQkl (ORCPT + 99 others); Tue, 15 Jan 2019 11:40:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:57044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730407AbfAOQkf (ORCPT ); Tue, 15 Jan 2019 11:40:35 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C79DA20675; Tue, 15 Jan 2019 16:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547570435; bh=c9VZdVHbLKhF1KAa4kwYWVnakYQ4ls2YzGBwSnDVs2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WoatfrP4gV5tEVi0oB2/ze27P9/c/8cqfzOgBpabHxalJkESNg5gyPBPtPxw3joRr dKyV3fObB5ZuzHDNK0GARGVfFgM6eeS7vjdEO5wjjiy3H8KjpMphxMUvq2uAavkBB2 nWOoBHjK1xeg0KEnCpMM5culbeaBu8Wqm/YtW3Wc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso , stable@kernel.org Subject: [PATCH 4.14 22/27] ext4: fix a potential fiemap/page fault deadlock w/ inline_data Date: Tue, 15 Jan 2019 17:36:11 +0100 Message-Id: <20190115154902.717175122@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115154901.189747728@linuxfoundation.org> References: <20190115154901.189747728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Theodore Ts'o commit 2b08b1f12cd664dc7d5c84ead9ff25ae97ad5491 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- fs/ext4/inline.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -1864,12 +1864,12 @@ int ext4_inline_data_fiemap(struct 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); }