linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Trond Myklebust <trond.myklebust@primarydata.com>
Subject: [PATCH 3.14 072/122] NFSv4.1: nfs41_clear_delegation_stateid shouldnt trust NFS_DELEGATED_STATE
Date: Wed, 19 Nov 2014 12:52:02 -0800	[thread overview]
Message-ID: <20141119205211.196416565@linuxfoundation.org> (raw)
In-Reply-To: <20141119205208.812884198@linuxfoundation.org>

3.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Trond Myklebust <trond.myklebust@primarydata.com>

commit 0c116cadd94b16b30b1dd90d38b2784d9b39b01a upstream.

This patch removes the assumption made previously, that we only need to
check the delegation stateid when it matches the stateid on a cached
open.

If we believe that we hold a delegation for this file, then we must assume
that its stateid may have been revoked or expired too. If we don't test it
then our state recovery process may end up caching open/lock state in a
situation where it should not.
We therefore rename the function nfs41_clear_delegation_stateid as
nfs41_check_delegation_stateid, and change it to always run through the
delegation stateid test and recovery process as outlined in RFC5661.

http://lkml.kernel.org/r/CAN-5tyHwG=Cn2Q9KsHWadewjpTTy_K26ee+UnSvHvG4192p-Xw@mail.gmail.com
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/nfs/nfs4proc.c |   42 +++++++++++++++++-------------------------
 1 file changed, 17 insertions(+), 25 deletions(-)

--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2057,45 +2057,37 @@ static int nfs40_open_expired(struct nfs
 }
 
 #if defined(CONFIG_NFS_V4_1)
-static void nfs41_clear_delegation_stateid(struct nfs4_state *state)
+static void nfs41_check_delegation_stateid(struct nfs4_state *state)
 {
 	struct nfs_server *server = NFS_SERVER(state->inode);
-	nfs4_stateid *stateid = &state->stateid;
+	nfs4_stateid stateid;
 	struct nfs_delegation *delegation;
-	struct rpc_cred *cred = NULL;
-	int status = -NFS4ERR_BAD_STATEID;
-
-	/* If a state reset has been done, test_stateid is unneeded */
-	if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0)
-		return;
+	struct rpc_cred *cred;
+	int status;
 
 	/* Get the delegation credential for use by test/free_stateid */
 	rcu_read_lock();
 	delegation = rcu_dereference(NFS_I(state->inode)->delegation);
-	if (delegation != NULL &&
-	    nfs4_stateid_match(&delegation->stateid, stateid)) {
-		cred = get_rpccred(delegation->cred);
-		rcu_read_unlock();
-		status = nfs41_test_stateid(server, stateid, cred);
-		trace_nfs4_test_delegation_stateid(state, NULL, status);
-	} else
+	if (delegation == NULL) {
 		rcu_read_unlock();
+		return;
+	}
+
+	nfs4_stateid_copy(&stateid, &delegation->stateid);
+	cred = get_rpccred(delegation->cred);
+	rcu_read_unlock();
+	status = nfs41_test_stateid(server, &stateid, cred);
+	trace_nfs4_test_delegation_stateid(state, NULL, status);
 
 	if (status != NFS_OK) {
 		/* Free the stateid unless the server explicitly
 		 * informs us the stateid is unrecognized. */
 		if (status != -NFS4ERR_BAD_STATEID)
-			nfs41_free_stateid(server, stateid, cred);
-		nfs_remove_bad_delegation(state->inode);
-
-		write_seqlock(&state->seqlock);
-		nfs4_stateid_copy(&state->stateid, &state->open_stateid);
-		write_sequnlock(&state->seqlock);
-		clear_bit(NFS_DELEGATED_STATE, &state->flags);
+			nfs41_free_stateid(server, &stateid, cred);
+		nfs_finish_clear_delegation_stateid(state);
 	}
 
