Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1375184
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4.4 047/210] dm snapshot: disallow the COW and origin devices from being identical |
| Date | 2016-04-10 22:10 +0200 |
| Message-ID | <rmtQh-22e-69@gated-at.bofh.it> (permalink) |
| References | <rmsKu-Wx-25@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: DingXiang <dingxiang@huawei.com>
commit 4df2bf466a9c9c92f40d27c4aa9120f4e8227bfc upstream.
Otherwise loading a "snapshot" table using the same device for the
origin and COW devices, e.g.:
echo "0 20971520 snapshot 253:3 253:3 P 8" | dmsetup create snap
will trigger:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000098
[ 1958.979934] IP: [<ffffffffa040efba>] dm_exception_store_set_chunk_size+0x7a/0x110 [dm_snapshot]
[ 1958.989655] PGD 0
[ 1958.991903] Oops: 0000 [#1] SMP
...
[ 1959.059647] CPU: 9 PID: 3556 Comm: dmsetup Tainted: G IO 4.5.0-rc5.snitm+ #150
...
[ 1959.083517] task: ffff8800b9660c80 ti: ffff88032a954000 task.ti: ffff88032a954000
[ 1959.091865] RIP: 0010:[<ffffffffa040efba>] [<ffffffffa040efba>] dm_exception_store_set_chunk_size+0x7a/0x110 [dm_snapshot]
[ 1959.104295] RSP: 0018:ffff88032a957b30 EFLAGS: 00010246
[ 1959.110219] RAX: 0000000000000000 RBX: 0000000000000008 RCX: 0000000000000001
[ 1959.118180] RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff880329334a00
[ 1959.126141] RBP: ffff88032a957b50 R08: 0000000000000000 R09: 0000000000000001
[ 1959.134102] R10: 000000000000000a R11: f000000000000000 R12: ffff880330884d80
[ 1959.142061] R13: 0000000000000008 R14: ffffc90001c13088 R15: ffff880330884d80
[ 1959.150021] FS: 00007f8926ba3840(0000) GS:ffff880333440000(0000) knlGS:0000000000000000
[ 1959.159047] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1959.165456] CR2: 0000000000000098 CR3: 000000032f48b000 CR4: 00000000000006e0
[ 1959.173415] Stack:
[ 1959.175656] ffffc90001c13040 ffff880329334a00 ffff880330884ed0 ffff88032a957bdc
[ 1959.183946] ffff88032a957bb8 ffffffffa040f225 ffff880329334a30 ffff880300000000
[ 1959.192233] ffffffffa04133e0 ffff880329334b30 0000000830884d58 00000000569c58cf
[ 1959.200521] Call Trace:
[ 1959.203248] [<ffffffffa040f225>] dm_exception_store_create+0x1d5/0x240 [dm_snapshot]
[ 1959.211986] [<ffffffffa040d310>] snapshot_ctr+0x140/0x630 [dm_snapshot]
[ 1959.219469] [<ffffffffa0005c44>] ? dm_split_args+0x64/0x150 [dm_mod]
[ 1959.226656] [<ffffffffa0005ea7>] dm_table_add_target+0x177/0x440 [dm_mod]
[ 1959.234328] [<ffffffffa0009203>] table_load+0x143/0x370 [dm_mod]
[ 1959.241129] [<ffffffffa00090c0>] ? retrieve_status+0x1b0/0x1b0 [dm_mod]
[ 1959.248607] [<ffffffffa0009e35>] ctl_ioctl+0x255/0x4d0 [dm_mod]
[ 1959.255307] [<ffffffff813304e2>] ? memzero_explicit+0x12/0x20
[ 1959.261816] [<ffffffffa000a0c3>] dm_ctl_ioctl+0x13/0x20 [dm_mod]
[ 1959.268615] [<ffffffff81215eb6>] do_vfs_ioctl+0xa6/0x5c0
[ 1959.274637] [<ffffffff81120d2f>] ? __audit_syscall_entry+0xaf/0x100
[ 1959.281726] [<ffffffff81003176>] ? do_audit_syscall_entry+0x66/0x70
[ 1959.288814] [<ffffffff81216449>] SyS_ioctl+0x79/0x90
[ 1959.294450] [<ffffffff8167e4ae>] entry_SYSCALL_64_fastpath+0x12/0x71
...
[ 1959.323277] RIP [<ffffffffa040efba>] dm_exception_store_set_chunk_size+0x7a/0x110 [dm_snapshot]
[ 1959.333090] RSP <ffff88032a957b30>
[ 1959.336978] CR2: 0000000000000098
[ 1959.344121] ---[ end trace b049991ccad1169e ]---
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1195899
Signed-off-by: Ding Xiang <dingxiang@huawei.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/md/dm-snap.c | 9 +++++++++
drivers/md/dm-table.c | 36 ++++++++++++++++++++++++------------
include/linux/device-mapper.h | 2 ++
3 files changed, 35 insertions(+), 12 deletions(-)
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -1106,6 +1106,7 @@ static int snapshot_ctr(struct dm_target
int i;
int r = -EINVAL;
char *origin_path, *cow_path;
+ dev_t origin_dev, cow_dev;
unsigned args_used, num_flush_bios = 1;
fmode_t origin_mode = FMODE_READ;
@@ -1136,11 +1137,19 @@ static int snapshot_ctr(struct dm_target
ti->error = "Cannot get origin device";
goto bad_origin;
}
+ origin_dev = s->origin->bdev->bd_dev;
cow_path = argv[0];
argv++;
argc--;
+ cow_dev = dm_get_dev_t(cow_path);
+ if (cow_dev && cow_dev == origin_dev) {
+ ti->error = "COW device cannot be the same as origin device";
+ r = -EINVAL;
+ goto bad_cow;
+ }
+
r = dm_get_device(ti, cow_path, dm_table_get_mode(ti->table), &s->cow);
if (r) {
ti->error = "Cannot get COW device";
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -365,6 +365,26 @@ static int upgrade_mode(struct dm_dev_in
}
/*
+ * Convert the path to a device
+ */
+dev_t dm_get_dev_t(const char *path)
+{
+ dev_t uninitialized_var(dev);
+ struct block_device *bdev;
+
+ bdev = lookup_bdev(path);
+ if (IS_ERR(bdev))
+ dev = name_to_dev_t(path);
+ else {
+ dev = bdev->bd_dev;
+ bdput(bdev);
+ }
+
+ return dev;
+}
+EXPORT_SYMBOL_GPL(dm_get_dev_t);
+
+/*
* Add a device to the list, or just increment the usage count if
* it's already present.
*/
@@ -372,23 +392,15 @@ int dm_get_device(struct dm_target *ti,
struct dm_dev **result)
{
int r;
- dev_t uninitialized_var(dev);
+ dev_t dev;
struct dm_dev_internal *dd;
struct dm_table *t = ti->table;
- struct block_device *bdev;
BUG_ON(!t);
- /* convert the path to a device */
- bdev = lookup_bdev(path);
- if (IS_ERR(bdev)) {
- dev = name_to_dev_t(path);
- if (!dev)
- return -ENODEV;
- } else {
- dev = bdev->bd_dev;
- bdput(bdev);
- }
+ dev = dm_get_dev_t(path);
+ if (!dev)
+ return -ENODEV;
dd = find_device(&t->devices, dev);
if (!dd) {
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -124,6 +124,8 @@ struct dm_dev {
char name[16];
};
+dev_t dm_get_dev_t(const char *path);
+
/*
* Constructors should call these functions to ensure destination devices
* are opened/closed correctly.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 4.4 000/210] 4.4.7-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 025/210] EDAC/sb_edac: Fix computation of channel address Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 043/210] scsi: storvsc: fix SRB_STATUS_ABORTED handling Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 006/210] mmc: sh_mmcif: Correct TX DMA channel allocation Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 007/210] x86/microcode/intel: Make early loader look for builtin microcode too Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 026/210] EDAC, amd64_edac: Shift wrapping issue in f1x_get_norm_dct_addr() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 016/210] KVM: VMX: avoid guest hang on invalid invvpid instruction Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 094/210] staging: comedi: ni_mio_common: fix the ni_write[blw]() functions Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 009/210] x86/entry/compat: Keep TS_COMPAT set during signal delivery Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 096/210] net: irda: Fix use-after-free in irtty_open() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 092/210] staging: comedi: ni_tiocmd: change mistaken use of start_src for start_arg Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 085/210] tpm_crb: tpm2_shutdown() must be called before tpm_chip_unregister() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 024/210] sched/preempt, sh: kmap_coherent relies on disabled preemption Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 042/210] sd: Fix discard granularity when LBPRZ=1 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 077/210] crypto: ccp - memset request context to zero during import Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 053/210] usb: hub: fix a typo in hub_port_init() leading to wrong logic Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 008/210] x86/microcode: Untangle from BLK_DEV_INITRD Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 051/210] dm: fix rq_end_stats() NULL pointer in dm_requeue_original_request() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 048/210] dm: fix excessive dm-mq context switching Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 076/210] crypto: ccp - Dont assume export/import areas are aligned Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 029/210] s390/pci: enforce fmb page boundary rule Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 091/210] HID: fix hid_ignore_special_drivers module parameter Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 022/210] Thermal: Ignore invalid trip points Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 090/210] HID: multitouch: force retrieving of Win8 signature blob Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 047/210] dm snapshot: disallow the COW and origin devices from being identical Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 044/210] be2iscsi: set the boot_kset pointer to NULL in case of failure Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:10 +0200
[PATCH 4.4 018/210] perf/core: Fix perf_sched_count derailment Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 001/210] s390/cpumf: Fix lpp detection Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 011/210] x86/PCI: Mark Broadwell-EP Home Agent & PCU as having non-compliant BARs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 019/210] perf tools: Dont stop PMU parsing on alias parse error Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 014/210] KVM: fix spin_lock_init order on x86 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 017/210] KVM: VMX: fix nested vpid for old KVM guests Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 021/210] perf tools: Fix python extension build Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 012/210] KVM: x86: fix missed hardware breakpoints Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 004/210] ASoC: samsung: pass DMA channels as pointers Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 010/210] perf/x86/intel: Add definition for PT PMI bit Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 015/210] KVM: VMX: avoid guest hang on invalid invept instruction Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 005/210] mmc: sh_mmcif: rework dma channel handling Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 020/210] perf tools: Fix checking asprintf return value Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 002/210] regulator: core: avoid unused variable warning Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:20 +0200
[PATCH 4.4 028/210] s390/cpumf: add missing lpp magic initialization Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:40 +0200
[PATCH 4.4 182/210] clk: rockchip: add hclk_cpubus to the list of rk3188 critical clocks Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:40 +0200
[PATCH 4.4 170/210] kbuild/mkspec: fix grub2 installkernel issue Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:40 +0200
[PATCH 4.4 069/210] ALSA: usb-audio: Minor code cleanup in create_fixed_stream_quirk() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:40 +0200
[PATCH 4.4 073/210] Bluetooth: btusb: Add a new AR3012 ID 13d3:3472 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:40 +0200
[PATCH 4.4 188/210] iser-target: Rework connection termination Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:40 +0200
[PATCH 4.4 178/210] clk: rockchip: rk3368: fix cpuclk mux bit of big cpu-cluster Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:40 +0200
[PATCH 4.4 037/210] x86/mm: TLB_REMOTE_SEND_IPI should count pages Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-10 22:50 +0200
Re: [PATCH 4.4 159/210] drm/radeon: disable runtime pm on PX laptops without dGPU power control Michel Dänzer <michel@daenzer.net> - 2016-04-11 04:40 +0200
Re: [PATCH 4.4 159/210] drm/radeon: disable runtime pm on PX laptops without dGPU power control Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-12 16:20 +0200
Re: [PATCH 4.4 159/210] drm/radeon: disable runtime pm on PX laptops without dGPU power control Michel Dänzer <michel@daenzer.net> - 2016-04-13 06:00 +0200
Re: [PATCH 4.4 159/210] drm/radeon: disable runtime pm on PX laptops without dGPU power control Michel Dänzer <michel@daenzer.net> - 2016-04-14 04:50 +0200
Re: [PATCH 4.4 159/210] drm/radeon: disable runtime pm on PX laptops without dGPU power control Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-14 16:30 +0200
Re: [PATCH 4.4 000/210] 4.4.7-stable review Guenter Roeck <linux@roeck-us.net> - 2016-04-11 05:20 +0200
Re: [PATCH 4.4 000/210] 4.4.7-stable review shuahkh <shuahkh@osg.sisa.samsung.com> - 2016-04-11 19:30 +0200
csiph-web