Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp574984iog; Mon, 13 Jun 2022 08:25:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBBxVEf36PQpjBU50eLyz1Hlnm1BguHUzvZQHYncvB8lYn6f8NaAC44+hpxLfvxt6GvInJ X-Received: by 2002:a65:57c2:0:b0:3fd:876d:3c86 with SMTP id q2-20020a6557c2000000b003fd876d3c86mr137316pgr.31.1655133908420; Mon, 13 Jun 2022 08:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655133908; cv=none; d=google.com; s=arc-20160816; b=iVh4aqKyb3cAgwoCyiqvbbUQUJP3wkarsqgcnQK9ExDEyBeuvKFZ7ZiIAWOM3zm3F7 I2fa5CdNcMiJNr5strMW35H4n3fwa33I78wvRuC9iHJn+kC6Tk5stiJjPq1pQWm3bIzo id1U04Cf2tlpFOsiCZWMLSJRhAIb6R4vQ+S2iokAs7K9fmm/FMhqg/d7ox2DLjRablWe dxWmQ1gdg0LJjUJYJMSPgmhM+lj11KF070R94HXEncdysaK8fvv9Tw5evaJAXvITUN1O 8mfVGdCQz121qDhnJQGGlsajLnzfQHv+U3si3cL5sZfKZ5iLeM9bSAf7uvoa6OfKvhoG /clg== 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=OFXULQV7evoUyBVQ7/xKEzjNMNd1H4wFdt7cUGMU6f4=; b=Ic6JWG7pmC15h73YbsiqgltG8ZWwDPVwxZz4rV9FGaMCjz2for1ZILcLsbxy2o3CSo NNc2ijNCJQPQkE9yhnUZYnLGqM2nk45wNubdTeN6sDNbzRBRAgrFpRkuWtShqbl6j8E/ AoEby8HBW2X4QQkfXIiPy0S0Ie7OANXql57P73paY5/aSxY8XYJTomlk7C83ngS1kzku AuBH9hU+tfXXVrMRsjZEqYCPfLTUKU9Hu37BH8qgjrtwzCSKV6VYLVf4YWsEdP5uPPxD olShHbs1KOhuZPfsMKNHbZvPp0bHAsix6Jl4VomYWOJjAf+eluoFb/q1OPxgwSLaeUz+ LXvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jS4uBQ8E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19-20020a170902e9d300b0015ec0b44cd1si9979348plk.199.2022.06.13.08.24.53; Mon, 13 Jun 2022 08:25:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jS4uBQ8E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353990AbiFML0u (ORCPT + 99 others); Mon, 13 Jun 2022 07:26:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353782AbiFMLT5 (ORCPT ); Mon, 13 Jun 2022 07:19:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B60D628E18; Mon, 13 Jun 2022 03:41:41 -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 4FE3E611E1; Mon, 13 Jun 2022 10:41:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6283EC34114; Mon, 13 Jun 2022 10:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116900; bh=5DDNupAR/7627w53+2dEufecBqxANPwMnBhE612l/5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jS4uBQ8EqkDBHPwKCYRspK1uFN2u0jitD6zSZV7IaEyQN4sxC/ofFC6bq2y+ePqxn BBCahidA0V6yXIiVnHFojxqz9dZqi3tAT08b0ybOkG3uG7trtdjqXEFBbJgpcyQqJN +InKAyadtTz6/8JKXF2RYRtgnf7tXiWoTQOurkUM= 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.4 214/411] f2fs: fix fallocate to use file_modified to update permissions consistently Date: Mon, 13 Jun 2022 12:08:07 +0200 Message-Id: <20220613094935.070435180@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 @@ -1608,6 +1608,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;