From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17F0F196C92; Thu, 6 Jun 2024 14:08:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717682913; cv=none; b=V3qbcY01OCTKn1oRaWDdMMnUzSKjKYXi349J9s3xRCyjeaQ6M4mWh3B4dsOEuBpznRwhKaaJvgLAWp6MKSyUHybg6mVDSTxlv/57lf3uuZprum2SZFBguewS28IDWC6cCmwe/2JNWrJgpze+KKvIu97ox1AA1svr/H9h1gJQ5pc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717682913; c=relaxed/simple; bh=2eT3ay4QzGefTSFfOEjxY+Lnz2qrpT1uugox50yRdaQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JlO26CVVBBuxxaPqSTF5T2t4iYdL+oFK0RYchl+mkV3osgbUITsVLxkiI8coNQtI2wI/Y0hunzvpVl5wiIf9YX79AYP2OsmfohbbMjvAowmUw4LSo4qTNGthva4I4+Hj5Envrfen/rHRwNMCwPORysD0EIt+dWrflCqh0G+ulc0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KxsSnXNG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="KxsSnXNG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E85DCC32781; Thu, 6 Jun 2024 14:08:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1717682913; bh=2eT3ay4QzGefTSFfOEjxY+Lnz2qrpT1uugox50yRdaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KxsSnXNGPG6/9n27C2SxdVC+PMbrZvKvQtPvWUZ7aIdp/V89mjP5HM9mI0IkNdIaa lQu3Pw836nDOoI+ilYZywRB8C/876WZ5RjE7YsqXueu9bK+FWwpyZOgPeI2eryAUmF mBqEcgKf1BsQeHSZvg1JIgRLwQ/+bY4EgagjaolI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 6.9 042/374] f2fs: fix to relocate check condition in f2fs_fallocate() Date: Thu, 6 Jun 2024 16:00:21 +0200 Message-ID: <20240606131653.226265694@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240606131651.683718371@linuxfoundation.org> References: <20240606131651.683718371@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chao Yu [ Upstream commit 278a6253a673611dbc8ab72a3b34b151a8e75822 ] compress and pinfile flag should be checked after inode lock held to avoid race condition, fix it. Fixes: 4c8ff7095bef ("f2fs: support data compression") Fixes: 5fed0be8583f ("f2fs: do not allow partial truncation on pinned file") Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/file.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 3eed9f167fc91..357367e2cb337 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1820,15 +1820,6 @@ static long f2fs_fallocate(struct file *file, int mode, (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE))) return -EOPNOTSUPP; - /* - * Pinned file should not support partial truncation since the block - * can be used by applications. - */ - if ((f2fs_compressed_file(inode) || f2fs_is_pinned_file(inode)) && - (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE | - FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE))) - return -EOPNOTSUPP; - if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE)) @@ -1836,6 +1827,17 @@ static long f2fs_fallocate(struct file *file, int mode, inode_lock(inode); + /* + * Pinned file should not support partial truncation since the block + * can be used by applications. + */ + if ((f2fs_compressed_file(inode) || f2fs_is_pinned_file(inode)) && + (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE | + FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE))) { + ret = -EOPNOTSUPP; + goto out; + } + ret = file_modified(file); if (ret) goto out; -- 2.43.0