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, Jeff Layton <jlayton@redhat.com>,
	Weston Andros Adamson <dros@netapp.com>,
	Bruce Fields <bfields@fieldses.org>,
	Trond Myklebust <Trond.Myklebust@netapp.com>
Subject: [PATCH 3.12 097/116] SUNRPC: Avoid deep recursion in rpc_release_client
Date: Tue, 26 Nov 2013 16:57:50 -0800	[thread overview]
Message-ID: <20131127005743.606914626@linuxfoundation.org> (raw)
In-Reply-To: <20131127005736.915454872@linuxfoundation.org>

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

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

From: Trond Myklebust <Trond.Myklebust@netapp.com>

commit d07ba8422f1e58be94cc98a1f475946dc1b89f1b upstream.

In cases where an rpc client has a parent hierarchy, then
rpc_free_client may end up calling rpc_release_client() on the
parent, thus recursing back into rpc_free_client. If the hierarchy
is deep enough, then we can get into situations where the stack
simply overflows.

The fix is to have rpc_release_client() loop so that it can take
care of the parent rpc client hierarchy without needing to
recurse.

Reported-by: Jeff Layton <jlayton@redhat.com>
Reported-by: Weston Andros Adamson <dros@netapp.com>
Reported-by: Bruce Fields <bfields@fieldses.org>
Link: http://lkml.kernel.org/r/2C73011F-0939-434C-9E4D-13A1EB1403D7@netapp.com
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/sunrpc/clnt.c |   29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -656,14 +656,16 @@ EXPORT_SYMBOL_GPL(rpc_shutdown_client);
 /*
  * Free an RPC client
  */
-static void
+static struct rpc_clnt *
 rpc_free_client(struct rpc_clnt *clnt)
 {
+	struct rpc_clnt *parent = NULL;
+
 	dprintk_rcu("RPC:       destroying %s client for %s\n",
 			clnt->cl_program->name,
 			rcu_dereference(clnt->cl_xprt)->servername);
 	if (clnt->cl_parent != clnt)
-		rpc_release_client(clnt->cl_parent);
+		parent = clnt->cl_parent;
 	rpc_clnt_remove_pipedir(clnt);
 	rpc_unregister_client(clnt);
 	rpc_free_iostats(clnt->cl_metrics);
@@ -672,18 +674,17 @@ rpc_free_client(struct rpc_clnt *clnt)
 	rpciod_down();
 	rpc_free_clid(clnt);
 	kfree(clnt);
+	return parent;
 }
 
 /*
  * Free an RPC client
  */
