From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6590C56202 for ; Mon, 26 Oct 2020 23:52:43 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A5B421D7B; Mon, 26 Oct 2020 23:52:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="JyEfu7pa"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="WdM+T1TB"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="PjYsvaPn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A5B421D7B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1kXCI6-0000UD-Ux; Mon, 26 Oct 2020 23:52:42 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXCHz-0000SQ-6m for linux-f2fs-devel@lists.sourceforge.net; Mon, 26 Oct 2020 23:52:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=FBLBpkrVukvaNtJKG125I5c5jOslzKyeUnjubh3fWjA=; b=JyEfu7pabFedc/SGGRa23cCydA lePdBeOiDbLYG5whCJS+ANaWCndVJsuJUbrsIceXQkGacrh99ltwvdfpW4weROn+IFWdenzoSdk9t x9bw765gh3fwmXBZAgqOdVFF2X0AbSwZ1vRJVVLymhAGiQ/XqPVcNYsFcGNV5mge2/Lc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=FBLBpkrVukvaNtJKG125I5c5jOslzKyeUnjubh3fWjA=; b=WdM+T1TB97R86V2Ro0iuP2BqBz tIpc8rsSBQiE5c81/0v7Rmg4B3k7Nav+NKdeNvkwquwANs7DEBryDfAmt4et7fdlWCqdkHXLHMy4k FqsNLmanLKwte3vSpYoyAgRi4az+RIt8qLtaYyTGAlruTwfcHIwavwdL63W6oXSoBqbs=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kXCHq-00Eu9V-5T for linux-f2fs-devel@lists.sourceforge.net; Mon, 26 Oct 2020 23:52:35 +0000 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1DF8A21D7B; Mon, 26 Oct 2020 23:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756340; bh=9kk0a7HyUydSRWlqF76ldu7TV33KYy8Chili1/Lt0RM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PjYsvaPneNMSsE9g/0gx6l8aPJDMLFARm4sOKqeCgh1aEIdaYC3lVibY7Z/OX4ZYf HFlOFnL2ggpgCHN1j6G5UJpSin9HZuXbDJK53plwLBsqJPUMweUhD0PAtKf+08SnUI G1tkiMXAOFtXmtD1X0lAXeRgp6biG1WX4xIUvwks= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Mon, 26 Oct 2020 19:50:05 -0400 Message-Id: <20201026235205.1023962-13-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235205.1023962-1-sashal@kernel.org> References: <20201026235205.1023962-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-Headers-End: 1kXCHq-00Eu9V-5T Subject: [f2fs-dev] [PATCH AUTOSEL 5.8 013/132] f2fs: compress: fix to disallow enabling compress on non-empty file X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Chao Yu [ Upstream commit 519a5a2f37b850f4eb86674a10d143088670a390 ] Compressed inode and normal inode has different layout, so we should disallow enabling compress on non-empty file to avoid race condition during inode .i_addr array parsing and updating. Signed-off-by: Chao Yu [Jaegeuk Kim: Fix missing condition] Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 3268f8dd59bba..408a99fdaaea2 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1837,6 +1837,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) if (iflags & F2FS_COMPR_FL) { if (!f2fs_may_compress(inode)) return -EINVAL; + if (S_ISREG(inode->i_mode) && inode->i_size) + return -EINVAL; set_compress_context(inode); } -- 2.25.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel