Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp888746yba; Thu, 18 Apr 2019 11:15:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxoje8AF1m+cJzA7HnOr8+G1aiHHHf/HjZicWRamYhwzUeH8ZUegw5iuG5j7bcOkYWv3mh3 X-Received: by 2002:a17:902:bb90:: with SMTP id m16mr7791767pls.340.1555611308531; Thu, 18 Apr 2019 11:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611308; cv=none; d=google.com; s=arc-20160816; b=M3lrS1BFJNoSqw+vDM0ljwq0dEJKf5k8lyPZp3GVxf1GgSO3C+JAVeMlybQLhupfIR b+f+s/kW6cHU/M9uN+Z649d1ombsfLkmVYlKq+LD9bNd1nIb4VsEmOmEYYR8NOcAq0vI oEKAzCcSmXBMtUdXasPXhRBFKQUzG4l3EHmgMW7vlWlsqOWodClVQGF6TMAcWqZjbS4q SpiS32jIWXlW/wu1E9C87itavFZcW/dwLAa22AAgDFSTREa7HiZgGjz+WyTDr3e/nYQs H7sgWCH9vqusWdsgwDVYZxRHquOMt+AzwE/gABzVm27TOtzB2ODOBQzvwSiI8DqHsGmy Y5Uw== 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=Hu7wBtkUaaM/rXKJB5EmjpyWb4OitCBSDHDCG3nKBFw=; b=YR2ZG6h/tv7SmEMMZZKRTdAzsTOHF9sELzQhi4fhc0db7x6rU9n/IRlv4vFHu+5bkZ iqoouYJtjue8wbk3G9Gipv4XuqwD0ijg7wNOKzl0lCqu7gE8gZFaGGjQfYqlqOxC8rlu UG3KzVuKqHVKH23INfH6Fr0uTGhTmLfafaLKtdPMk9uxWaAAV4kc5uFboI8SBuGDdE+M 6Yq6zdXQeHeoLMCkkaGnQcN6GPHpJ6Hyp1tDk9O7CL+0t5EhoSMRCLqOaiymj2yyaudr D6pxObmuc2XHfw63r3pZ8p1QQ+5H0SzqxK3++GGQcTUIvjNKumUy2sERiMaDJcCnEJnM OIkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SjYVDSEN; 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 v10si2712462plo.439.2019.04.18.11.14.53; Thu, 18 Apr 2019 11:15:08 -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=SjYVDSEN; 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 S2404427AbfDRSNV (ORCPT + 99 others); Thu, 18 Apr 2019 14:13:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:45990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404405AbfDRSNR (ORCPT ); Thu, 18 Apr 2019 14:13:17 -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 367AD21872; Thu, 18 Apr 2019 18:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555611196; bh=2B7WEXNUQiFETZRN6SGBNeT5lvglUMdmZJmO+wzNi28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SjYVDSENfN/QLPejL3b/rlvOxE0AMF0KQoPkdbcv8QG4G8CK0vaO9wocxK9JTVDAR fgl0QEfj6ACYPyzaqWaSYkIw7jx7VVRugLctk2J4Fp2mcAHLbOSkoKxXyxhkeXFwcI Dqd70yn2tStVMtQV4BSHxXu0WpIUFuKDiZfckAqQ= 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 5.0 67/93] ext4: prohibit fstrim in norecovery mode Date: Thu, 18 Apr 2019 19:57:45 +0200 Message-Id: <20190418160444.080203740@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160436.781762249@linuxfoundation.org> References: <20190418160436.781762249@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 2e76fb55d94a..5f24fdc140ad 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -999,6 +999,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