<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/block/loop.c, branch v5.0</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v5.0</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.0'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2019-01-10T03:51:44Z</updated>
<entry>
<title>loop: drop caches if offset or block_size are changed</title>
<updated>2019-01-10T03:51:44Z</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk@kernel.org</email>
</author>
<published>2019-01-10T03:17:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5db470e229e22b7eda6e23b5566e532c96fb5bc3'/>
<id>urn:sha1:5db470e229e22b7eda6e23b5566e532c96fb5bc3</id>
<content type='text'>
If we don't drop caches used in old offset or block_size, we can get old data
from new offset/block_size, which gives unexpected data to user.

For example, Martijn found a loopback bug in the below scenario.
1) LOOP_SET_FD loads first two pages on loop file
2) LOOP_SET_STATUS64 changes the offset on the loop file
3) mount is failed due to the cached pages having wrong superblock

Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: linux-block@vger.kernel.org
Reported-by: Martijn Coenen &lt;maco@google.com&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>block: loop: remove redundant code</title>
<updated>2018-12-22T21:45:31Z</updated>
<author>
<name>Chengguang Xu</name>
<email>cgxu519@gmx.com</email>
</author>
<published>2018-12-22T12:47:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c41103691b7fc4fda11f74a90a4fbd9d265c8cc9'/>
<id>urn:sha1:c41103691b7fc4fda11f74a90a4fbd9d265c8cc9</id>
<content type='text'>
Code cleanup for removing redundant break in switch case.

Signed-off-by: Chengguang Xu &lt;cgxu519@gmx.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>block: loop: check error using IS_ERR instead of IS_ERR_OR_NULL in loop_add()</title>
<updated>2018-12-16T16:01:38Z</updated>
<author>
<name>Chengguang Xu</name>
<email>cgxu519@gmx.com</email>
</author>
<published>2018-12-16T09:35:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=38a3499f6d0cb15bd673e517b0656807e22bfd24'/>
<id>urn:sha1:38a3499f6d0cb15bd673e517b0656807e22bfd24</id>
<content type='text'>
blk_mq_init_queue() will not return NULL pointer to its caller,
so it's better to replace IS_ERR_OR_NULL using IS_ERR in loop_add().

If in the future things change to check NULL pointer inside loop_add(),
we should return -ENOMEM as return code instead of PTR_ERR(NULL).

Signed-off-by: Chengguang Xu &lt;cgxu519@gmx.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>blkcg: remove bio-&gt;bi_css and instead use bio-&gt;bi_blkg</title>
<updated>2018-12-08T05:26:37Z</updated>
<author>
<name>Dennis Zhou</name>
<email>dennis@kernel.org</email>
</author>
<published>2018-12-05T17:10:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=db6638d7d177a8bc74c9e539e2e0d7d061c767b1'/>
<id>urn:sha1:db6638d7d177a8bc74c9e539e2e0d7d061c767b1</id>
<content type='text'>
Prior patches ensured that any bio that interacts with a request_queue
is properly associated with a blkg. This makes bio-&gt;bi_css unnecessary
as blkg maintains a reference to blkcg already.

This removes the bio field bi_css and transfers corresponding uses to
access via bi_blkg.

Signed-off-by: Dennis Zhou &lt;dennis@kernel.org&gt;
Reviewed-by: Josef Bacik &lt;josef@toxicpanda.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>loop: Fix double mutex_unlock(&amp;loop_ctl_mutex) in loop_control_ioctl()</title>
<updated>2018-11-12T15:44:06Z</updated>
<author>
<name>Tetsuo Handa</name>
<email>penguin-kernel@I-love.SAKURA.ne.jp</email>
</author>
<published>2018-11-12T15:42:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=628bd85947091830a8c4872adfd5ed1d515a9cf2'/>
<id>urn:sha1:628bd85947091830a8c4872adfd5ed1d515a9cf2</id>
<content type='text'>
Commit 0a42e99b58a20883 ("loop: Get rid of loop_index_mutex") forgot to
remove mutex_unlock(&amp;loop_ctl_mutex) from loop_control_ioctl() when
replacing loop_index_mutex with loop_ctl_mutex.