-	if (cred != NULL)
-		put_rpccred(cred);
+	put_rpccred(cred);
 }
 
 /**
@@ -2139,7 +2131,7 @@ static int nfs41_open_expired(struct nfs
 {
 	int status;
 
-	nfs41_clear_delegation_stateid(state);
+	nfs41_check_delegation_stateid(state);
 	status = nfs41_check_open_stateid(state);
 	if (status != NFS_OK)
 		status = nfs4_open_expired(sp, state);



  parent reply	other threads:[~2014-11-19 21:48 UTC|newest]

Thread overview: 123+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-19 20:50 [PATCH 3.14 000/122] 3.14.25-stable review Greg Kroah-Hartman
2014-11-19 20:50 ` [PATCH 3.14 001/122] Revert "drivers/net: Disable UFO through virtio" Greg Kroah-Hartman
2014-11-19 20:50 ` [PATCH 3.14 002/122] ip6_tunnel: Use ip6_tnl_dev_init as the ndo_init function Greg Kroah-Hartman
2014-11-19 20:50 ` [PATCH 3.14 003/122] vti6: Use vti6_dev_init " Greg Kroah-Hartman
2014-11-19 20:50 ` [PATCH 3.14 004/122] sit: Use ipip6_tunnel_init " Greg Kroah-Hartman
2014-11-19 20:50 ` [PATCH 3.14 005/122] gre6: Move the setting of dev->iflink into the ndo_init functions Greg Kroah-Hartman
2014-11-19 20:50 ` [PATCH 3.14 006/122] vxlan: Do not reuse sockets for a different address family Greg Kroah-Hartman
2014-11-19 20:50 ` [PATCH 3.14 007/122] net: sctp: fix NULL pointer dereference in af->from_addr_param on malformed packet Greg Kroah-Hartman
2014-11-19 20:50 ` [PATCH 3.14 008/122] net: sctp: fix memory leak in auth key management Greg Kroah-Hartman
2014-11-19 20:50 ` [PATCH 3.14 009/122] smsc911x: power-up phydev before doing a software reset Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 010/122] sunvdc: add cdrom and v1.1 protocol support Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 011/122] sunvdc: compute vdisk geometry from capacity Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 012/122] sunvdc: limit each sg segment to a page Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 013/122] vio: fix reuse of vio_dring slot Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 014/122] sunvdc: dont call VD_OP_GET_VTOC Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 015/122] sparc64: Fix crashes in schizo_pcierr_intr_other() Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 016/122] sparc64: Do irq_{enter,exit}() around generic_smp_call_function*() Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 017/122] sparc32: Implement xchg and atomic_xchg using ATOMIC_HASH locks Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 018/122] zram: avoid kunmap_atomic() of a NULL pointer Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 019/122] crypto: caam - fix missing dma unmap on error path Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 020/122] crypto: caam - remove duplicated sg copy functions Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 021/122] hwrng: pseries - port to new read API and fix stack corruption Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 022/122] tun: Fix csum_start with VLAN acceleration Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 023/122] x86, x32, audit: Fix x32s AUDIT_ARCH wrt audit Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 024/122] audit: correct AUDIT_GET_FEATURE return message type Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 025/122] audit: AUDIT_FEATURE_CHANGE message format missing delimiting space Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 026/122] audit: keep inode pinned Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 027/122] ahci: Add Device IDs for Intel Sunrise Point PCH Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 028/122] ahci: disable MSI instead of NCQ on Samsung pci-e SSDs on macbooks Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 029/122] ALSA: usb-audio: Fix memory leak in FTU quirk Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 030/122] xtensa: re-wire umount syscall to sys_oldumount Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 031/122] libceph: do not crash on large auth tickets Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 032/122] macvtap: Fix csum_start when VLAN tags are present Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 033/122] mac80211_hwsim: release driver when ieee80211_register_hw fails Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 034/122] mac80211: properly flush delayed scan work on interface removal Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 035/122] mac80211: use secondary channel offset IE also beacons during CSA Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 036/122] mac80211: schedule the actual switch of the station before CSA count 0 Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 037/122] mac80211: fix use-after-free in defragmentation Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 038/122] drm/radeon: set correct CE ram size for CIK Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 039/122] drm/radeon: make sure mode init is complete in bandwidth_update Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 040/122] drm/radeon: add missing crtc unlock when setting up the MC Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 042/122] ARM: 8191/1: decompressor: ensure I-side picks up relocated code Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 043/122] pinctrl: dra: dt-bindings: Fix output pull up/down Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 044/122] dm thin: grab a virtual cell before looking up the mapping Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 046/122] firewire: cdev: prevent kernel stack leaking into ioctl arguments Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 047/122] ata: sata_rcar: Disable DIPM mode for r8a7790 ES1 Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 048/122] nfs: fix pnfs direct write memory leak Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 049/122] Correct the race condition in aarch64_insn_patch_text_sync() Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 050/122] scsi: only re-lock door after EH on devices that were reset Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 051/122] parisc: Use compat layer for msgctl, shmat, shmctl and semtimedop syscalls Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 052/122] block: Fix computation of merged request priority Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 053/122] dm bufio: change __GFP_IO to __GFP_FS in shrinker callbacks Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 054/122] dm btree: fix a recursion depth bug in btree walking code Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 055/122] dm raid: ensure superblocks size matches devices logical block size Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 056/122] Input: synaptics - add min/max quirk for Lenovo T440s Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 060/122] power: charger-manager: Fix accessing invalidated power supply after fuel gauge unbind Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 061/122] power: charger-manager: Fix accessing invalidated power supply after charger unbind Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 062/122] power: bq2415x_charger: Properly handle ENODEV from power_supply_get_by_phandle Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 063/122] power: bq2415x_charger: Fix memory leak on DTS parsing error Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 064/122] x86, microcode, AMD: Fix early ucode loading on 32-bit Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 065/122] x86, microcode, AMD: Fix ucode patch stashing " Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 066/122] x86, kaslr: Prevent .bss from overlaping initrd Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 067/122] md: Always set RECOVERY_NEEDED when clearing RECOVERY_FROZEN Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 068/122] NFSv4: Ensure that we remove NFSv4.0 delegations when state has expired Greg Kroah-Hartman
2014-11-19 20:51 ` [PATCH 3.14 069/122] NFS: Dont try to reclaim delegation open state if recovery failed Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 070/122] nfs: Fix use of uninitialized variable in nfs_getattr() Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 071/122] NFSv4: Fix races between nfs_remove_bad_delegation() and delegation return Greg Kroah-Hartman
2014-11-19 20:52 ` Greg Kroah-Hartman [this message]
2014-11-19 20:52 ` [PATCH 3.14 073/122] media: ttusb-dec: buffer overflow in ioctl Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 074/122] memory-hotplug: Remove "weak" from memory_block_size_bytes() declaration Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 075/122] vmcore: Remove "weak" from function declarations Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 076/122] kgdb: Remove "weak" from kgdb_arch_pc() declaration Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 077/122] clocksource: Remove "weak" from clocksource_default_clock() declaration Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 078/122] IB/core: Clear AH attr variable to prevent garbage data Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 079/122] ipc: always handle a new value of auto_msgmni Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 080/122] netfilter: ipset: off by one in ip_set_nfnl_get_byindex() Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 081/122] netfilter: nf_log: account for size of NLMSG_DONE attribute Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 082/122] netfilter: nfnetlink_log: fix maximum packet length logged to userspace Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 083/122] netfilter: nf_log: release skbuff on nlmsg put failure Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 084/122] netfilter: nft_compat: fix wrong target lookup in nft_target_select_ops() Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 085/122] netfilter: xt_bpf: add mising opaque struct sk_filter definition Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 086/122] ARM: probes: fix instruction fetch order with <asm/opcodes.h> Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 087/122] GFS2: Fix address space from page function Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 088/122] rcu: Make callers awaken grace-period kthread Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 089/122] rcu: Use rcu_gp_kthread_wake() to wake up grace period kthreads Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 091/122] perf: Handle compat ioctl Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 092/122] perf/x86/intel: Use proper dTLB-load-misses event on IvyBridge Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 093/122] KVM: x86: Dont report guest userspace emulation error to userspace Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 094/122] net: sctp: fix remote memory pressure from excessive queueing Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 095/122] net: sctp: fix panic on duplicate ASCONF chunks Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 096/122] net: sctp: fix skb_over_panic when receiving malformed " Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 097/122] iwlwifi: configure the LTR Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 098/122] regmap: fix kernel hang on regmap_bulk_write with zero val_count Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 099/122] lib: radix-tree: add radix_tree_delete_item() Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 100/122] mm: shmem: save one radix tree lookup when truncating swapped pages Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 101/122] mm: filemap: move radix tree hole searching here Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 102/122] mm + fs: prepare for non-page entries in page cache radix trees Greg Kroah-Hartman
2014-11-20 15:49   ` Johannes Weiner
2014-11-20 16:20     ` Greg Kroah-Hartman
2014-11-20 16:21     ` Mel Gorman
2014-11-20 20:39       ` Johannes Weiner
2014-11-19 20:52 ` [PATCH 3.14 103/122] mm: madvise: fix MADV_WILLNEED on shmem swapouts Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 104/122] mm: remove read_cache_page_async() Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 105/122] callers of iov_copy_from_user_atomic() dont need pagecache_disable() Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 106/122] mm/readahead.c: inline ra_submit Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 107/122] mm/compaction: clean up unused code lines Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 108/122] mm/compaction: cleanup isolate_freepages() Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 109/122] mm, migration: add destination page freeing callback Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 110/122] mm, compaction: return failed migration target pages back to freelist Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 111/122] mm, compaction: add per-zone migration pfn cache for async compaction Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 112/122] mm, compaction: embed migration mode in compact_control Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 113/122] mm, compaction: terminate async compaction when rescheduling Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 114/122] mm/compaction: do not count migratepages when unnecessary Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 115/122] mm/compaction: avoid rescanning pageblocks in isolate_freepages Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 116/122] mm, compaction: properly signal and act upon lock and need_sched() contention Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 117/122] x86/mm: In the PTE swapout page reclaim case clear the accessed bit instead of flushing the TLB Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 118/122] mm: fix direct reclaim writeback regression Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 119/122] fs/superblock: unregister sb shrinker before ->kill_sb() Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 120/122] fs/superblock: avoid locking counting inodes and dentries before reclaiming them Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 121/122] mm: vmscan: use proportional scanning during direct reclaim and full scan at DEF_PRIORITY Greg Kroah-Hartman
2014-11-19 20:52 ` [PATCH 3.14 122/122] mm/page_alloc: prevent MIGRATE_RESERVE pages from being misplaced Greg Kroah-Hartman
2014-11-20  5:32 ` [PATCH 3.14 000/122] 3.14.25-stable review Guenter Roeck
2014-11-21  1:37 ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141119205211.196416565@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=trond.myklebust@primarydata.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).