dect
/
linux-2.6
Archived
13
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
linux-2.6/drivers
Jun'ichi Nomura ae9da83f6d dm: fix thaw_bdev
This patch fixes a bd_mount_sem counter corruption bug in device-mapper.

thaw_bdev() should be called only when freeze_bdev() was called for the
device.
Otherwise, thaw_bdev() will up bd_mount_sem and corrupt the semaphore counter.
struct block_device with the corrupted semaphore may remain in slab cache
and be reused later.

Attached patch will fix it by calling unlock_fs() instead.
unlock_fs() will determine whether it should call thaw_bdev()
by checking the device is frozen or not.

Easy reproducer is:
  #!/bin/sh
  while [ 1 ]; do
     dmsetup --notable create a
     dmsetup --nolockfs suspend a
     dmsetup remove a
  done

It's not easy to see the effect of corrupted semaphore.
So I have tested with putting printk below in bdev_alloc_inode():
        if (atomic_read(&ei->bdev.bd_mount_sem.count) != 1)
                printk(KERN_DEBUG "Incorrect semaphore count = %d (%p)\n",
                        atomic_read(&ei->bdev.bd_mount_sem.count),
                        &ei->bdev);

Without the patch, I saw something like:
 Incorrect semaphore count = 17 (f2ab91c0)

With the patch, the message didn't appear.

The bug was introduced in 2.6.16 with this bug fix:

commit d9dde59ba0
Date:   Fri Feb 24 13:04:24 2006 -0800

    [PATCH] dm: missing bdput/thaw_bdev at removal

    Need to unfreeze and release bdev otherwise the bdev inode with
    inconsistent state is reused later and cause problem.

and backported to 2.6.15.5.

