Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1496584

[PATCH 4.4 27/93] ceph: fix race during filling readdir cache

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 4.4 27/93] ceph: fix race during filling readdir cache
Date 2016-10-06 12:40 +0200
Message-ID <spefL-7nn-13@gated-at.bofh.it> (permalink)
References <spcGZ-6dt-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

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

From: Yan, Zheng <zyan@redhat.com>

commit af5e5eb574776cdf1b756a27cc437bff257e22fe upstream.

Readdir cache uses page cache to save dentry pointers. When adding
dentry pointers to middle of a page, we need to make sure the page
already exists. Otherwise the beginning part of the page will be
invalid pointers.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
Cc: Nikolay Borisov <kernel@kyup.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/ceph/inode.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1358,15 +1358,20 @@ static int fill_readdir_cache(struct ino
 
 	if (!ctl->page || pgoff != page_index(ctl->page)) {
 		ceph_readdir_cache_release(ctl);
-		ctl->page  = grab_cache_page(&dir->i_data, pgoff);
+		if (idx == 0)
+			ctl->page = grab_cache_page(&dir->i_data, pgoff);
+		else
+			ctl->page = find_lock_page(&dir->i_data, pgoff);
 		if (!ctl->page) {
 			ctl->index = -1;
-			return -ENOMEM;
+			return idx == 0 ? -ENOMEM : 0;
 		}
 		/* reading/filling the cache are serialized by
 		 * i_mutex, no need to use page lock */
 		unlock_page(ctl->page);
 		ctl->dentries = kmap(ctl->page);
+		if (idx == 0)
+			memset(ctl->dentries, 0, PAGE_CACHE_SIZE);
 	}
 
 	if (req->r_dir_release_cnt == atomic64_read(&ci->i_release_count) &&

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4.4 00/93] 4.4.24-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:00 +0200
  [PATCH 4.4 68/93] brcmsmac: Initialize power in brcms_c_stf_ss_algo_channel_get() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:00 +0200
  [PATCH 4.4 02/93] mtd: nand: davinci: Reinitialize the HW ECC engine in 4bit hwctl Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:00 +0200
  [PATCH 4.4 63/93] pNFS/files: Fix layoutcommit after a commit to DS Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:00 +0200
  [PATCH 4.4 16/93] pinctrl: uniphier: fix .pin_dbg_show() callback Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:00 +0200
  [PATCH 4.4 92/93] ALSA: hda - Fix headset mic detection problem for several Dell laptops Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 75/93] IB/ipoib: Fix memory corruption in ipoib cm mode connect flow Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 72/93] kernel/fork: fix CLONE_CHILD_CLEARTID regression in nscd Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 46/93] ARM: sa1100: clear reset status prior to reboot Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 84/93] dm log writes: fix bug with too large bios Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 88/93] USB: serial: cp210x: Add ID for a Juniper console Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 77/93] IB/ipoib: Dont allow MC joins during light MC flush Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 83/93] clk: xgene: Add missing parenthesis when clearing divider value Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 82/93] aio: mark AIO pseudo-fs noexec Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 37/93] printk: fix parsing of "brl=" option Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 89/93] Revert "usbtmc: convert to devm_kzalloc" Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 41/93] regulator: qcom_spmi: Update mvs1/mvs2 switches on pm8941 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 78/93] IB/mlx4: Fix incorrect MC join state bit-masking on SR-IOV Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 45/93] ARM: sa1100: fix 3.6864MHz clock Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 93/93] ALSA: hda - Add the top speaker pin config for HP Spectre x360 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 85/93] USB: serial: cp210x: fix hardware flow-control disable Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 42/93] regulator: qcom_smd: Fix voltage ranges for pm8x41 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 76/93] IB/core: Fix use after free in send_leave function Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 90/93] ALSA: hda - Adding one more ALC255 pin definition for headset problem Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 44/93] ARM: sa1100: register clocks early Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 79/93] IB/mlx4: Fix code indentation in QP1 MAD flow Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 87/93] Staging: fbtft: Fix bug in fbtft-core Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 91/93] ACPICA: acpi_get_sleep_type_data: Reduce warnings Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 80/93] IB/mlx4: Use correct subnet-prefix in QP1 mads under SR-IOV Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 65/93] ASoC: Intel: Skylake: Fix error return code in skl_probe() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 86/93] usb: misc: legousbtower: Fix NULL pointer deference Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:10 +0200
  [PATCH 4.4 55/93] [media] em28xx-i2c: rt_mutex_trylock() returns zero on failure Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:20 +0200
  [PATCH 4.4 56/93] [media] gspca: avoid unused variable warnings Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:20 +0200
  [PATCH 4.4 01/93] cpuset: handle race between CPU hotplug and cpuset_hotplug_work Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:30 +0200
  [PATCH 4.4 21/93] ipvs: fix bind to link-local mcast IPv6 address in backup Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 11:30 +0200
  [PATCH 4.4 27/93] ceph: fix race during filling readdir cache Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-06 12:40 +0200
  Re: [PATCH 4.4 00/93] 4.4.24-stable review Guenter Roeck <linux@roeck-us.net> - 2016-10-06 20:50 +0200
  Re: [PATCH 4.4 00/93] 4.4.24-stable review Shuah Khan <shuah.kh@samsung.com> - 2016-10-06 22:00 +0200
  Re: [PATCH 4.4 00/93] 4.4.24-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-07 15:10 +0200
    Re: [PATCH 4.4 00/93] 4.4.24-stable review Kevin Hilman <khilman@baylibre.com> - 2016-10-08 12:00 +0200

csiph-web