<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/block, branch v3.2.41</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.2.41</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.2.41'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2013-03-06T03:24:16Z</updated>
<entry>
<title>block: fix synchronization and limit check in blk_alloc_devt()</title>
<updated>2013-03-06T03:24:16Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2013-02-28T01:03:56Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a51db52c68e3ad5c718c1915d28086b2c0ef8642'/>
<id>urn:sha1:a51db52c68e3ad5c718c1915d28086b2c0ef8642</id>
<content type='text'>
commit ce23bba842aee98092225d9576dba47c82352521 upstream.

idr allocation in blk_alloc_devt() wasn't synchronized against lookup
and removal, and its limit check was off by one - 1 &lt;&lt; MINORBITS is
the number of minors allowed, not the maximum allowed minor.

Add locking and rename MAX_EXT_DEVT to NR_EXT_DEVT and fix limit
checking.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>block: fix ext_devt_idr handling</title>
<updated>2013-03-06T03:24:15Z</updated>
<author>
<name>Tomas Henzl</name>
<email>thenzl@redhat.com</email>
</author>
<published>2013-02-28T01:03:32Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=2abb7d3a3cf05900a6d9cc6b98b1ba3aa432ce30'/>
<id>urn:sha1:2abb7d3a3cf05900a6d9cc6b98b1ba3aa432ce30</id>
<content type='text'>
commit 7b74e912785a11572da43292786ed07ada7e3e0c upstream.

While adding and removing a lot of disks disks and partitions this
sometimes shows up:

  WARNING: at fs/sysfs/dir.c:512 sysfs_add_one+0xc9/0x130() (Not tainted)
  Hardware name:
  sysfs: cannot create duplicate filename '/dev/block/259:751'
  Modules linked in: raid1 autofs4 bnx2fc cnic uio fcoe libfcoe libfc 8021q scsi_transport_fc scsi_tgt garp stp llc sunrpc cpufreq_ondemand powernow_k8 freq_table mperf ipv6 dm_mirror dm_region_hash dm_log power_meter microcode dcdbas serio_raw amd64_edac_mod edac_core edac_mce_amd i2c_piix4 i2c_core k10temp bnx2 sg ixgbe dca mdio ext4 mbcache jbd2 dm_round_robin sr_mod cdrom sd_mod crc_t10dif ata_generic pata_acpi pata_atiixp ahci mptsas mptscsih mptbase scsi_transport_sas dm_multipath dm_mod [last unloaded: scsi_wait_scan]
  Pid: 44103, comm: async/16 Not tainted 2.6.32-195.el6.x86_64 #1
  Call Trace:
    warn_slowpath_common+0x87/0xc0
    warn_slowpath_fmt+0x46/0x50
    sysfs_add_one+0xc9/0x130
    sysfs_do_create_link+0x12b/0x170
    sysfs_create_link+0x13/0x20
    device_add+0x317/0x650
    idr_get_new+0x13/0x50
    add_partition+0x21c/0x390
    rescan_partitions+0x32b/0x470
    sd_open+0x81/0x1f0 [sd_mod]
    __blkdev_get+0x1b6/0x3c0
    blkdev_get+0x10/0x20
    register_disk+0x155/0x170
    add_disk+0xa6/0x160
    sd_probe_async+0x13b/0x210 [sd_mod]
    add_wait_queue+0x46/0x60
    async_thread+0x102/0x250
    default_wake_function+0x0/0x20
    async_thread+0x0/0x250
    kthread+0x96/0xa0
    child_rip+0xa/0x20
    kthread+0x0/0xa0
    child_rip+0x0/0x20

This most likely happens because dev_t is freed while the number is
still used and idr_get_new() is not protected on every use.  The fix
adds a mutex where it wasn't before and moves the dev_t free function so
it is called after device del.

Signed-off-by: Tomas Henzl &lt;thenzl@redhat.com&gt;
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>block: Don't access request after it might be freed</title>
<updated>2012-12-06T11:20:35Z</updated>
<author>
<name>Roland Dreier</name>
<email>roland@purestorage.com</email>
</author>
<published>2012-11-22T10:00:11Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=32eb44e290d1151e9eb26f57564dae6966190685'/>
<id>urn:sha1:32eb44e290d1151e9eb26f57564dae6966190685</id>
<content type='text'>
commit 893d290f1d7496db97c9471bc352ad4a11dc8a25 upstream.

After we've done __elv_add_request() and __blk_run_queue() in
blk_execute_rq_nowait(), the request might finish and be freed
immediately.  Therefore checking if the type is REQ_TYPE_PM_RESUME
isn't safe afterwards, because if it isn't, rq might be gone.
Instead, check beforehand and stash the result in a temporary.

