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 8C75AC32789 for ; Mon, 22 Aug 2022 09:13:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234237AbiHVJNG (ORCPT ); Mon, 22 Aug 2022 05:13:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234306AbiHVJMi (ORCPT ); Mon, 22 Aug 2022 05:12:38 -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 A51A92F646 for ; Mon, 22 Aug 2022 02:12:06 -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 00BFA60EA6 for ; Mon, 22 Aug 2022 09:12:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2C6FC433C1; Mon, 22 Aug 2022 09:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661159525; bh=fqdNpl7VIaIw8Q07SBqI54sKtQJQawHUUWCxvrU3qHI=; h=Subject:To:Cc:From:Date:From; b=lwWYDBOkpC2orNlq06kSTWV82EZaO/dIQuy6ApKuFqeNuO4HkUgrKpbfRknr5/pW/ bslnl9VRn5kxIqgCEgXDHF3bhUSl25CqPUg0k3lep9aTozo0myuKwrVaNhbFl5DChu VmFEaPmpqzUwsCm0Wej7bjCTL2K/DtI+8TX4TUp8= Subject: FAILED: patch "[PATCH] ceph: don't truncate file in atomic_open" failed to apply to 5.4-stable tree To: sehuww@mail.scut.edu.cn, idryomov@gmail.com, xiubli@redhat.com Cc: From: Date: Mon, 22 Aug 2022 11:11:19 +0200 Message-ID: <166115947977185@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.4-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 7cb9994754f8a36ae9e5ec4597c5c4c2d6c03832 Mon Sep 17 00:00:00 2001 From: Hu Weiwen Date: Fri, 1 Jul 2022 10:52:27 +0800 Subject: [PATCH] ceph: don't truncate file in atomic_open Clear O_TRUNC from the flags sent in the MDS create request. `atomic_open' is called before permission check. We should not do any modification to the file here. The caller will do the truncation afterward. Fixes: 124e68e74099 ("ceph: file operations") Signed-off-by: Hu Weiwen Reviewed-by: Xiubo Li Signed-off-by: Ilya Dryomov diff --git a/fs/ceph/file.c b/fs/ceph/file.c index cd025ff25bf0..b4e978420802 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -749,6 +749,11 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, err = ceph_wait_on_conflict_unlink(dentry); if (err) return err; + /* + * Do not truncate the file, since atomic_open is called before the + * permission check. The caller will do the truncation afterward. + */ + flags &= ~O_TRUNC; if (flags & O_CREAT) { if (ceph_quota_is_max_files_exceeded(dir)) @@ -824,9 +829,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, } set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); - err = ceph_mdsc_do_request(mdsc, - (flags & (O_CREAT|O_TRUNC)) ? dir : NULL, - req); + err = ceph_mdsc_do_request(mdsc, (flags & O_CREAT) ? dir : NULL, req); if (err == -ENOENT) { dentry = ceph_handle_snapdir(req, dentry); if (IS_ERR(dentry)) {