-static void
+static struct rpc_clnt *
 rpc_free_auth(struct rpc_clnt *clnt)
 {
-	if (clnt->cl_auth == NULL) {
-		rpc_free_client(clnt);
-		return;
-	}
+	if (clnt->cl_auth == NULL)
+		return rpc_free_client(clnt);
 
 	/*
 	 * Note: RPCSEC_GSS may need to send NULL RPC calls in order to
@@ -694,7 +695,8 @@ rpc_free_auth(struct rpc_clnt *clnt)
 	rpcauth_release(clnt->cl_auth);
 	clnt->cl_auth = NULL;
 	if (atomic_dec_and_test(&clnt->cl_count))
-		rpc_free_client(clnt);
+		return rpc_free_client(clnt);
+	return NULL;
 }
 
 /*
@@ -705,10 +707,13 @@ rpc_release_client(struct rpc_clnt *clnt
 {
 	dprintk("RPC:       rpc_release_client(%p)\n", clnt);
 
-	if (list_empty(&clnt->cl_tasks))
-		wake_up(&destroy_wait);
-	if (atomic_dec_and_test(&clnt->cl_count))
-		rpc_free_auth(clnt);
+	do {
+		if (list_empty(&clnt->cl_tasks))
+			wake_up(&destroy_wait);
+		if (!atomic_dec_and_test(&clnt->cl_count))
+			break;
+		clnt = rpc_free_auth(clnt);
+	} while (clnt != NULL);
 }
 EXPORT_SYMBOL_GPL(rpc_release_client);
 



  parent reply	other threads:[~2013-11-27  1:00 UTC|newest]

Thread overview: 120+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-27  0:56 [PATCH 3.12 000/116] 3.12.2-stable review Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 001/116] prepend_path() needs to reinitialize dentry/vfsmount/mnt on restarts Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 002/116] libertas: potential oops in debugfs Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 003/116] aacraid: prevent invalid pointer dereference Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 004/116] xfs: be more forgiving of a v4 secondary sb w/ junk in v5 fields Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 005/116] USB: mos7840: fix tiocmget error handling Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 006/116] can: kvaser_usb: fix usb endpoints detection Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 007/116] Btrfs: relocate csums properly with prealloc extents Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 008/116] crypto: ansi_cprng - Fix off by one error in non-block size request Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 009/116] crypto: s390 - Fix aes-cbc IV corruption Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 010/116] can: c_can: Fix RX message handling, handle lost message before EOB Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 011/116] alx: Reset phy speed after resume Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 012/116] ipc,shm: correct error return value in shmctl (SHM_UNLOCK) Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 013/116] ipc,shm: fix shm_file deletion races Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 014/116] drm: shmobile: Add dependency on BACKLIGHT_CLASS_DEVICE Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 015/116] staging: ashmem: Fix ASHMEM_PURGE_ALL_CACHES return value Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 016/116] drm/nvc0-/gr: fix a number of missing explicit array terminators Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 017/116] thinkpad_acpi: Fix build error when CONFIG_SND_MAX_CARDS > 32 Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 018/116] ARM: OMAP2+: hwmod: check for module address space during init Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 019/116] sched, idle: Fix the idle polling state logic Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 020/116] perf/ftrace: Fix paranoid level for enabling function tracer Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 021/116] ACPI / EC: Ensure lock is acquired before accessing ec struct members Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 022/116] ACPI / video: Quirk initial backlight level 0 Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 023/116] ACPI / hotplug: Fix handle_root_bridge_removal() Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 024/116] ACPI / hotplug: Do not execute "insert in progress" _OST Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 025/116] Staging: zram: Fix access of NULL pointer Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 026/116] staging: r8188eu: Set device type to wlan Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 027/116] staging: comedi: avoid memleak for subdevice private Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 028/116] lkdtm: isolate stack corruption test Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 029/116] Drivers: hv: vmbus: Fix a bug in channel rescind code Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 030/116] rt2x00: fix a crash bug in the HT descriptor handling fix Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 031/116] rt2x00: check if device is still available on rt2x00mac_flush() Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 032/116] rt2x00: rt2800lib: fix VGC adjustment for RT5592 Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 033/116] rt2x00: fix HT TX descriptor settings regression Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 034/116] Bluetooth: revert: "Bluetooth: Add missing reset_resume dev_pm_ops" Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 035/116] Revert "ima: policy for RAMFS" Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 036/116] exec/ptrace: fix get_dumpable() incorrect tests Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 037/116] ALSA: 6fire: Fix probe of multiple cards Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 038/116] ALSA: compress: fix drain calls blocking other compress functions Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 039/116] ALSA: compress: fix drain calls blocking other compress functions (v6) Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 040/116] ALSA: pcsp: Fix the order of input device unregistration Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 041/116] ALSA: hda - Apply GPIO setup for MacBooks with CS4208 Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 042/116] ALSA: hda - Apply MacBook fixups for CS4208 correctly Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 043/116] ALSA: msnd: Avoid duplicated driver name Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 044/116] ALSA: hda - Add support of ALC255 codecs Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 045/116] ALSA: hda - Introduce the bitmask for excluding output volume Greg Kroah-Hartman
2013-11-27  0:56 ` [PATCH 3.12 046/116] ALSA: hda - Enable SPDIF for Acer TravelMate 6293 Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 047/116] ALSA: hda - Force buffer alignment for Haswell HDMI controllers Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 048/116] ALSA: hda - Make sure mute LEDs stay on during runtime suspend (Realtek) Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 049/116] ALSA: hda - Add support for CX20952 Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 050/116] ALSA: hda - Add pincfg fixup for ASUS W5A Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 051/116] ALSA: hda - Fix Line Out automute on Realtek multifunction jacks Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 052/116] ALSA: hda - Check keep_eapd_on before inv_eapd Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 053/116] ALSA: hda - Dont turn off EAPD for headphone on Lenovo N100 Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 054/116] ALSA: hda - Dont clear the power state at snd_hda_codec_reset() Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 055/116] ALSA: hda - Fix unbalanced runtime PM notification at resume Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 056/116] ALSA: hda - Fix the headphone jack detection on Sony VAIO TX Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 057/116] ALSA: hda - Add headset quirk for Dell Inspiron 3135 Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 058/116] ALSA: hda - Provide missing pin configs for VAIO with ALC260 Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 059/116] NFSv4.2: Fix a mismatch between Linux labeled NFS and the NFSv4.2 spec Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 060/116] NFSv4: Fix a use-after-free situation in _nfs4_proc_getlk() Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 061/116] NFSv4: fix NULL dereference in open recover Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 062/116] NFSv4: dont fail on missing fattr " Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 063/116] NFSv4: dont reprocess cached open CLAIM_PREVIOUS Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 064/116] NFSv4: Fix state reference counting in _nfs4_opendata_reclaim_to_nfs4_state Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 065/116] nfs: fix inverted test for delegation in nfs4_reclaim_open_state Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 066/116] nfs: fix oops when trying to set SELinux label Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 067/116] NFS: Fix a missing initialisation when reading the " Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 068/116] nfsd: return better errors to exportfs Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 069/116] nfsd4: fix discarded security labels on setattr Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 070/116] nfs: dont retry detect_trunking with RPC_AUTH_UNIX more than once Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 071/116] nfsd: split up nfsd_setattr Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 072/116] nfsd: make sure to balance get/put_write_access Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 073/116] nfsd4: fix xdr decoding of large non-write compounds Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 074/116] x86/apic: Disable I/O APIC before shutdown of the local APIC Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 075/116] x86/microcode/amd: Tone down printk(), dont treat a missing firmware file as an error Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 076/116] KVM: x86: fix emulation of "movzbl %bpl, %eax" Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 077/116] ftrace/x86: skip over the breakpoint for ftrace caller Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 078/116] KVM: IOMMU: hva align mapping page size Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 079/116] arm/arm64: KVM: Fix hyp mappings of vmalloc regions Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 080/116] hwmon: (lm90) Fix max6696 alarm handling Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 081/116] drivers/memstick/core/ms_block.c: fix unreachable state in h_msb_read_page() Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 082/116] block: fix race between request completion and timeout handling Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 083/116] block: fix a probe argument to blk_register_region Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 084/116] block: properly stack underlying max_segment_size to DM device Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 085/116] powerpc/52xx: fix build breakage for MPC5200 LPBFIFO module Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 086/116] powerpc/mpc512x: silence build warning upon disabled DIU Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 087/116] powerpc/vio: use strcpy in modalias_show Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 088/116] powerpc/powernv: Add PE to its own PELTV Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 089/116] powerpc: ppc64 address space capped at 32TB, mmap randomisation disabled Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 090/116] powerpc: Fix __get_user_pages_fast() irq handling Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 091/116] powerpc/signals: Mark VSX not saved with small contexts Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 092/116] powerpc/eeh: Enable PCI_COMMAND_MASTER for PCI bridges Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 093/116] powerpc/pseries: Duplicate dtl entries sometimes sent to userspace Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 094/116] slub: Handle NULL parameter in kmem_cache_flags Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 095/116] SUNRPC: gss_alloc_msg - choose _either_ a v0 message or a v1 message Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 096/116] SUNRPC: Fix a data corruption issue when retransmitting RPC calls Greg Kroah-Hartman
2013-11-27  0:57 ` Greg Kroah-Hartman [this message]
2013-11-27  0:57 ` [PATCH 3.12 098/116] mei: nfc: fix memory leak in error path Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 099/116] usb: Dont enable USB 2.0 Link PM by default Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 100/116] xhci: Enable LPM support only for hardwired or BESL devices Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 101/116] xhci: Set L1 device slot on USB2 LPM enable/disable Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 102/116] usb: Disable USB 2.0 Link PM before device reset Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 103/116] usb: hub: Clear Port Reset Change during init/resume Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 104/116] usb: wusbcore: set the RPIPE wMaxPacketSize value correctly Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 105/116] rt2800usb: slow down TX status polling Greg Kroah-Hartman
2013-11-27  0:57 ` [PATCH 3.12 106/116] usb: musb: cancel work on removal Greg Kroah-Hartman
2013-11-27  0:58 ` [PATCH 3.12 107/116] usb: musb: call musb_start() only once in OTG mode Greg Kroah-Hartman
2013-11-27  0:58 ` [PATCH 3.12 108/116] usb: musb: dsps: move try_idle to start hook Greg Kroah-Hartman
2013-11-27  0:58 ` [PATCH 3.12 109/116] usb: musb: dsps: redo the otg timer Greg Kroah-Hartman
2013-11-27  0:58 ` [PATCH 3.12 110/116] usb: musb: core: properly free host / device structs in err path Greg Kroah-Hartman
2013-11-27  0:58 ` [PATCH 3.12 111/116] s390/time: fix get_tod_clock_ext inline assembly Greg Kroah-Hartman
2013-11-27  0:58 ` [PATCH 3.12 112/116] s390/vtime: correct idle time calculation Greg Kroah-Hartman
2013-11-27  0:58 ` [PATCH 3.12 113/116] configfs: fix race between dentry put and lookup Greg Kroah-Hartman
2013-11-27  0:58 ` [PATCH 3.12 114/116] GFS2: d_splice_alias() cant return error Greg Kroah-Hartman
2013-11-27  0:58 ` [PATCH 3.12 115/116] GFS2: fix dentry leaks Greg Kroah-Hartman
2013-11-27  0:58 ` [PATCH 3.12 116/116] cris: media platform drivers: fix build Greg Kroah-Hartman
2013-11-27  4:10 ` [PATCH 3.12 000/116] 3.12.2-stable review Guenter Roeck
2013-11-27 22:28 ` Shuah Khan
2013-11-28 10:57 ` Satoru Takeuchi

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=20131127005743.606914626@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=Trond.Myklebust@netapp.com \
    --cc=bfields@fieldses.org \
    --cc=dros@netapp.com \
    --cc=jlayton@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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).