This fixes crashes in blk_execute_rq_nowait() I get occasionally when
running with lots of memory debugging options enabled -- I think this
race is usually harmless because the window for rq to be reallocated
is so small.

Signed-off-by: Roland Dreier &lt;roland@purestorage.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>block: add blk_queue_dead()</title>
<updated>2012-08-02T13:37:54Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2011-12-13T23:33:37Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=68e9e9fee2bbec4853a993e98b0df8479292f572'/>
<id>urn:sha1:68e9e9fee2bbec4853a993e98b0df8479292f572</id>
<content type='text'>
commit 34f6055c80285e4efb3f602a9119db75239744dc upstream.

There are a number of QUEUE_FLAG_DEAD tests.  Add blk_queue_dead()
macro and use it.

This patch doesn't introduce any functional difference.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>scsi: Silence unnecessary warnings about ioctl to partition</title>
<updated>2012-07-25T03:11:05Z</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2012-06-15T10:52:46Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f45c9a6eec20cd712421c442785e7a4e9215a230'/>
<id>urn:sha1:f45c9a6eec20cd712421c442785e7a4e9215a230</id>
<content type='text'>
commit 6d9359280753d2955f86d6411047516a9431eb51 upstream.

Sometimes, warnings about ioctls to partition happen often enough that they
form majority of the warnings in the kernel log and users complain. In some
cases warnings are about ioctls such as SG_IO so it's not good to get rid of
the warnings completely as they can ease debugging of userspace problems
when ioctl is refused.

Since I have seen warnings from lots of commands, including some proprietary
userspace applications, I don't think disallowing the ioctls for processes
with CAP_SYS_RAWIO will happen in the near future if ever. So lets just
stop warning for processes with CAP_SYS_RAWIO for which ioctl is allowed.

CC: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
CC: James Bottomley &lt;JBottomley@parallels.com&gt;
CC: linux-scsi@vger.kernel.org
Acked-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
[bwh: Backported to 3.2: use ENOTTY, not ENOIOCTLCMD]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>block: fix buffer overflow when printing partition UUIDs</title>
<updated>2012-05-30T23:43:15Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2012-05-15T06:22:04Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9fd246e048bbd8569a84b412382cd299e0313a62'/>
<id>urn:sha1:9fd246e048bbd8569a84b412382cd299e0313a62</id>
<content type='text'>
commit 05c69d298c96703741cac9a5cbbf6c53bd55a6e2 upstream.

6d1d8050b4bc8 "block, partition: add partition_meta_info to hd_struct"
added part_unpack_uuid() which assumes that the passed in buffer has
enough space for sprintfing "%pU" - 37 characters including '\0'.

Unfortunately, b5af921ec0233 "init: add support for root devices
specified by partition UUID" supplied 33 bytes buffer to the function
leading to the following panic with stackprotector enabled.

  Kernel panic - not syncing: stack-protector: Kernel stack corrupted in: ffffffff81b14c7e

  [&lt;ffffffff815e226b&gt;] panic+0xba/0x1c6
  [&lt;ffffffff81b14c7e&gt;] ? printk_all_partitions+0x259/0x26xb
  [&lt;ffffffff810566bb&gt;] __stack_chk_fail+0x1b/0x20
  [&lt;ffffffff81b15c7e&gt;] printk_all_paritions+0x259/0x26xb
  [&lt;ffffffff81aedfe0&gt;] mount_block_root+0x1bc/0x27f
  [&lt;ffffffff81aee0fa&gt;] mount_root+0x57/0x5b
  [&lt;ffffffff81aee23b&gt;] prepare_namespace+0x13d/0x176
  [&lt;ffffffff8107eec0&gt;] ? release_tgcred.isra.4+0x330/0x30
  [&lt;ffffffff81aedd60&gt;] kernel_init+0x155/0x15a
  [&lt;ffffffff81087b97&gt;] ? schedule_tail+0x27/0xb0
  [&lt;ffffffff815f4d24&gt;] kernel_thread_helper+0x5/0x10
  [&lt;ffffffff81aedc0b&gt;] ? start_kernel+0x3c5/0x3c5
  [&lt;ffffffff815f4d20&gt;] ? gs_change+0x13/0x13

Increase the buffer size, remove the dangerous part_unpack_uuid() and
use snprintf() directly from printk_all_partitions().

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-by: Szymon Gruszczynski &lt;sz.gruszczynski@googlemail.com&gt;
Cc: Will Drewry &lt;wad@chromium.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>Block: use a freezable workqueue for disk-event polling</title>
<updated>2012-03-19T16:02:34Z</updated>
<author>
<name>Alan Stern</name>
<email>stern@rowland.harvard.edu</email>
</author>
<published>2012-03-02T09:51:00Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=2053689f68e19b8c1bb38aa68049c57576eed6e0'/>
<id>urn:sha1:2053689f68e19b8c1bb38aa68049c57576eed6e0</id>
<content type='text'>
commit 62d3c5439c534b0e6c653fc63e6d8c67be3a57b1 upstream.

