Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3312765imu; Sun, 11 Nov 2018 12:09:03 -0800 (PST) X-Google-Smtp-Source: AJdET5fAV9ibIOfZzSyTqqptHlerp7LS2iiy1PSoymJq24Wkk+uPAunNiS5VOOv4zIvYhkF/8ewd X-Received: by 2002:a17:902:5a4:: with SMTP id f33-v6mr16891093plf.324.1541966943429; Sun, 11 Nov 2018 12:09:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966943; cv=none; d=google.com; s=arc-20160816; b=E6Rr0VQsjV26T30jisbK1w9OX3frFTzJLjHHqoWWWb6toafGLHtoH6S/FoHqYi5Pdz /Mj4gBk0d3nI2mpyTQzxWL9lq6bbTKWqlg0bYLCcU8QArs67HlDoHc0w1AdRdMI953eh VgBaFoHmucMmccXiFvPqSrHYqtpS0FQUYHr54/9VFi4DeKxs6SIWt2XWrphCgkjWTRG0 RtWyItBBL3cYOmtwDNWVs6+ViT3dcsKrM4X7BMw3HDOAjBK+9hax4/G5s1fbMssp8x8U dm16JXUuZ/Mo5CG/Z8WfmbqzWjUR33Buus7lPl7NaD7ljgAkPgf4X+j9A3rIEjK7Q3uA 2Xeg== 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=P/lvWc1H/N2bPkBpnwbn4J8ulQ5Mp+puF1oPjf2OJwY=; b=0VrPSyw4wvTILAKGKelx5oVN88gyRm5gT8kfvvr4k3H/rGRGJz4hTLU0mRXlYctuOD qykPxyYvY3pUZXxCJJ/Xv6FkkkfrVYSkjC3rC6xD2+wuUNIiVo8YsLtNgdcBlJyhhpeH ZxQoXwA2T1q2ywSsFscHSvE2hHgresuZVTL0lWCLZdDBeTuxB46EfLrOnte0I7Ro/9xs RVlpeTa64o2PvxAtXfUan0yaig2wkyTqsRcLTTpbGuKg1SPOeD0XUneuJFbQhAZhQeWU wd/MOFDLBIGxhtr6Q/Od8QlwZSQbSVm3ngIFMrH5Ndf3s+o/61BoShIZWLkQIOWlcgyN qbwg== 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 w65-v6si17158159pfd.55.2018.11.11.12.08.48; Sun, 11 Nov 2018 12:09:03 -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; 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 S1731452AbeKLF4q (ORCPT + 99 others); Mon, 12 Nov 2018 00:56:46 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:52102 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbeKLF4q (ORCPT ); Mon, 12 Nov 2018 00:56:46 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvtB-0000tu-RD; Sun, 11 Nov 2018 19:59:21 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsO-0001Pi-PJ; Sun, 11 Nov 2018 19:58:32 +0000 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, "Jan Kara" , "Theodore Ts'o" , "Amir Goldstein" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 046/366] ext4: do not update s_last_mounted of a frozen fs In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 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.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Amir Goldstein commit db6516a5e7ddb6dc72d167b920f2f272596ea22d upstream. If fs is frozen after mount and before the first file open, the update of s_last_mounted bypasses freeze protection and prints out a WARNING splat: $ mount /vdf $ fsfreeze -f /vdf $ cat /vdf/foo [ 31.578555] WARNING: CPU: 1 PID: 1415 at fs/ext4/ext4_jbd2.c:53 ext4_journal_check_start+0x48/0x82 [ 31.614016] Call Trace: [ 31.614997] __ext4_journal_start_sb+0xe4/0x1a4 [ 31.616771] ? ext4_file_open+0xb6/0x189 [ 31.618094] ext4_file_open+0xb6/0x189 If fs is frozen, skip s_last_mounted update. [backport hint: to apply to stable tree, need to apply also patches vfs: add the sb_start_intwrite_trylock() helper ext4: factor out helper ext4_sample_last_mounted()] Fixes: bc0b0d6d69ee ("ext4: update the s_last_mounted field in the superblock") Signed-off-by: Amir Goldstein Signed-off-by: Theodore Ts'o Reviewed-by: Jan Kara [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- fs/ext4/file.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -220,7 +220,7 @@ static int ext4_sample_last_mounted(stru if (likely(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED)) return 0; - if (sb->s_flags & MS_RDONLY) + if (sb->s_flags & MS_RDONLY || !sb_start_intwrite_trylock(sb)) return 0; sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED; @@ -234,21 +234,25 @@ static int ext4_sample_last_mounted(stru path.mnt = mnt; path.dentry = mnt->mnt_root; cp = d_path(&path, buf, sizeof(buf)); + err = 0; if (IS_ERR(cp)) - return 0; + goto out; handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1); + err = PTR_ERR(handle); if (IS_ERR(handle)) - return PTR_ERR(handle); + goto out; BUFFER_TRACE(sbi->s_sbh, "get_write_access"); err = ext4_journal_get_write_access(handle, sbi->s_sbh); if (err) - goto out; + goto out_journal; strlcpy(sbi->s_es->s_last_mounted, cp, sizeof(sbi->s_es->s_last_mounted)); ext4_handle_dirty_super(handle, sb); -out: +out_journal: ext4_journal_stop(handle); +out: + sb_end_intwrite(sb); return err; }