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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5A5FC43334 for ; Tue, 7 Jun 2022 20:03:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358394AbiFGUDw (ORCPT ); Tue, 7 Jun 2022 16:03:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353938AbiFGTFH (ORCPT ); Tue, 7 Jun 2022 15:05:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4F8A18FA68; Tue, 7 Jun 2022 11:05:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BD2B6617C4; Tue, 7 Jun 2022 18:05:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0CCBC385A5; Tue, 7 Jun 2022 18:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654625123; bh=IXz8843a3WoKElcC7WcUXD0dVEzUGyIl2tYK9O8MHjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IXY5Wc2iJwCdW2uZaTFgRB2WZLgB5TN3NtkMDi7pPHnatSuBplRlbWchdldX7qHcF uBDopAunmDE+Y+3vNt1A9FY/Kq9AWVxMymj4XwC5uvT7yy1uKhSyCI5X2Kon0vCZX+ yG1NpqmtMfJ40fBmtY3RHPP8Ollz8wiQhaBcku3M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Chao Yu , Jaegeuk Kim Subject: [PATCH 5.15 523/667] f2fs: fix fallocate to use file_modified to update permissions consistently Date: Tue, 7 Jun 2022 19:03:08 +0200 Message-Id: <20220607164950.389539572@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164934.766888869@linuxfoundation.org> References: <20220607164934.766888869@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Yu commit 958ed92922028ec67f504dcdc72bfdfd0f43936a upstream. This patch tries to fix permission consistency issue as all other mainline filesystems. Since the initial introduction of (posix) fallocate back at the turn of the century, it has been possible to use this syscall to change the user-visible contents of files. This can happen by extending the file size during a preallocation, or through any of the newer modes (punch, zero, collapse, insert range). Because the call can be used to change file contents, we should treat it like we do any other modification to a file -- update the mtime, and drop set[ug]id privileges/capabilities. The VFS function file_modified() does all this for us if pass it a locked inode, so let's make fallocate drop permissions correctly. Cc: stable@kernel.org Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/file.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1768,6 +1768,10 @@ static long f2fs_fallocate(struct file * inode_lock(inode); + ret = file_modified(file); + if (ret) + goto out; + if (mode & FALLOC_FL_PUNCH_HOLE) { if (offset >= inode->i_size) goto out;