This patch (as1519) fixes a bug in the block layer's disk-events
polling.  The polling is done by a work routine queued on the
system_nrt_wq workqueue.  Since that workqueue isn't freezable, the
polling continues even in the middle of a system sleep transition.

Obviously, polling a suspended drive for media changes and such isn't
a good thing to do; in the case of USB mass-storage devices it can
lead to real problems requiring device resets and even re-enumeration.

The patch fixes things by creating a new system-wide, non-reentrant,
freezable workqueue and using it for disk-events polling.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Rafael J. Wysocki &lt;rjw@sisk.pl&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>block: fix __blkdev_get and add_disk race condition</title>
<updated>2012-03-19T16:02:34Z</updated>
<author>
<name>Stanislaw Gruszka</name>
<email>sgruszka@redhat.com</email>
</author>
<published>2012-03-02T09:43:28Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=eee92c36399fe1c0d19de4982e9cfdf526b37922'/>
<id>urn:sha1:eee92c36399fe1c0d19de4982e9cfdf526b37922</id>
<content type='text'>
commit 9f53d2fe815b4011ff930a7b6db98385d45faa68 upstream.

The following situation might occur:

__blkdev_get:			add_disk:

				register_disk()
get_gendisk()

disk_block_events()
	disk-&gt;ev == NULL

				disk_add_events()

__disk_unblock_events()
	disk-&gt;ev != NULL
	--ev-&gt;block

Then we unblock events, when they are suppose to be blocked. This can
trigger events related block/genhd.c warnings, but also can crash in
sd_check_events() or other places.

I'm able to reproduce crashes with the following scripts (with
connected usb dongle as sdb disk).

&lt;snip&gt;
DEV=/dev/sdb
ENABLE=/sys/bus/usb/devices/1-2/bConfigurationValue

function stop_me()
{
	for i in `jobs -p` ; do kill $i 2&gt; /dev/null ; done
	exit
}

trap stop_me SIGHUP SIGINT SIGTERM

for ((i = 0; i &lt; 10; i++)) ; do
	while true; do fdisk -l $DEV  2&gt;&amp;1 &gt; /dev/null ; done &amp;
done

while true ; do
echo 1 &gt; $ENABLE
sleep 1
echo 0 &gt; $ENABLE
done
&lt;/snip&gt;

I use the script to verify patch fixing oops in sd_revalidate_disk
http://marc.info/?l=linux-scsi&amp;m=132935572512352&amp;w=2
Without Jun'ichi Nomura patch titled "Fix NULL pointer dereference in
sd_revalidate_disk" or this one, script easily crash kernel within
a few seconds. With both patches applied I do not observe crash.
Unfortunately after some time (dozen of minutes), script will hung in:

[ 1563.906432]  [&lt;c08354f5&gt;] schedule_timeout_uninterruptible+0x15/0x20
[ 1563.906437]  [&lt;c04532d5&gt;] msleep+0x15/0x20
[ 1563.906443]  [&lt;c05d60b2&gt;] blk_drain_queue+0x32/0xd0
[ 1563.906447]  [&lt;c05d6e00&gt;] blk_cleanup_queue+0xd0/0x170
[ 1563.906454]  [&lt;c06d278f&gt;] scsi_free_queue+0x3f/0x60
[ 1563.906459]  [&lt;c06d7e6e&gt;] __scsi_remove_device+0x6e/0xb0
[ 1563.906463]  [&lt;c06d4aff&gt;] scsi_forget_host+0x4f/0x60
[ 1563.906468]  [&lt;c06cd84a&gt;] scsi_remove_host+0x5a/0xf0
[ 1563.906482]  [&lt;f7f030fb&gt;] quiesce_and_remove_host+0x5b/0xa0 [usb_storage]
[ 1563.906490]  [&lt;f7f03203&gt;] usb_stor_disconnect+0x13/0x20 [usb_storage]

Anyway I think this patch is some step forward.

As drawback, I do not teardown on sysfs file create error, because I do
not know how to nullify disk-&gt;ev (since it can be used). However add_disk
error handling practically does not exist too, and things will work
without this sysfs file, except events will not be exported to user
space.