Fixes: 0a42e99b58a20883 ("loop: Get rid of loop_index_mutex")
Reported-by: syzbot &lt;syzbot+c0138741c2290fc5e63f@syzkaller.appspotmail.com&gt;
Reviewed-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Reviewed-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Tetsuo Handa &lt;penguin-kernel@I-love.SAKURA.ne.jp&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>loop: Get rid of 'nested' acquisition of loop_ctl_mutex</title>
<updated>2018-11-08T13:30:37Z</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2018-11-08T13:01:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c28445fa06a3a54e06938559b9514c5a7f01c90f'/>
<id>urn:sha1:c28445fa06a3a54e06938559b9514c5a7f01c90f</id>
<content type='text'>
The nested acquisition of loop_ctl_mutex (-&gt;lo_ctl_mutex back then) has
been introduced by commit f028f3b2f987e "loop: fix circular locking in
loop_clr_fd()" to fix lockdep complains about bd_mutex being acquired
after lo_ctl_mutex during partition rereading. Now that these are
properly fixed, let's stop fooling lockdep.

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>loop: Avoid circular locking dependency between loop_ctl_mutex and bd_mutex</title>
<updated>2018-11-08T13:30:36Z</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2018-11-08T13:01:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1dded9acf6dc9a34cd27fcf8815507e4e65b3c4f'/>
<id>urn:sha1:1dded9acf6dc9a34cd27fcf8815507e4e65b3c4f</id>
<content type='text'>
Code in loop_change_fd() drops reference to the old file (and also the
new file in a failure case) under loop_ctl_mutex. Similarly to a
situation in loop_set_fd() this can create a circular locking dependency
if this was the last reference holding the file open. Delay dropping of
the file reference until we have released loop_ctl_mutex.

Reported-by: Tetsuo Handa &lt;penguin-kernel@i-love.sakura.ne.jp&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>loop: Fix deadlock when calling blkdev_reread_part()</title>
<updated>2018-11-08T13:30:32Z</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2018-11-08T13:01:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0da03cab87e6323ff2e05b14bc7d5c6fcc531efd'/>
<id>urn:sha1:0da03cab87e6323ff2e05b14bc7d5c6fcc531efd</id>
<content type='text'>
Calling blkdev_reread_part() under loop_ctl_mutex causes lockdep to
complain about circular lock dependency between bdev-&gt;bd_mutex and
lo-&gt;lo_ctl_mutex. The problem is that on loop device open or close
lo_open() and lo_release() get called with bdev-&gt;bd_mutex held and they
need to acquire loop_ctl_mutex. OTOH when loop_reread_partitions() is
called with loop_ctl_mutex held, it will call blkdev_reread_part() which
acquires bdev-&gt;bd_mutex. See syzbot report for details [1].

Move call to blkdev_reread_part() in __loop_clr_fd() from under
loop_ctl_mutex to finish fixing of the lockdep warning and the possible
deadlock.

[1] https://syzkaller.appspot.com/bug?id=bf154052f0eea4bc7712499e4569505907d1588

Reported-by: syzbot &lt;syzbot+4684a000d5abdade83fac55b1e7d1f935ef1936e@syzkaller.appspotmail.com&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>loop: Move loop_reread_partitions() out of loop_ctl_mutex</title>
<updated>2018-11-08T13:30:31Z</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2018-11-08T13:01:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=85b0a54a82e4fbceeb1aebb7cb6909edd1a24668'/>
<id>urn:sha1:85b0a54a82e4fbceeb1aebb7cb6909edd1a24668</id>
<content type='text'>
Calling loop_reread_partitions() under loop_ctl_mutex causes lockdep to
complain about circular lock dependency between bdev-&gt;bd_mutex and
lo-&gt;lo_ctl_mutex. The problem is that on loop device open or close
lo_open() and lo_release() get called with bdev-&gt;bd_mutex held and they
need to acquire loop_ctl_mutex. OTOH when loop_reread_partitions() is
called with loop_ctl_mutex held, it will call blkdev_reread_part() which
acquires bdev-&gt;bd_mutex. See syzbot report for details [1].

Move all calls of loop_rescan_partitions() out of loop_ctl_mutex to
avoid lockdep warning and fix deadlock possibility.

[1] https://syzkaller.appspot.com/bug?id=bf154052f0eea4bc7712499e4569505907d1588

Reported-by: syzbot &lt;syzbot+4684a000d5abdade83fac55b1e7d1f935ef1936e@syzkaller.appspotmail.com&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>loop: Move special partition reread handling in loop_clr_fd()</title>
<updated>2018-11-08T13:30:30Z</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2018-11-08T13:01:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d57f3374ba4817f7c8d26fae8a13d20ac8d31b92'/>
<id>urn:sha1:d57f3374ba4817f7c8d26fae8a13d20ac8d31b92</id>
<content type='text'>
The call of __blkdev_reread_part() from loop_reread_partition() happens
only when we need to invalidate partitions from loop_release(). Thus
move a detection for this into loop_clr_fd() and simplify
loop_reread_partition().

This makes loop_reread_partition() safe to use without loop_ctl_mutex
because we use only lo-&gt;lo_number and lo-&gt;lo_file_name in case of error
for reporting purposes (thus possibly reporting outdate information is
not a big deal) and we are safe from 'lo' going away under us by
elevated lo-&gt;lo_refcnt.

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
</feed>
