<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/block/loop.c, branch v5.1</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.1</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.1'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2019-03-18T14:20:53Z</updated>
<entry>
<title>loop: access lo_backing_file only when the loop device is Lo_bound</title>
<updated>2019-03-18T14:20:53Z</updated>
<author>
<name>Dongli Zhang</name>
<email>dongli.zhang@oracle.com</email>
</author>
<published>2019-03-18T12:23:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f7c8a4120eedf24c36090b7542b179ff7a649219'/>
<id>urn:sha1:f7c8a4120eedf24c36090b7542b179ff7a649219</id>
<content type='text'>
Commit 758a58d0bc67 ("loop: set GENHD_FL_NO_PART_SCAN after
blkdev_reread_part()") separates "lo-&gt;lo_backing_file = NULL" and
"lo-&gt;lo_state = Lo_unbound" into different critical regions protected by
loop_ctl_mutex.

However, there is below race that the NULL lo-&gt;lo_backing_file would be
accessed when the backend of a loop is another loop device, e.g., loop0's
backend is a file, while loop1's backend is loop0.

loop0's backend is file            loop1's backend is loop0

__loop_clr_fd()
  mutex_lock(&amp;loop_ctl_mutex);
  lo-&gt;lo_backing_file = NULL; --&gt; set to NULL
  mutex_unlock(&amp;loop_ctl_mutex);
                                   loop_set_fd()
                                     mutex_lock_killable(&amp;loop_ctl_mutex);
                                     loop_validate_file()
                                       f = l-&gt;lo_backing_file; --&gt; NULL
                                         access if loop0 is not Lo_unbound
  mutex_lock(&amp;loop_ctl_mutex);
  lo-&gt;lo_state = Lo_unbound;
  mutex_unlock(&amp;loop_ctl_mutex);

lo-&gt;lo_backing_file should be accessed only when the loop device is
Lo_bound.

In fact, the problem has been introduced already in commit 7ccd0791d985
("loop: Push loop_ctl_mutex down into loop_clr_fd()") after which
loop_validate_file() could see devices in Lo_rundown state with which it
did not count. It was harmless at that point but still.

Fixes: 7ccd0791d985 ("loop: Push loop_ctl_mutex down into loop_clr_fd()")
Reported-by: syzbot+9bdc1adc1c55e7fe765b@syzkaller.appspotmail.com
Signed-off-by: Dongli Zhang &lt;dongli.zhang@oracle.com&gt;
Reviewed-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>loop: set GENHD_FL_NO_PART_SCAN after blkdev_reread_part()</title>
<updated>2019-02-22T22:51:22Z</updated>
<author>
<name>Dongli Zhang</name>
<email>dongli.zhang@oracle.com</email>
</author>
<published>2019-02-22T14:10:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=758a58d0bc67457f1215321a536226654a830eeb'/>
<id>urn:sha1:758a58d0bc67457f1215321a536226654a830eeb</id>
<content type='text'>
Commit 0da03cab87e6
("loop: Fix deadlock when calling blkdev_reread_part()") moves
blkdev_reread_part() out of the loop_ctl_mutex. However,
GENHD_FL_NO_PART_SCAN is set before __blkdev_reread_part(). As a result,
__blkdev_reread_part() will fail the check of GENHD_FL_NO_PART_SCAN and
will not rescan the loop device to delete all partitions.

Below are steps to reproduce the issue:

step1 # dd if=/dev/zero of=tmp.raw bs=1M count=100
step2 # losetup -P /dev/loop0 tmp.raw
step3 # parted /dev/loop0 mklabel gpt
step4 # parted -a none -s /dev/loop0 mkpart primary 64s 1
step5 # losetup -d /dev/loop0

Step5 will not be able to delete /dev/loop0p1 (introduced by step4) and
there is below kernel warning message:

[  464.414043] __loop_clr_fd: partition scan of loop0 failed (rc=-22)

This patch sets GENHD_FL_NO_PART_SCAN after blkdev_reread_part().

Fixes: 0da03cab87e6 ("loop: Fix deadlock when calling blkdev_reread_part()")
Signed-off-by: Dongli Zhang &lt;dongli.zhang@oracle.com&gt;
Reviewed-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>loop: do not print warn message if partition scan is successful</title>
<updated>2019-02-22T22:51:21Z</updated>
<author>
<name>Dongli Zhang</name>
<email>dongli.zhang@oracle.com</email>
</author>
<published>2019-02-22T14:10:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=40853d6fc619a6fd3d3177c3973a2eac9b598a80'/>
<id>urn:sha1:40853d6fc619a6fd3d3177c3973a2eac9b598a80</id>
<content type='text'>
Do not print warn message when the partition scan returns 0.

Fixes: d57f3374ba48 ("loop: Move special partition reread handling in loop_clr_fd()")
Signed-off-by: Dongli Zhang &lt;dongli.zhang@oracle.com&gt;
Reviewed-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>block: kill BLK_MQ_F_SG_MERGE</title>
<updated>2019-02-15T15:40:12Z</updated>
<author>
<name>Ming Lei</name>
<email>ming.lei@redhat.com</email>
</author>
<published>2019-02-15T11:13:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=56d18f62f556b80105e38e7975975cf7465aae3e'/>
<id>urn:sha1:56d18f62f556b80105e38e7975975cf7465aae3e</id>
<content type='text'>
QUEUE_FLAG_NO_SG_MERGE has been killed, so kill BLK_MQ_F_SG_MERGE too.

Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Omar Sandoval &lt;osandov@fb.com&gt;
Signed-off-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>block: loop: pass multi-page bvec to iov_iter</title>
<updated>2019-02-15T15:40:11Z</updated>
<author>
<name>Ming Lei</name>
<email>ming.lei@redhat.com</email>
</author>
<published>2019-02-15T11:13:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=86af5952a8470f96b53830372c64469cb7ce780c'/>
<id>urn:sha1:86af5952a8470f96b53830372c64469cb7ce780c</id>
<content type='text'>
iov_iter is implemented on bvec itererator helpers, so it is safe to pass
multi-page bvec to it, and this way is much more efficient than passing one
page in each bvec.

Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Omar Sandoval &lt;osandov@fb.com&gt;
Signed-off-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<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>
</feed>