Signed-off-by: Stanislaw Gruszka &lt;sgruszka@redhat.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>bsg: fix sysfs link remove warning</title>
<updated>2012-03-12T19:31:36Z</updated>
<author>
<name>Stanislaw Gruszka</name>
<email>sgruszka@redhat.com</email>
</author>
<published>2012-02-08T19:02:03Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6e118375b14e1cd89cab325c79faf6f48dc9c50b'/>
<id>urn:sha1:6e118375b14e1cd89cab325c79faf6f48dc9c50b</id>
<content type='text'>
commit 37b40adf2d1b4a5e51323be73ccf8ddcf3f15dd3 upstream.

We create "bsg" link if q-&gt;kobj.sd is not NULL, so remove it only
when the same condition is true.

Fixes:

WARNING: at fs/sysfs/inode.c:323 sysfs_hash_and_remove+0x2b/0x77()
sysfs: can not remove 'bsg', no directory
Call Trace:
  [&lt;c0429683&gt;] warn_slowpath_common+0x6a/0x7f
  [&lt;c0537a68&gt;] ? sysfs_hash_and_remove+0x2b/0x77
  [&lt;c042970b&gt;] warn_slowpath_fmt+0x2b/0x2f
  [&lt;c0537a68&gt;] sysfs_hash_and_remove+0x2b/0x77
  [&lt;c053969a&gt;] sysfs_remove_link+0x20/0x23
  [&lt;c05d88f1&gt;] bsg_unregister_queue+0x40/0x6d
  [&lt;c0692263&gt;] __scsi_remove_device+0x31/0x9d
  [&lt;c069149f&gt;] scsi_forget_host+0x41/0x52
  [&lt;c0689fa9&gt;] scsi_remove_host+0x71/0xe0
  [&lt;f7de5945&gt;] quiesce_and_remove_host+0x51/0x83 [usb_storage]
  [&lt;f7de5a1e&gt;] usb_stor_disconnect+0x18/0x22 [usb_storage]
  [&lt;c06c29de&gt;] usb_unbind_interface+0x4e/0x109
  [&lt;c067a80f&gt;] __device_release_driver+0x6b/0xa6
  [&lt;c067a861&gt;] device_release_driver+0x17/0x22
  [&lt;c067a46a&gt;] bus_remove_device+0xd6/0xe6
  [&lt;c06785e2&gt;] device_del+0xf2/0x137
  [&lt;c06c101f&gt;] usb_disable_device+0x94/0x1a0

Signed-off-by: Stanislaw Gruszka &lt;sgruszka@redhat.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Tim Gardner &lt;tim.gardner@canonical.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>block: fail SCSI passthrough ioctls on partition devices</title>
<updated>2012-01-26T00:13:42Z</updated>
<author>
<name>Paolo Bonzini</name>
<email>pbonzini@redhat.com</email>
</author>
<published>2012-01-12T15:01:28Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=d33310de0d7914f2e27ed4fef67a1979f10037e1'/>
<id>urn:sha1:d33310de0d7914f2e27ed4fef67a1979f10037e1</id>
<content type='text'>
commit 0bfc96cb77224736dfa35c3c555d37b3646ef35e upstream.

[ Changes with respect to 3.3: return -ENOTTY from scsi_verify_blk_ioctl
  and -ENOIOCTLCMD from sd_compat_ioctl. ]

Linux allows executing the SG_IO ioctl on a partition or LVM volume, and
will pass the command to the underlying block device.  This is
well-known, but it is also a large security problem when (via Unix
permissions, ACLs, SELinux or a combination thereof) a program or user
needs to be granted access only to part of the disk.

This patch lets partitions forward a small set of harmless ioctls;
others are logged with printk so that we can see which ioctls are
actually sent.  In my tests only CDROM_GET_CAPABILITY actually occurred.
Of course it was being sent to a (partition on a) hard disk, so it would
have failed with ENOTTY and the patch isn't changing anything in
practice.  Still, I'm treating it specially to avoid spamming the logs.

In principle, this restriction should include programs running with
CAP_SYS_RAWIO.  If for example I let a program access /dev/sda2 and
/dev/sdb, it still should not be able to read/write outside the
boundaries of /dev/sda2 independent of the capabilities.  However, for
now programs with CAP_SYS_RAWIO will still be allowed to send the
ioctls.  Their actions will still be logged.

This patch does not affect the non-libata IDE driver.  That driver
however already tests for bd != bd-&gt;bd_contains before issuing some
ioctl; it could be restricted further to forbid these ioctls even for
programs running with CAP_SYS_ADMIN/CAP_SYS_RAWIO.

Cc: linux-scsi@vger.kernel.org
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: James Bottomley &lt;JBottomley@parallels.com&gt;
Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
[ Make it also print the command name when warning - Linus ]
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
</feed>
