Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1626207
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4.10 39/69] target: Avoid mappedlun symlink creation during lun shutdown |
| Date | 2017-04-19 16:50 +0200 |
| Message-ID | <txZ5F-4CC-39@gated-at.bofh.it> (permalink) |
| References | <txYVX-4yJ-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Bellinger <nab@linux-iscsi.org>
commit 49cb77e297dc611a1b795cfeb79452b3002bd331 upstream.
This patch closes a race between se_lun deletion during configfs
unlink in target_fabric_port_unlink() -> core_dev_del_lun()
-> core_tpg_remove_lun(), when transport_clear_lun_ref() blocks
waiting for percpu_ref RCU grace period to finish, but a new
NodeACL mappedlun is added before the RCU grace period has
completed.
This can happen in target_fabric_mappedlun_link() because it
only checks for se_lun->lun_se_dev, which is not cleared until
after transport_clear_lun_ref() percpu_ref RCU grace period
finishes.
This bug originally manifested as NULL pointer dereference
OOPsen in target_stat_scsi_att_intr_port_show_attr_dev() on
v4.1.y code, because it dereferences lun->lun_se_dev without
a explicit NULL pointer check.
In post v4.1 code with target-core RCU conversion, the code
in target_stat_scsi_att_intr_port_show_attr_dev() no longer
uses se_lun->lun_se_dev, but the same race still exists.
To address the bug, go ahead and set se_lun>lun_shutdown as
early as possible in core_tpg_remove_lun(), and ensure new
NodeACL mappedlun creation in target_fabric_mappedlun_link()
fails during se_lun shutdown.
Reported-by: James Shen <jcs@datera.io>
Cc: James Shen <jcs@datera.io>
Tested-by: James Shen <jcs@datera.io>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/target/target_core_fabric_configfs.c | 5 +++++
drivers/target/target_core_tpg.c | 4 ++++
include/target/target_core_base.h | 1 +
3 files changed, 10 insertions(+)
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -92,6 +92,11 @@ static int target_fabric_mappedlun_link(
pr_err("Source se_lun->lun_se_dev does not exist\n");
return -EINVAL;
}
+ if (lun->lun_shutdown) {
+ pr_err("Unable to create mappedlun symlink because"
+ " lun->lun_shutdown=true\n");
+ return -EINVAL;
+ }
se_tpg = lun->lun_tpg;
nacl_ci = &lun_acl_ci->ci_parent->ci_group->cg_item;
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -640,6 +640,8 @@ void core_tpg_remove_lun(
*/
struct se_device *dev = rcu_dereference_raw(lun->lun_se_dev);
+ lun->lun_shutdown = true;
+
core_clear_lun_from_tpg(lun, tpg);
/*
* Wait for any active I/O references to percpu se_lun->lun_ref to
@@ -661,6 +663,8 @@ void core_tpg_remove_lun(
}
if (!(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE))
hlist_del_rcu(&lun->link);
+
+ lun->lun_shutdown = false;
mutex_unlock(&tpg->tpg_lun_mutex);
percpu_ref_exit(&lun->lun_ref);
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -705,6 +705,7 @@ struct se_lun {
u64 unpacked_lun;
#define SE_LUN_LINK_MAGIC 0xffff7771
u32 lun_link_magic;
+ bool lun_shutdown;
bool lun_access_ro;
u32 lun_index;
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 4.10 00/69] 4.10.12-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:40 +0200
[PATCH 4.10 18/69] CIFS: store results of cifs_reopen_file to avoid infinite wait Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:40 +0200
[PATCH 4.10 20/69] perf annotate s390: Fix perf annotate error -95 (4.10 regression) Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:40 +0200
[PATCH 4.10 48/69] cpufreq: Bring CPUs up even if cpufreq_online() failed Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:40 +0200
[PATCH 4.10 35/69] scsi: sr: Sanity check returned mode data Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:40 +0200
[PATCH 4.10 15/69] drm/etnaviv: fix missing unlock on error in etnaviv_gpu_submit() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:40 +0200
[PATCH 4.10 08/69] zsmalloc: expand class bit Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:40 +0200
[PATCH 4.10 11/69] drm/nouveau/mmu/nv4a: use nv04 mmu rather than the nv44 one Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:40 +0200
[PATCH 4.10 26/69] x86/vdso: Ensure vdso32_enabled gets set to valid values only Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:40 +0200
[PATCH 4.10 42/69] make skb_copy_datagram_msg() et.al. preserve ->msg_iter on error Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:50 +0200
[PATCH 4.10 67/69] mm: Tighten x86 /dev/mem with zeroing reads Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:50 +0200
[PATCH 4.10 39/69] target: Avoid mappedlun symlink creation during lun shutdown Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:50 +0200
[PATCH 4.10 52/69] char: lack of bool string made CONFIG_DEVPORT always on Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:50 +0200
[PATCH 4.10 34/69] iscsi-target: Drop work-around for legacy GlobalSAN initiator Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:50 +0200
[PATCH 4.10 43/69] libnvdimm: fix blk free space accounting Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:50 +0200
[PATCH 4.10 40/69] xen, fbfront: fix connecting to backend Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:50 +0200
[PATCH 4.10 69/69] virtio-console: avoid DMA from stack Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:50 +0200
[PATCH 4.10 65/69] ACPI / EC: Use busy polling mode when GPE is not enabled Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:50 +0200
[PATCH 4.10 66/69] rtc: tegra: Implement clock handling Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:50 +0200
[PATCH 4.10 41/69] [iov_iter] new privimitive: iov_iter_revert() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:50 +0200
[PATCH 4.10 37/69] scsi: qla2xxx: Add fix to read correct register value for ISP82xx. Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 16:50 +0200
[PATCH 4.10 56/69] crypto: algif_aead - Fix bogus request dereference in completion function Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:20 +0200
[PATCH 4.10 54/69] zram: do not use copy_page with non-page aligned address Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:20 +0200
[PATCH 4.10 58/69] crypto: ahash - Fix EINPROGRESS notification callback Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:20 +0200
[PATCH 4.10 61/69] [media] dvb-usb-v2: avoid use-after-free Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:20 +0200
[PATCH 4.10 36/69] scsi: sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:20 +0200
[PATCH 4.10 59/69] crypto: lrw - Fix use-after-free on EINPROGRESS Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:20 +0200
[PATCH 4.10 38/69] scsi: sd: Fix capacity calculation with 32-bit sector_t Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:20 +0200
[PATCH 4.10 57/69] crypto: xts - Fix use-after-free on EINPROGRESS Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:20 +0200
[PATCH 4.10 64/69] x86/xen: Fix APIC id mismatch warning on Intel Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:20 +0200
[PATCH 4.10 62/69] ASoC: Intel: select DW_DMAC_CORE since its mandatory Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:20 +0200
[PATCH 4.10 55/69] ftrace: Fix function pid filter on instances Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 06/69] thp: fix MADV_DONTNEED vs. MADV_FREE race Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 23/69] x86/signals: Fix lower/upper bound reporting in compat siginfo Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 45/69] libnvdimm: band aid btt vs clear poison locking Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 07/69] thp: fix MADV_DONTNEED vs clear soft dirty race Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 50/69] ftrace: Fix removing of second function probe Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 49/69] irqchip/irq-imx-gpcv2: Fix spinlock initialization Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 51/69] drm/i915/gvt: set the correct default value of CTX STATUS PTR Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 46/69] can: ifi: use correct register to read rx status Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 31/69] efi/libstub: Skip GOP with PIXEL_BLT_ONLY format Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 22/69] x86/efi: Dont try to reserve runtime regions Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 25/69] x86, pmem: fix broken __copy_user_nocache cache-bypass assumptions Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 28/69] acpi, nfit, libnvdimm: fix interleave set cookie calculation (64-bit comparison) Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 27/69] x86/vdso: Plug race between mapping and ELF header setup Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 53/69] Revert "MIPS: Lantiq: Fix cascaded IRQ setup" Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 32/69] efi/fb: Avoid reconfiguration of BAR that covers the framebuffer Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 09/69] orangefs: free superblock when mount fails Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 03/69] tcmu: Fix possible overwrite of t_data_sgs last iov[] Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 04/69] tcmu: Fix wrongly calculating of the base_command_size Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 29/69] ACPI / scan: Set the visited flag for all enumerated devices Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 47/69] pwm: rockchip: State of PWM clock should synchronize with PWM enabled state Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 05/69] tcmu: Skip Data-Out blocks before gathering Data-In buffer for BIDI case Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 60/69] parisc: Fix get_user() for 64-bit value on 32-bit kernel Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 44/69] libnvdimm: fix reconfig_mutex, mmap_sem, and jbd2_handle lockdep splat Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:30 +0200
[PATCH 4.10 19/69] Input: xpad - add support for Razer Wildcat gamepad Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:40 +0200
[PATCH 4.10 17/69] CIFS: reconnect thread reschedule itself Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:40 +0200
[PATCH 4.10 13/69] drm/nouveau/kms/nv50: fix double dma_fence_put() when destroying plane state Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:40 +0200
[PATCH 4.10 02/69] audit: make sure we dont let the retry queue grow without bounds Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:40 +0200
[PATCH 4.10 01/69] cgroup, kthread: close race window where new kthreads can be migrated to non-root cgroups Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:40 +0200
[PATCH 4.10 10/69] drm/nouveau/mpeg: mthd returns true on success now Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:40 +0200
[PATCH 4.10 12/69] drm/nouveau/kms/nv50: fix setting of HeadSetRasterVertBlankDmi method Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-19 17:40 +0200
Re: [PATCH 4.10 00/69] 4.10.12-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2017-04-19 22:40 +0200
Re: [PATCH 4.10 00/69] 4.10.12-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-20 08:40 +0200
Re: [PATCH 4.10 00/69] 4.10.12-stable review Guenter Roeck <linux@roeck-us.net> - 2017-04-20 01:30 +0200
Re: [PATCH 4.10 00/69] 4.10.12-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-20 08:40 +0200
csiph-web