Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1317561yba; Tue, 2 Apr 2019 06:46:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvaKWU74LRwuY3jR5G+9n08YWvxZVheC69LDr2Q2WB2YvJL19Zc4o4erPpU4GWURxvNqrD X-Received: by 2002:a63:f448:: with SMTP id p8mr21887959pgk.50.1554212790891; Tue, 02 Apr 2019 06:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554212790; cv=none; d=google.com; s=arc-20160816; b=0fGYGfEdUkjCal3ysAaFP4wUFK0R+sd5G0eV4e9HqG/xELoytYDuUA/q0lO9AsEn5I 51VGdY9pCl2NHP6np5DWQYNVhZQxkdR8rNsIPnVzRGkCwZ9nbV1Z/C6ygpqfHfdayxcr AxgcTer0oaoPH9azVcZrekgOd++0hHH6ARU5J4mWneO15+3/t+JsIrhvN18m9RjlWfQI 7dtiYU3xXFi4cg9nY3feEdailELb0nf3MwhMfuc3xSt88Jr0s3MjW3JSgrwk1uQZJ0oj YQApUmxOjmmWCTT1vfVnY9c8xpPpBvMb0herYZaAc3bN18mmuxSFUN9fJ/rKUuz+M3uS a7zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=NtasKwgq5zPyPe4AHUz1vuibzgKqFmXsJaZMFasTfU0=; b=k8PStK0nLjLN4h6a6zTV8l2YGbFlsnA7TDpWZasDDREWaWYydpS2D9ERTv5bYK7/Cx a3amMivhDC6weJNtauoix/AFrqpAg6Xee7m2Tdejj8OukvE7wG/gJz+RnX4HOW3YGJCf Vgx6ta9Bt2R6D8nVci0P1gkGra4HZmXNLOYOkFyxxfZbQG2NQbeyiSl0mVq+Ir0r0HWg hYRKLtC33iiWv2VDntb8gwcIwny5LDYFzxgt2e0fj+buHo34pG9PpuFfqUWTK2Q3yxTG tvEJ3/cE50X4Oxk9D1AV09my+a7Mf5IiCKqqdG/N9lSGMYTulU5yiwfLgDMgTcdpa6x9 icwA== ARC-Authentication-Results: i=1; mx.google.com; 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 h69si11531226pfc.120.2019.04.02.06.46.15; Tue, 02 Apr 2019 06:46:30 -0700 (PDT) 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; 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 S1732108AbfDBNpI (ORCPT + 99 others); Tue, 2 Apr 2019 09:45:08 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43396 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731466AbfDBNkI (ORCPT ); Tue, 2 Apr 2019 09:40:08 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJe0-0002oc-J3; Tue, 02 Apr 2019 14:40:04 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdx-0004wz-NJ; Tue, 02 Apr 2019 14:40:01 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Theodore Ts'o" Date: Tue, 02 Apr 2019 14:38:28 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 81/99] ext4: fix a potential fiemap/page fault deadlock w/ inline_data In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.65-rc1 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 Signed-off-by: Ben Hutchings --- fs/ext4/inline.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -1846,12 +1846,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); }