Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2219851iof; Tue, 7 Jun 2022 23:35:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyR0S/hgR3pHZ0wU1dsbksHM41ZQ+q6SyuRKfPAQxkZsgXQVzUf2r2TCQGwf7Z+w/fatSvi X-Received: by 2002:a17:90b:33c5:b0:1e3:e57a:8998 with SMTP id lk5-20020a17090b33c500b001e3e57a8998mr35907623pjb.54.1654670159740; Tue, 07 Jun 2022 23:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654670159; cv=none; d=google.com; s=arc-20160816; b=qBamQEVMwoJ36WC7LQpSUjFPSfJSHidt0yyEjgj22HVhAjdAR+Kh08klNri0AnuHO+ ADDcAt7jNXvVzl75ZaZJ06V0bsoO+mGVp6oTv1Tu8FEvWE/4c6j+p4Y4nf+sWIDe6g/s CGXmJNMasnOmXPyrnrFLJlnruJD0RpHL/dnULzO+VoqHgXkOzDxMh+nye/jJtOXFCwmF T2h39WwK+bAWwiBflOPZespNlUrODz4/y3NwOiXRnLWR9j9aYrBOsPjJgXB8fIR58oFe JSwoGi6pjjac62XaF7QG1CieR6P7UOp4Z0eBtjsFVXyEsCv3Rz9G2t4zjCCyt7hCFOzI zefg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ia7hsJsI9VCpeHfaxNnnjeqpaIrFHUlI5nr4ONOIiQ0=; b=wS9F0uMRqA+LPzJsgy0mDECk3ZgzPFxC10flaiepbPr+uwWWABrZ/V7pFvNKHXq+V+ pFToEW2BtVLDoXlCMuP1eu3nwPsAA0ljh5haB8gYLznOcVI1RGnbVk64cYyKHA3mOMjR 2IXYOv8gwAV8/3frU0vAh4Uil2srgu/hr7xTQfcxuMBGTUXeCb/mg+iSMBNJU9CnDbTB WiH3CCXs3sTLmflZAskZ7YhrVC8rHbhEgU1TeTluz1j2lNI1t1xLz3E4iaHuOPUUNMC3 I5wV2lkVSy6X1ncbwlgkyXZTDvtKjmORsgFhDqD5aZfc1NMUnCauiCRs2pTFYKhkf5v3 M+nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tCyVpjk1; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 82-20020a630555000000b003fc6682b1ebsi2658232pgf.223.2022.06.07.23.35.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:35:59 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tCyVpjk1; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 44EEC9A985; Tue, 7 Jun 2022 23:00:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241496AbiFHCWN (ORCPT + 99 others); Tue, 7 Jun 2022 22:22:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444768AbiFHCLS (ORCPT ); Tue, 7 Jun 2022 22:11:18 -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 C23DB254EC4; Tue, 7 Jun 2022 12:18:31 -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 040536192F; Tue, 7 Jun 2022 19:18:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12A17C341C0; Tue, 7 Jun 2022 19:18:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629510; bh=FjpVwRVNYYlAGn7k/OHLaxc52wPen+gS9TwWMFYhhXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tCyVpjk1fjuXHH9A6PXLj8ci8B/JapyI6SHik/kMIH9uxTn5hJ7EJ4f6j1GPBZ84U 9ieQuiZuN7HuAILSblgBVMbd9CcdQR/IvO2RENcUtp1yHc1cYFH/S//3WNXb8Yxzlv Kj/7KxSTlcuzOd3ot4/Ye5wP2FlvY933PyFz/SJ4= 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.18 715/879] f2fs: fix fallocate to use file_modified to update permissions consistently Date: Tue, 7 Jun 2022 19:03:53 +0200 Message-Id: <20220607165023.608176335@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 @@ -1774,6 +1774,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;