<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/md/dm-thin-metadata.c, branch linux-5.8.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.8.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.8.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-09-09T17:14:32Z</updated>
<entry>
<title>dm thin metadata: Fix use-after-free in dm_bm_set_read_only</title>
<updated>2020-09-09T17:14:32Z</updated>
<author>
<name>Ye Bin</name>
</author>
<published>2020-09-01T06:25:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4469ea5972ab9c3064af6dcc0d76c1dfa6bb7913'/>
<id>urn:sha1:4469ea5972ab9c3064af6dcc0d76c1dfa6bb7913</id>
<content type='text'>
commit 3a653b205f29b3f9827a01a0c88bfbcb0d169494 upstream.

The following error ocurred when testing disk online/offline:

[  301.798344] device-mapper: thin: 253:5: aborting current metadata transaction
[  301.848441] device-mapper: thin: 253:5: failed to abort metadata transaction
[  301.849206] Aborting journal on device dm-26-8.
[  301.850489] EXT4-fs error (device dm-26) in __ext4_new_inode:943: Journal has aborted
[  301.851095] EXT4-fs (dm-26): Delayed block allocation failed for inode 398742 at logical offset 181 with max blocks 19 with error 30
[  301.854476] BUG: KASAN: use-after-free in dm_bm_set_read_only+0x3a/0x40 [dm_persistent_data]

Reason is:

 metadata_operation_failed
    abort_transaction
        dm_pool_abort_metadata
	    __create_persistent_data_objects
	        r = __open_or_format_metadata
	        if (r) --&gt; If failed will free pmd-&gt;bm but pmd-&gt;bm not set NULL
		    dm_block_manager_destroy(pmd-&gt;bm);
    set_pool_mode
	dm_pool_metadata_read_only(pool-&gt;pmd);
	dm_bm_set_read_only(pmd-&gt;bm);  --&gt; use-after-free

Add checks to see if pmd-&gt;bm is NULL in dm_bm_set_read_only and
dm_bm_set_read_write functions.  If bm is NULL it means creating the
bm failed and so dm_bm_is_read_only must return true.

Signed-off-by: Ye Bin &lt;yebin10@huawei.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>dm thin metadata: Avoid returning cmd-&gt;bm wild pointer on error</title>
<updated>2020-09-09T17:14:32Z</updated>
<author>
<name>Ye Bin</name>
</author>
<published>2020-09-01T06:25:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b3c76fdbb11988c5775b684980aabc02886e5d41'/>
<id>urn:sha1:b3c76fdbb11988c5775b684980aabc02886e5d41</id>
<content type='text'>
commit 219403d7e56f9b716ad80ab87db85d29547ee73e upstream.

Maybe __create_persistent_data_objects() caller will use PTR_ERR as a
pointer, it will lead to some strange things.

Signed-off-by: Ye Bin &lt;yebin10@huawei.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>dm thin metadata: fix lockdep complaint</title>
<updated>2020-02-27T17:00:53Z</updated>
<author>
<name>Theodore Ts'o</name>
</author>
<published>2020-02-23T19:54:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3918e0667bbac99400b44fa5aef3f8be2eeada4a'/>
<id>urn:sha1:3918e0667bbac99400b44fa5aef3f8be2eeada4a</id>
<content type='text'>
[ 3934.173244] ======================================================
[ 3934.179572] WARNING: possible circular locking dependency detected
[ 3934.185884] 5.4.21-xfstests #1 Not tainted
[ 3934.190151] ------------------------------------------------------
[ 3934.196673] dmsetup/8897 is trying to acquire lock:
[ 3934.201688] ffffffffbce82b18 (shrinker_rwsem){++++}, at: unregister_shrinker+0x22/0x80
[ 3934.210268]
               but task is already holding lock:
[ 3934.216489] ffff92a10cc5e1d0 (&amp;pmd-&gt;root_lock){++++}, at: dm_pool_metadata_close+0xba/0x120
[ 3934.225083]
               which lock already depends on the new lock.

[ 3934.564165] Chain exists of:
                 shrinker_rwsem --&gt; &amp;journal-&gt;j_checkpoint_mutex --&gt; &amp;pmd-&gt;root_lock

For a more detailed lockdep report, please see:

	https://lore.kernel.org/r/20200220234519.GA620489@mit.edu

We shouldn't need to hold the lock while are just tearing down and
freeing the whole metadata pool structure.

Fixes: 44d8ebf436399a4 ("dm thin metadata: use pool locking at end of dm_pool_metadata_close")
Signed-off-by: Theodore Ts'o &lt;tytso@mit.edu&gt;
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
</content>
</entry>
<entry>
<title>dm thin metadata: use pool locking at end of dm_pool_metadata_close</title>
<updated>2020-01-15T01:22:49Z</updated>
<author>
<name>Mike Snitzer</name>
</author>
<published>2020-01-13T16:18:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=44d8ebf436399a40fcd10dd31b29d37823d62fcc'/>
<id>urn:sha1:44d8ebf436399a40fcd10dd31b29d37823d62fcc</id>
<content type='text'>
Ensure that the pool is locked during calls to __commit_transaction and
__destroy_persistent_data_objects.  Just being consistent with locking,
but reality is dm_pool_metadata_close is called once pool is being
destroyed so access to pool shouldn't be contended.

Also, use pmd_write_lock_in_core rather than __pmd_write_lock in
dm_pool_commit_metadata and rename __pmd_write_lock to
pmd_write_lock_in_core -- there was no need for the alias.

In addition, verify that the pool is locked in __commit_transaction().

