Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp884926yba; Thu, 18 Apr 2019 11:11:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0DGMGiIcdWOis2POMvbmy160UCkAU7ySBY5SbhSEofqS1oaJI7CeEdDI58uufB+WSUn9t X-Received: by 2002:a17:902:a607:: with SMTP id u7mr98475272plq.66.1555611066663; Thu, 18 Apr 2019 11:11:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611066; cv=none; d=google.com; s=arc-20160816; b=VTQZ1HvGGUHeqztsmVc8XMdjGXtnUB0lU7Vv6dNCPGweq7Crm+rGXbo9blK3hG7I31 AzstJQK+RsqZfLuxBmr077k9v6+lAV+2pVqvhoYeKFLhuDgYhPjHRg0r4k7orRkZiTPz NkPjkS5uFBl6rqtmPor1LA/czL4FQu8EQz21u39KKfT3pRCnQvDCxZSwyY5xAluXaH9H 5w+EHHaNjWNPf9NHoO4UKN61s8QOZCBsThDiJ9Syym7avaz9Er8c/hZnFNLhIKTt6XYJ x9UaTM1MomzoDXAXN62ly4zeUbJ2WDt2XFfVdSVwbznMb7eb8d4BnHP3odKz3Qo14aIy p9NA== 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=uXHPiQgvn2pLtWvhbNnzSxtpiBzJjYPs0J8FEHaeMCU=; b=Zo/V84B1KOwSP2xYNwg6ySE9Aus1BdQUoSZI3Ov5AcQE619y05i4CMovn/EL39Fn8G Fv+0AnLh6mPbmAPd3URhg/73jRMkXAFXPQj/MmxIzemnZCLsroMU0NazG40BgIvkRZQA fXdB12C3gwSeQsYX1Q3TJP//kyqOOc9y2dinmyXuzxoA0497LYC1r6erynvFbFvKoa07 BqNiz/k7VrC2rhrjVH+DZb7gJim5l6sRrLeWK0ONQK8p+EWMqh6YMdIPpqfuJSnVzB9d E81kLHuKfeK1uBSYej0wbLkQ/OTs2WaM1EkIIfjtPbEcrlf2335GhcBdT6QHPynHVwdX v/Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Eyud7ek/"; 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 y29si2579012pgk.120.2019.04.18.11.10.51; Thu, 18 Apr 2019 11:11:06 -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; dkim=pass header.i=@kernel.org header.s=default header.b="Eyud7ek/"; 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 S2391861AbfDRSJO (ORCPT + 99 others); Thu, 18 Apr 2019 14:09:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:40758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391843AbfDRSJN (ORCPT ); Thu, 18 Apr 2019 14:09:13 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 5D090217FA; Thu, 18 Apr 2019 18:09:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610952; bh=u4xp/qqJH0eCnjJdaUcNW4Vm0bROl9Bp1YqEi6hleOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eyud7ek/2FKDEC8O9Pa9uiz3CRGQM+WfHsZ4NqrGT6SPw6wfn0rpTeCYOK6wyvxAU 8Q65zk+ELCGtpSB0TJfvNYV7M9wOSkJN/bEBffZia9Gu35jjPxGhByFZaOSvnd06mi hnzn/wMg+RU6fmmqNvLo6flFC+1QzC0vDzOmq2GA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Theodore Tso , Sasha Levin Subject: [PATCH 4.9 27/50] ext4: prohibit fstrim in norecovery mode Date: Thu, 18 Apr 2019 19:57:38 +0200 Message-Id: <20190418160426.126375911@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160422.455656724@linuxfoundation.org> References: <20190418160422.455656724@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 18915b5873f07e5030e6fb108a050fa7c71c59fb ] The ext4 fstrim implementation uses the block bitmaps to find free space that can be discarded. If we haven't replayed the journal, the bitmaps will be stale and we absolutely *cannot* use stale metadata to zap the underlying storage. Signed-off-by: Darrick J. Wong Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/ioctl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 2880e017cd0a..2ce73287b53c 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -749,6 +749,13 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) if (!blk_queue_discard(q)) return -EOPNOTSUPP; + /* + * We haven't replayed the journal, so we cannot use our + * block-bitmap-guided storage zapping commands. + */ + if (test_opt(sb, NOLOAD) && ext4_has_feature_journal(sb)) + return -EROFS; + if (copy_from_user(&range, (struct fstrim_range __user *)arg, sizeof(range))) return -EFAULT; -- 2.19.1