It occurs only in free_dev(), which is called only when the dm device is
removed.  The buggy code is executed only if md->suspended_bdev is
non-NULL and that can happen only when the device was suspended without
noflush.

Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Cc: stable@kernel.org
2007-10-20 02:01:05 +01:00
..
acorn/char unicode diacritics support 2007-10-17 08:42:52 -07:00
acpi Merge ssh://master.kernel.org/pub/scm/linux/kernel/git/tglx/linux-2.6-x86 2007-10-19 15:06:00 -07:00
amba Driver core: change add_uevent_var to use a struct 2007-10-12 14:51:01 -07:00
ata Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev 2007-10-18 15:08:35 -07:00
atm Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild 2007-10-16 11:23:06 -07:00
auxdisplay
base sparse pointer use of zero as null 2007-10-18 14:37:31 -07:00
block Use helpers to obtain task pid in printks 2007-10-19 11:53:43 -07:00
bluetooth
cdrom Use helpers to obtain task pid in printks 2007-10-19 11:53:43 -07:00
char Use helpers to obtain task pid in printks 2007-10-19 11:53:43 -07:00
clocksource
connector [NET]: make netlink user -> kernel interface synchronious 2007-10-10 21:15:29 -07:00
cpufreq Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6 2007-10-12 15:49:37 -07:00
cpuidle
crypto [CRYPTO] sha: Add header file for SHA definitions 2007-10-10 16:55:50 -07:00
dca I/OAT: Add DCA services 2007-10-16 09:43:09 -07:00
dio
dma I/OAT: Add completion callback for async_tx interface use 2007-10-18 14:37:32 -07:00
edac NULL terminate the pci_device_ids in pasemi_edac 2007-10-19 11:53:56 -07:00
eisa signedness: module_param_array nump argument 2007-10-14 12:41:52 -07:00
fc4 Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2007-10-15 08:19:33 -07:00
firewire firewire: fw-cdev: reorder wakeup vs. spinlock 2007-10-17 00:00:10 +02:00
firmware define global BIT macro 2007-10-19 11:53:42 -07:00
hid Use helpers to obtain task pid in printks 2007-10-19 11:53:43 -07:00
hwmon Merge ssh://master.kernel.org/pub/scm/linux/kernel/git/tglx/linux-2.6-x86 2007-10-19 15:06:00 -07:00
i2c i2c-pxa, rename BIT macro to PXA_BIT 2007-10-19 11:53:42 -07:00
ide remove asm/bitops.h includes 2007-10-19 11:53:41 -07:00
ieee1394 ieee1394: ieee1394_core.c: use DEFINE_SPINLOCK for spinlock definition 2007-10-16 23:59:59 +02:00
infiniband [INET]: Justification for local port range robustness. 2007-10-18 22:00:17 -07:00
input Merge ssh://master.kernel.org/pub/scm/linux/kernel/git/tglx/linux-2.6-x86 2007-10-19 15:06:00 -07:00
isdn isdn/sc: remove unused REQUEST_IRQ and unnecessary header file 2007-10-19 11:53:34 -07:00
kvm sched: guest CPU accounting: maintain guest state in KVM 2007-10-15 17:00:19 +02:00
leds Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild 2007-10-16 11:23:06 -07:00
lguest Merge branch 'xen-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen 2007-10-17 11:10:11 -07:00
macintosh get rid of input BIT* duplicate defines 2007-10-19 11:53:42 -07:00
mca
md dm: fix thaw_bdev 2007-10-20 02:01:05 +01:00
media Use helpers to obtain task pid in printks 2007-10-19 11:53:43 -07:00
message I2O: Fix "defined but not used" build warnings 2007-10-17 08:42:56 -07:00
mfd
misc Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 2007-10-19 13:12:46 -07:00
mmc mmc: at91_mci: cleanup: use MCI_ERRORS 2007-10-17 21:35:10 +02:00
mtd Use helpers to obtain task pid in printks 2007-10-19 11:53:43 -07:00
net Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 2007-10-19 13:12:46 -07:00
nubus
of [SPARC/64]: Consolidate of_register_driver 2007-10-17 21:17:42 -07:00
oprofile
parisc
parport sysctl: parport remove binary paths 2007-10-18 14:37:23 -07:00
pci Get rid of unused variable warning in drivers/pci/hotplug/pci_hotplug_core.c 2007-10-15 09:07:58 -07:00
pcmcia remove asm/bitops.h includes 2007-10-19 11:53:41 -07:00
pnp PNP: add debug message for adding new device 2007-10-17 08:43:04 -07:00
power Add missing newlines to some uses of dev_<level> messages 2007-10-18 14:37:28 -07:00
ps3 remove asm/bitops.h includes 2007-10-19 11:53:41 -07:00
rapidio
rtc remove asm/bitops.h includes 2007-10-19 11:53:41 -07:00
s390 remove asm/bitops.h includes 2007-10-19 11:53:41 -07:00
sbus [SPARC] Videopix Frame Grabber: Convert device_lock_sem to mutex 2007-10-17 19:40:31 -07:00
scsi Change struct marker users 2007-10-19 11:53:53 -07:00
serial amba-pl011, rename BIT macro 2007-10-19 11:53:42 -07:00
sh
sn
spi Add missing newlines to some uses of dev_<level> messages 2007-10-18 14:37:28 -07:00
ssb [PATCH] ssb: fix build failure 2007-10-16 21:04:11 -04:00
tc lk201: remove obsolete driver 2007-10-17 08:42:57 -07:00
telephony kconfig: syntax cleanup - drop support for "depends/requires/def_boolean" 2007-10-12 21:20:32 +02:00
uio
usb Use helpers to obtain task pid in printks 2007-10-19 11:53:43 -07:00
video Merge ssh://master.kernel.org/pub/scm/linux/kernel/git/tglx/linux-2.6-x86 2007-10-19 15:06:00 -07:00
w1 Add missing newlines to some uses of dev_<level> messages 2007-10-18 14:37:28 -07:00
watchdog remove asm/bitops.h includes 2007-10-19 11:53:41 -07:00
xen Add missing newlines to some uses of dev_<level> messages 2007-10-18 14:37:28 -07:00
zorro
Kconfig mv watchdog tree under drivers 2007-10-18 10:39:03 +00:00
Makefile Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 2007-10-19 13:12:46 -07:00