Fixes: 873f258becca ("dm thin metadata: do not write metadata if no changes occurred")
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
</content>
</entry>
<entry>
<title>dm thin metadata: Fix trivial math error in on-disk format documentation</title>
<updated>2020-01-07T17:07:31Z</updated>
<author>
<name>Jeffle Xu</name>
</author>
<published>2019-12-30T02:54:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4306904053902c7e7827815722f82015dc274ba3'/>
<id>urn:sha1:4306904053902c7e7827815722f82015dc274ba3</id>
<content type='text'>
Signed-off-by: Jeffle Xu &lt;jefflexu@linux.alibaba.com&gt;
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
</content>
</entry>
<entry>
<title>dm thin metadata: use true/false for bool variable</title>
<updated>2020-01-07T17:07:24Z</updated>
<author>
<name>zhengbin</name>
</author>
<published>2019-12-24T06:38:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=63ee92d1c2531008c9e5d73db2f2a1349961b10a'/>
<id>urn:sha1:63ee92d1c2531008c9e5d73db2f2a1349961b10a</id>
<content type='text'>
Fixes coccicheck warning:

drivers/md/dm-thin-metadata.c:814:3-14: WARNING: Assignment of 0/1 to bool variable
drivers/md/dm-thin-metadata.c:1109:1-12: WARNING: Assignment of 0/1 to bool variable
drivers/md/dm-thin-metadata.c:1621:1-12: WARNING: Assignment of 0/1 to bool variable
drivers/md/dm-thin-metadata.c:1652:1-12: WARNING: Assignment of 0/1 to bool variable
drivers/md/dm-thin-metadata.c:1706:1-12: WARNING: Assignment of 0/1 to bool variable

Reported-by: Hulk Robot &lt;hulkci@huawei.com&gt;
Signed-off-by: zhengbin &lt;zhengbin13@huawei.com&gt;
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
</content>
</entry>
<entry>
<title>dm thin metadata: Add support for a pre-commit callback</title>
<updated>2019-12-05T22:05:24Z</updated>
<author>
<name>Nikos Tsironis</name>
</author>
<published>2019-12-04T14:07:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ecda7c0280e6b3398459dc589b9a41c1adb45529'/>
<id>urn:sha1:ecda7c0280e6b3398459dc589b9a41c1adb45529</id>
<content type='text'>
Add support for one pre-commit callback which is run right before the
metadata are committed.

This allows the thin provisioning target to run a callback before the
metadata are committed and is required by the next commit.

Cc: stable@vger.kernel.org
Signed-off-by: Nikos Tsironis &lt;ntsironis@arrikto.com&gt;
Acked-by: Joe Thornber &lt;ejt@redhat.com&gt;
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
</content>
</entry>
<entry>
<title>dm thin metadata: check if in fail_io mode when setting needs_check</title>
<updated>2019-07-02T19:50:08Z</updated>
<author>
<name>Mike Snitzer</name>
</author>
<published>2019-07-02T19:50:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=54fa16ee532705985e6c946da455856f18f63ee1'/>
<id>urn:sha1:54fa16ee532705985e6c946da455856f18f63ee1</id>
<content type='text'>
Check if in fail_io mode at start of dm_pool_metadata_set_needs_check().
Otherwise dm_pool_metadata_set_needs_check()'s superblock_lock() can
crash in dm_bm_write_lock() while accessing the block manager object
that was previously destroyed as part of a failed
dm_pool_abort_metadata() that ultimately set fail_io to begin with.

Also, update DMERR() message to more accurately describe
superblock_lock() failure.

Cc: stable@vger.kernel.org
Reported-by: Zdenek Kabelac &lt;zkabelac@redhat.com&gt;
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
</content>
</entry>
<entry>
<title>dm thin metadata: do not write metadata if no changes occurred</title>
<updated>2019-04-18T20:18:34Z</updated>
<author>
<name>Mike Snitzer</name>
</author>
<published>2019-04-18T14:29:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=873f258becca87f4dd973fe0ba09b88b737c9b14'/>
<id>urn:sha1:873f258becca87f4dd973fe0ba09b88b737c9b14</id>
<content type='text'>
Otherwise, just activating a thin-pool and thin device and then
deactivating them will cause the thin-pool metadata to be changed
(e.g. superblock written) -- even without any metadata being changed.

Add 'in_service' flag to struct dm_pool_metadata and set it in
pmd_write_lock() because all on-disk metadata changes must take a write
lock of pmd-&gt;root_lock.  Once 'in_service' is set it is never cleared.
__commit_transaction() will return 0 if 'in_service' is not set.
dm_pool_commit_metadata() is updated to use __pmd_write_lock() so that
it isn't the sole reason for putting a thin-pool in service.

Also fix dm_pool_commit_metadata() to open the next transaction if the
return from __commit_transaction() is 0.  Not seeing why the early
return ever made since for a return of 0 given that dm-io's async_io(),
as used by bufio, always returns 0.

Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
</content>
</entry>
<entry>
<title>dm thin metadata: add wrappers for managing write locking of metadata</title>
<updated>2019-04-18T20:18:34Z</updated>
<author>
<name>Mike Snitzer</name>
</author>
<published>2019-04-15T20:54:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6a1b1ddc6a2cfb32da8f5e75f1aa053280682a05'/>
<id>urn:sha1:6a1b1ddc6a2cfb32da8f5e75f1aa053280682a05</id>
<content type='text'>
No functional change, but this prepares to hook off of pmd_write_lock()
with additional functionality (as provided in next commit).

Suggested-by: Joe Thornber &lt;ejt@redhat.com&gt;
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
</content>
</entry>
</feed>
