<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/block/brd.c, branch v3.10.29</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/drivers/block/brd.c?h=v3.10.29</id>
<link rel='self' href='https://git.amat.us/linux/atom/drivers/block/brd.c?h=v3.10.29'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2013-11-29T19:11:50Z</updated>
<entry>
<title>block: fix a probe argument to blk_register_region</title>
<updated>2013-11-29T19:11:50Z</updated>
<author>
<name>Mikulas Patocka</name>
<email>mpatocka@redhat.com</email>
</author>
<published>2013-10-14T16:13:24Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=12e6e9c2a578d3a2f0474d48d845f796361a90c0'/>
<id>urn:sha1:12e6e9c2a578d3a2f0474d48d845f796361a90c0</id>
<content type='text'>
commit a207f5937630dd35bd2550620bef416937a1365e upstream.

The probe function is supposed to return NULL on failure (as we can see in
kobj_lookup: kobj = probe(dev, index, data); ... if (kobj) return kobj;

However, in loop and brd, it returns negative error from ERR_PTR.

This causes a crash if we simulate disk allocation failure and run
less -f /dev/loop0 because the negative number is interpreted as a pointer:

BUG: unable to handle kernel NULL pointer dereference at 00000000000002b4
IP: [&lt;ffffffff8118b188&gt;] __blkdev_get+0x28/0x450
PGD 23c677067 PUD 23d6d1067 PMD 0
Oops: 0000 [#1] PREEMPT SMP
Modules linked in: loop hpfs nvidia(PO) ip6table_filter ip6_tables uvesafb cfbcopyarea cfbimgblt cfbfillrect fbcon font bitblit fbcon_rotate fbcon_cw fbcon_ud fbcon_ccw softcursor fb fbdev msr ipt_MASQUERADE iptable_nat nf_nat_ipv4 nf_conntrack_ipv4 nf_defrag_ipv4 xt_state ipt_REJECT xt_tcpudp iptable_filter ip_tables x_tables bridge stp llc tun ipv6 cpufreq_stats cpufreq_ondemand cpufreq_userspace cpufreq_powersave cpufreq_conservative hid_generic spadfs usbhid hid fuse raid0 snd_usb_audio snd_pcm_oss snd_mixer_oss md_mod snd_pcm snd_timer snd_page_alloc snd_hwdep snd_usbmidi_lib dmi_sysfs snd_rawmidi nf_nat_ftp nf_nat nf_conntrack_ftp nf_conntrack snd soundcore lm85 hwmon_vid ohci_hcd ehci_pci ehci_hcd serverworks sata_svw libata acpi_cpufreq freq_table mperf ide_core usbcore kvm_amd kvm tg3 i2c_piix4 libphy microcode e100 usb_common ptp skge i2c_core pcspkr k10temp evdev floppy hwmon pps_core mii rtc_cmos button processor unix [last unloaded: nvidia]
CPU: 1 PID: 6831 Comm: less Tainted: P        W  O 3.10.15-devel #18
Hardware name: empty empty/S3992-E, BIOS 'V1.06   ' 06/09/2009
task: ffff880203cc6bc0 ti: ffff88023e47c000 task.ti: ffff88023e47c000
RIP: 0010:[&lt;ffffffff8118b188&gt;]  [&lt;ffffffff8118b188&gt;] __blkdev_get+0x28/0x450
RSP: 0018:ffff88023e47dbd8  EFLAGS: 00010286
RAX: ffffffffffffff74 RBX: ffffffffffffff74 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000001
RBP: ffff88023e47dc18 R08: 0000000000000002 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffff88023f519658
R13: ffffffff8118c300 R14: 0000000000000000 R15: ffff88023f519640
FS:  00007f2070bf7700(0000) GS:ffff880247400000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000000002b4 CR3: 000000023da1d000 CR4: 00000000000007e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Stack:
 0000000000000002 0000001d00000000 000000003e47dc50 ffff88023f519640
 ffff88043d5bb668 ffffffff8118c300 ffff88023d683550 ffff88023e47de60
 ffff88023e47dc98 ffffffff8118c10d 0000001d81605698 0000000000000292
Call Trace:
 [&lt;ffffffff8118c300&gt;] ? blkdev_get_by_dev+0x60/0x60
 [&lt;ffffffff8118c10d&gt;] blkdev_get+0x1dd/0x370
 [&lt;ffffffff8118c300&gt;] ? blkdev_get_by_dev+0x60/0x60
 [&lt;ffffffff813cea6c&gt;] ? _raw_spin_unlock+0x2c/0x50
 [&lt;ffffffff8118c300&gt;] ? blkdev_get_by_dev+0x60/0x60
 [&lt;ffffffff8118c365&gt;] blkdev_open+0x65/0x80
 [&lt;ffffffff8114d12e&gt;] do_dentry_open.isra.18+0x23e/0x2f0
 [&lt;ffffffff8114d214&gt;] finish_open+0x34/0x50
 [&lt;ffffffff8115e122&gt;] do_last.isra.62+0x2d2/0xc50
 [&lt;ffffffff8115eb58&gt;] path_openat.isra.63+0xb8/0x4d0
 [&lt;ffffffff81115a8e&gt;] ? might_fault+0x4e/0xa0
 [&lt;ffffffff8115f4f0&gt;] do_filp_open+0x40/0x90
 [&lt;ffffffff813cea6c&gt;] ? _raw_spin_unlock+0x2c/0x50
 [&lt;ffffffff8116db85&gt;] ? __alloc_fd+0xa5/0x1f0
 [&lt;ffffffff8114e45f&gt;] do_sys_open+0xef/0x1d0
 [&lt;ffffffff8114e559&gt;] SyS_open+0x19/0x20
 [&lt;ffffffff813cff16&gt;] system_call_fastpath+0x1a/0x1f
Code: 44 00 00 55 48 89 e5 41 57 49 89 ff 41 56 41 89 d6 41 55 41 54 4c 8d 67 18 53 48 83 ec 18 89 75 cc e9 f2 00 00 00 0f 1f 44 00 00 &lt;48&gt; 8b 80 40 03 00 00 48 89 df 4c 8b 68 58 e8 d5
a4 07 00 44 89
RIP  [&lt;ffffffff8118b188&gt;] __blkdev_get+0x28/0x450
 RSP &lt;ffff88023e47dbd8&gt;
CR2: 00000000000002b4
---[ end trace bb7f32dbf02398dc ]---

The brd change should be backported to stable kernels starting with 2.6.25.
The loop change should be backported to stable kernels starting with 2.6.22.

Signed-off-by: Mikulas Patocka &lt;mpatocka@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>drivers/block/brd.c: fix brd_lookup_page() race</title>
<updated>2013-05-24T23:22:52Z</updated>
<author>
<name>Brian Behlendorf</name>
<email>behlendorf1@llnl.gov</email>
</author>
<published>2013-05-24T22:55:28Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=dfd20b2b174d3a9b258ea3b7a35ead33576587b1'/>
<id>urn:sha1:dfd20b2b174d3a9b258ea3b7a35ead33576587b1</id>
<content type='text'>
The index on the page must be set before it is inserted in the radix
tree.  Otherwise there is a small race which can occur during lookup
where the page can be found with the incorrect index.  This will trigger
the BUG_ON() in brd_lookup_page().

Signed-off-by: Brian Behlendorf &lt;behlendorf1@llnl.gov&gt;
Reported-by: Chris Wedgwood &lt;cw@f00f.org&gt;
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>block: Add bio_end_sector()</title>
<updated>2013-03-23T21:15:29Z</updated>
<author>
<name>Kent Overstreet</name>
<email>koverstreet@google.com</email>
</author>
<published>2012-09-25T22:05:12Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=f73a1c7d117d07a96d89475066188a2b79e53c48'/>
<id>urn:sha1:f73a1c7d117d07a96d89475066188a2b79e53c48</id>
<content type='text'>
Just a little convenience macro - main reason to add it now is preparing
for immutable bio vecs, it'll reduce the size of the patch that puts
bi_sector/bi_size/bi_idx into a struct bvec_iter.

Signed-off-by: Kent Overstreet &lt;koverstreet@google.com&gt;
CC: Jens Axboe &lt;axboe@kernel.dk&gt;
CC: Lars Ellenberg &lt;drbd-dev@lists.linbit.com&gt;
CC: Jiri Kosina &lt;jkosina@suse.cz&gt;
CC: Alasdair Kergon &lt;agk@redhat.com&gt;
CC: dm-devel@redhat.com
CC: Neil Brown &lt;neilb@suse.de&gt;
CC: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
CC: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
CC: linux-s390@vger.kernel.org
CC: Chris Mason &lt;chris.mason@fusionio.com&gt;
CC: Steven Whitehouse &lt;swhiteho@redhat.com&gt;
Acked-by: Steven Whitehouse &lt;swhiteho@redhat.com&gt;
</content>
</entry>
<entry>
<title>block: remove the second argument of k[un]map_atomic()</title>
<updated>2012-03-20T13:48:16Z</updated>
<author>
<name>Cong Wang</name>
<email>amwang@redhat.com</email>
</author>
<published>2011-11-25T15:14:18Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=cfd8005c99c68882e962807d36603791adddfb9f'/>
<id>urn:sha1:cfd8005c99c68882e962807d36603791adddfb9f</id>
<content type='text'>
Signed-off-by: Cong Wang &lt;amwang@redhat.com&gt;
</content>
</entry>
<entry>
<title>fs: move code out of buffer.c</title>
<updated>2012-01-04T03:54:07Z</updated>
<author>
<name>Al Viro</name>
<email>viro@zeniv.linux.org.uk</email>
</author>
<published>2011-09-16T06:31:11Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=ff01bb4832651c6d25ac509a06a10fcbd75c461c'/>
<id>urn:sha1:ff01bb4832651c6d25ac509a06a10fcbd75c461c</id>
<content type='text'>
Move invalidate_bdev, block_sync_page into fs/block_dev.c.  Export
kill_bdev as well, so brd doesn't have to open code it.  Reduce
buffer_head.h requirement accordingly.

Removed a rather large comment from invalidate_bdev, as it looked a bit
obsolete to bother moving.  The small comment replacing it says enough.

Signed-off-by: Nick Piggin &lt;npiggin@suse.de&gt;
Cc: Al Viro &lt;viro@ZenIV.linux.org.uk&gt;
Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>block: remove support for bio remapping from -&gt;make_request</title>
<updated>2011-09-12T10:12:01Z</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@infradead.org</email>
</author>
<published>2011-09-12T10:12:01Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=5a7bbad27a410350e64a2d7f5ec18fc73836c14f'/>
<id>urn:sha1:5a7bbad27a410350e64a2d7f5ec18fc73836c14f</id>
<content type='text'>
There is very little benefit in allowing to let a -&gt;make_request
instance update the bios device and sector and loop around it in
__generic_make_request when we can archive the same through calling
generic_make_request from the driver and letting the loop in
generic_make_request handle it.

Note that various drivers got the return value from -&gt;make_request and
returned non-zero values for errors.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Acked-by: NeilBrown &lt;neilb@suse.de&gt;
Signed-off-by: Jens Axboe &lt;jaxboe@fusionio.com&gt;
</content>
</entry>
<entry>
<title>brd: export module parameters</title>
<updated>2011-05-26T19:06:50Z</updated>
<author>
<name>Namhyung Kim</name>
<email>namhyung@gmail.com</email>
</author>
<published>2011-05-26T19:06:50Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=8892cbaf686fb18a5f0558b9fd7773b32c0c7852'/>
<id>urn:sha1:8892cbaf686fb18a5f0558b9fd7773b32c0c7852</id>
<content type='text'>
Export 'rd_nr', 'rd_size' and 'max_part' parameters to sysfs so user can
know that how many devices are allowed, how big each device is and how
many partitions are supported. If 'max_part' is 0, it means simply the
device doesn't support partitioning.

Also note that 'max_part' can be adjusted to power of 2 minus 1 form if
needed. User should check this value after the module loading if he/she
want to use that number correctly (i.e. fdisk, mknod, etc.).

Signed-off-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
Cc: Laurent Vivier &lt;Laurent.Vivier@bull.net&gt;
Signed-off-by: Jens Axboe &lt;jaxboe@fusionio.com&gt;
</content>
</entry>
<entry>
<title>brd: fix comment on initial device creation</title>
<updated>2011-05-26T19:06:50Z</updated>
<author>
<name>Namhyung Kim</name>
<email>namhyung@gmail.com</email>
</author>
<published>2011-05-26T19:06:50Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=13868b76ab8135389fe1d8cf1c6a4847c9fef0a7'/>
<id>urn:sha1:13868b76ab8135389fe1d8cf1c6a4847c9fef0a7</id>
<content type='text'>
If 'rd_nr' param was not specified, 16 (can be adjusted via
CONFIG_BLK_DEV_RAM_COUNT) devices would be created by default
but comment said 1. Fix it.

Signed-off-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
Signed-off-by: Jens Axboe &lt;jaxboe@fusionio.com&gt;
</content>
</entry>
<entry>
<title>brd: handle on-demand devices correctly</title>
<updated>2011-05-26T19:06:50Z</updated>
<author>
<name>Namhyung Kim</name>
<email>namhyung@gmail.com</email>
</author>
<published>2011-05-26T19:06:50Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=af46566885a373b0a526932484cd8fef8de7b598'/>
<id>urn:sha1:af46566885a373b0a526932484cd8fef8de7b598</id>
<content type='text'>
When finding or allocating a ram disk device, brd_probe() did not take
partition numbers into account so that it can result to a different
device. Consider following example (I set CONFIG_BLK_DEV_RAM_COUNT=4
for simplicity) :

$ sudo modprobe brd max_part=15
$ ls -l /dev/ram*
brw-rw---- 1 root disk 1,  0 2011-05-25 15:41 /dev/ram0
brw-rw---- 1 root disk 1, 16 2011-05-25 15:41 /dev/ram1
brw-rw---- 1 root disk 1, 32 2011-05-25 15:41 /dev/ram2
brw-rw---- 1 root disk 1, 48 2011-05-25 15:41 /dev/ram3
$ sudo mknod /dev/ram4 b 1 64
$ sudo dd if=/dev/zero of=/dev/ram4 bs=4k count=256
256+0 records in
256+0 records out
1048576 bytes (1.0 MB) copied, 0.00215578 s, 486 MB/s
namhyung@leonhard:linux$ ls -l /dev/ram*
brw-rw---- 1 root disk 1,    0 2011-05-25 15:41 /dev/ram0
brw-rw---- 1 root disk 1,   16 2011-05-25 15:41 /dev/ram1
brw-rw---- 1 root disk 1,   32 2011-05-25 15:41 /dev/ram2
brw-rw---- 1 root disk 1,   48 2011-05-25 15:41 /dev/ram3
brw-r--r-- 1 root root 1,   64 2011-05-25 15:45 /dev/ram4
brw-rw---- 1 root disk 1, 1024 2011-05-25 15:44 /dev/ram64

After this patch, /dev/ram4 - instead of /dev/ram64 - was
accessed correctly.

In addition, 'range' passed to blk_register_region() should
include all range of dev_t that RAMDISK_MAJOR can address.
It does not need to be limited by partition numbers unless
'rd_nr' param was specified.

Signed-off-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
Cc: Laurent Vivier &lt;Laurent.Vivier@bull.net&gt;
Cc: stable@kernel.org
Signed-off-by: Jens Axboe &lt;jaxboe@fusionio.com&gt;
</content>
</entry>
<entry>
<title>brd: limit 'max_part' module param to DISK_MAX_PARTS</title>
<updated>2011-05-26T19:06:50Z</updated>
<author>
<name>Namhyung Kim</name>
<email>namhyung@gmail.com</email>
</author>
<published>2011-05-26T19:06:50Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=315980c8688c4b06713c1a5fe9d64cdf8ab57a72'/>
<id>urn:sha1:315980c8688c4b06713c1a5fe9d64cdf8ab57a72</id>
<content type='text'>
The 'max_part' parameter controls the number of maximum partition
a brd device can have. However if a user specifies very large
value it would exceed the limitation of device minor number and
can cause a kernel panic (or, at least, produce invalid device
nodes in some cases).

On my desktop system, following command kills the kernel. On qemu,
it triggers similar oops but the kernel was alive:

$ sudo modprobe brd max_part=100000
 BUG: unable to handle kernel NULL pointer dereference at 0000000000000058
 IP: [&lt;ffffffff81110a9a&gt;] sysfs_create_dir+0x2d/0xae
 PGD 7af1067 PUD 7b19067 PMD 0
 Oops: 0000 [#1] SMP
 last sysfs file:
 CPU 0
 Modules linked in: brd(+)

 Pid: 44, comm: insmod Tainted: G        W   2.6.39-qemu+ #158 Bochs Bochs
 RIP: 0010:[&lt;ffffffff81110a9a&gt;]  [&lt;ffffffff81110a9a&gt;] sysfs_create_dir+0x2d/0xae
 RSP: 0018:ffff880007b15d78  EFLAGS: 00000286
 RAX: ffff880007b05478 RBX: ffff880007a52760 RCX: ffff880007b15dc8
 RDX: ffff880007a4f900 RSI: ffff880007b15e48 RDI: ffff880007a52760
 RBP: ffff880007b15da8 R08: 0000000000000002 R09: 0000000000000000
 R10: ffff880007b15e48 R11: ffff880007b05478 R12: 0000000000000000
 R13: ffff880007b05478 R14: 0000000000400920 R15: 0000000000000063
 FS:  0000000002160880(0063) GS:ffff880007c00000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 0000000000000058 CR3: 0000000007b1c000 CR4: 00000000000006b0
 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
 DR3: 0000000000000000 DR6: 0000000000000000 DR7: 0000000000000000
 Process insmod (pid: 44, threadinfo ffff880007b14000, task ffff880007acb980)
 Stack:
  ffff880007b15dc8 ffff880007b05478 ffff880007b15da8 00000000fffffffe
  ffff880007a52760 ffff880007b05478 ffff880007b15de8 ffffffff81143c0a
  0000000000400920 ffff880007a52760 ffff880007b05478 0000000000000000
 Call Trace:
  [&lt;ffffffff81143c0a&gt;] kobject_add_internal+0xdf/0x1a0
  [&lt;ffffffff81143da1&gt;] kobject_add_varg+0x41/0x50
  [&lt;ffffffff81143e6b&gt;] kobject_add+0x64/0x66
  [&lt;ffffffff8113bbe7&gt;] blk_register_queue+0x5f/0xb8
  [&lt;ffffffff81140f72&gt;] add_disk+0xdf/0x289
  [&lt;ffffffffa00040df&gt;] brd_init+0xdf/0x1aa [brd]
  [&lt;ffffffffa0004000&gt;] ? 0xffffffffa0003fff
  [&lt;ffffffffa0004000&gt;] ? 0xffffffffa0003fff
  [&lt;ffffffff8100020a&gt;] do_one_initcall+0x7a/0x12e
  [&lt;ffffffff8108516c&gt;] sys_init_module+0x9c/0x1dc
  [&lt;ffffffff812ff4bb&gt;] system_call_fastpath+0x16/0x1b
 Code: 89 e5 41 55 41 54 53 48 89 fb 48 83 ec 18 48 85 ff 75 04 0f 0b eb fe 48 8b 47 18 49 c7 c4 70 1e 4d 81 48 85 c0 74 04 4c 8b 60 30
  8b 44 24 58 45 31 ed 0f b6 c4 85 c0 74 0d 48 8b 43 28 48 89
 RIP  [&lt;ffffffff81110a9a&gt;] sysfs_create_dir+0x2d/0xae
  RSP &lt;ffff880007b15d78&gt;
 CR2: 0000000000000058
 ---[ end trace aebb1175ce1f6739 ]---

Signed-off-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
Cc: Laurent Vivier &lt;Laurent.Vivier@bull.net&gt;
Cc: stable@kernel.org
Signed-off-by: Jens Axboe &lt;jaxboe@fusionio.com&gt;
</content>
</entry>
</feed>
