Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp584571pxb; Tue, 29 Mar 2022 08:03:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaz5FivzC4uFEq2bohb+sPZtigsqYYWksnRfqC1Q8rMAPg20AjEKj1mzgu8UM8McUtEJNJ X-Received: by 2002:a5e:c00f:0:b0:64c:7199:468e with SMTP id u15-20020a5ec00f000000b0064c7199468emr6438476iol.161.1648566201312; Tue, 29 Mar 2022 08:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648566201; cv=none; d=google.com; s=arc-20160816; b=K74ijBgJIXXU2jxIhtDrvSQg/iu/ASW9Zqz5eYWqWQNpw8v4QIK5wI4wz9XDEw1L2r 9sOUVcnnSi6mEKmFlJEylsN3u4Tf2434pb4XHiNZ2D7ErllxvTow1KkiGhJdEcPt/Zae M0P8vZbu/JyfBrvjPzNquc0nozFFak8eueMP9kw679BJ95m95O2TH6Mtofkx6US/evqc 0atCu7g2UN1OWCoYRU+71JgbZPyaoBfCIzVDCUFuM83wQN5hUQXdeJdOK0cxiR6w5Q47 zhI0dme8SQVGA/PhE+ETxvowETTAq9d8VU9EsgDR1m4jbECI3weJepmbGLA9AdpgOLmj em/g== 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=aTxUJ0CE8lrv1sWUgUCDY6xGW2g7GsRI3fBc8EA6Zfo=; b=077ulF6JRI4PNNAEc/PmRgP4uFeuBgLhCbYjqI9z5mD2vhou/TzO3Ww+4ZVY9JwmHM pWVRkhQrgord3sGh7GNhIbF3G8WpzevHzrIq30Mbr9qZyhFAwqR4xGmW5+hTotzfk4cl 9oUdIYMRNjf0AQ78OBNg2FaLRJSU/v0AWAoR1VCtWYOffRfZrHFvjPNhWn7MPnIfmJqn KxVwNlH9db0/B3DJ5YzYlSMMdBIOPBJ1XtqFLjSRnZTmvm32iDL5CiwvXvo69OA6fIxH xwux7K45xF4+bbpkC8Re3xn5oS3DQpqB1RTitb4VSgOlXbR7IsMXRNmCDn2OCIiYaqQl 7VlA== 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 n18-20020a056e02101200b002c8676d5fb4si13890052ilj.169.2022.03.29.08.02.55; Tue, 29 Mar 2022 08:03: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 S235331AbiC2LTS (ORCPT + 99 others); Tue, 29 Mar 2022 07:19:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232605AbiC2LTR (ORCPT ); Tue, 29 Mar 2022 07:19:17 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1F814D61E; Tue, 29 Mar 2022 04:17:33 -0700 (PDT) Received: from kwepemi100026.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KSRnj32wXzfYml; Tue, 29 Mar 2022 19:15:53 +0800 (CST) Received: from kwepemm600015.china.huawei.com (7.193.23.52) by kwepemi100026.china.huawei.com (7.221.188.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 29 Mar 2022 19:17:31 +0800 Received: from huawei.com (10.175.127.227) 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.2308.21; Tue, 29 Mar 2022 19:17:30 +0800 From: ChenXiaoSong To: , , CC: , , , , , , Subject: [PATCH -next 1/2] Revert "NFSv4: Handle the special Linux file open access mode" Date: Tue, 29 Mar 2022 19:32:07 +0800 Message-ID: <20220329113208.2466000-2-chenxiaosong2@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220329113208.2466000-1-chenxiaosong2@huawei.com> References: <20220329113208.2466000-1-chenxiaosong2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) 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, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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-nfs@vger.kernel.org This reverts commit 44942b4e457beda00981f616402a1a791e8c616e. After secondly opening a file with O_ACCMODE|O_DIRECT flags, nfs4_valid_open_stateid() will dereference NULL nfs4_state when lseek(). Reproducer: 1. mount -t nfs -o vers=4.2 $server_ip:/ /mnt/ 2. fd = open("/mnt/file", O_ACCMODE|O_DIRECT|O_CREAT) 3. close(fd) 4. fd = open("/mnt/file", O_ACCMODE|O_DIRECT) 5. lseek(fd) Reported-by: Lyu Tao Signed-off-by: ChenXiaoSong --- fs/nfs/inode.c | 1 - fs/nfs/nfs4file.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 3351c2de3e08..bb91b228f1e5 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1180,7 +1180,6 @@ int nfs_open(struct inode *inode, struct file *filp) nfs_fscache_open_file(inode, filp); return 0; } -EXPORT_SYMBOL_GPL(nfs_open); /* * This function is called whenever some part of NFS notices that diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index e79ae4cbc395..c178db86a6e8 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -51,7 +51,7 @@ nfs4_file_open(struct inode *inode, struct file *filp) return err; if ((openflags & O_ACCMODE) == 3) - return nfs_open(inode, filp); + openflags--; /* We can't create new files here */ openflags &= ~(O_CREAT|O_EXCL); -- 2.31.1