Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp436140rwb; Thu, 22 Sep 2022 21:38:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4HXz2EprqRnj7BDwHGKeOoa2vdYOH8Cdorw4e8+jik3m5CPOrWMWvXe+qd0cgPrDLji92T X-Received: by 2002:a05:6402:34d5:b0:451:335c:2f1e with SMTP id w21-20020a05640234d500b00451335c2f1emr6464823edc.160.1663907901634; Thu, 22 Sep 2022 21:38:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663907901; cv=none; d=google.com; s=arc-20160816; b=hAExFuwM9XyH/FqIaOdA3QEiokhyq/DPZa2nfXTaMON54zoPc37yWhZDCj8bsfg8wG q3EBmcITcKVWSG8VSLQB6RT91xhVBplvM35C1S2famCjLdpsExjvVJBi5v22pqQUnSc+ VgINOYCDYsUfrh9TAvM5DjJUWqkFgWoUCSgm+9/UzgiWcWkFOoQ9E6gPO9UGC54wg7lm DONT32zov4xkSX5GtPIK5ea7tRu0sEX1GwrNOXP/ZP3V9nycyRLaDdAozNAb/JKoufvd 4iMb4C8xo3xj0yLmToQSmGI0Ll0NERoTOTCcZNYg2go1HywOV5GxXgJkLobDK/YtMZHP J7aQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=NvML268GrcLlTz05bKqCf3izZwFlMlSTzWBocY+1msI=; b=YeukBDPscLQGcF0U5brfI/XAkpvT2vUfxoBqKYGjS1NXg+MwZM6qag1zH2leml7Vds 2LH3erlqthdcLjZMIAg2btoKTU6bry4TiWbgPpJXs5M+Sra9WJpXc0hA/AmQ6S+MaIxQ A3lvI6jJJtyuwTdhYoHDZ2+sg0wwDI1+XlSBHV+H3wOKY4ACm6oHwR8Fwc4T5V6dMi+Q RCofIoKEKoQvmIPoRnG7pmegWSkRkT+NoNbaWjNyg8OWktV8iZvUe6X/dyd4oCsSnbAI 7u4wpYCQIhW4xU8NUoMIUNFwll9RfUtg4WAuUNjqKHTQD1lVUhPK6g2TqtmVf7aHbAEP Pu6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa13-20020a170907868d00b0077ec350b0fbsi7051439ejc.272.2022.09.22.21.37.56; Thu, 22 Sep 2022 21:38:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229639AbiIWEf2 (ORCPT + 99 others); Fri, 23 Sep 2022 00:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229624AbiIWEf1 (ORCPT ); Fri, 23 Sep 2022 00:35:27 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A12ED1181C4; Thu, 22 Sep 2022 21:35:26 -0700 (PDT) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MYfNg4KXszlXT7; Fri, 23 Sep 2022 12:31:15 +0800 (CST) Received: from kwepemm600015.china.huawei.com (7.193.23.52) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 23 Sep 2022 12:35:25 +0800 Received: from huawei.com (10.175.101.6) by kwepemm600015.china.huawei.com (7.193.23.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 23 Sep 2022 12:35:24 +0800 From: ChenXiaoSong To: , CC: , , , , Subject: [PATCH v2 1/2] NFS: make sure open context mode have FMODE_EXEC when file open for exec Date: Fri, 23 Sep 2022 13:36:04 +0800 Message-ID: <20220923053605.2723395-2-chenxiaosong2@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220923053605.2723395-1-chenxiaosong2@huawei.com> References: <20220923053605.2723395-1-chenxiaosong2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600015.china.huawei.com (7.193.23.52) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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-nfs@vger.kernel.org Because file f_mode never have FMODE_EXEC, open context mode won't get FMODE_EXEC from file f_mode. Open context mode only care about FMODE_READ/ FMODE_WRITE/FMODE_EXEC, and all info about open context mode can be convert from file f_flags, so convert file f_flags to open context mode by flags_to_mode(). Signed-off-by: ChenXiaoSong --- fs/nfs/inode.c | 3 ++- fs/nfs/nfs4file.c | 12 ++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index bea7c005119c..bafa808823db 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1173,7 +1173,8 @@ int nfs_open(struct inode *inode, struct file *filp) { struct nfs_open_context *ctx; - ctx = alloc_nfs_open_context(file_dentry(filp), filp->f_mode, filp); + ctx = alloc_nfs_open_context(file_dentry(filp), + flags_to_mode(filp->f_flags), filp); if (IS_ERR(ctx)) return PTR_ERR(ctx); nfs_file_set_open_context(filp, ctx); diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 9eb181287879..2563ed8580f3 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -32,7 +32,6 @@ nfs4_file_open(struct inode *inode, struct file *filp) struct dentry *parent = NULL; struct inode *dir; unsigned openflags = filp->f_flags; - fmode_t f_mode; struct iattr attr; int err; @@ -51,17 +50,14 @@ nfs4_file_open(struct inode *inode, struct file *filp) if (err) return err; - f_mode = filp->f_mode; - if ((openflags & O_ACCMODE) == 3) - f_mode |= flags_to_mode(openflags); - /* We can't create new files here */ openflags &= ~(O_CREAT|O_EXCL); parent = dget_parent(dentry); dir = d_inode(parent); - ctx = alloc_nfs_open_context(file_dentry(filp), f_mode, filp); + ctx = alloc_nfs_open_context(file_dentry(filp), + flags_to_mode(openflags), filp); err = PTR_ERR(ctx); if (IS_ERR(ctx)) goto out; @@ -366,8 +362,8 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt, goto out_free_name; } - ctx = alloc_nfs_open_context(filep->f_path.dentry, filep->f_mode, - filep); + ctx = alloc_nfs_open_context(filep->f_path.dentry, + flags_to_mode(filep->f_flags), filep); if (IS_ERR(ctx)) { res = ERR_CAST(ctx); goto out_filep; -- 2.31.1