Commit 87ee1369 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Li Lingfeng
Browse files

dm snapshot: fix lockup in dm_exception_table_exit

stable inclusion
from stable-v5.4.274
commit e7d4cff57c3c43fdd72342c78d4138f509c7416e
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9Q9CC
CVE: CVE-2024-35805

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=e7d4cff57c3c43fdd72342c78d4138f509c7416e



--------------------------------

[ Upstream commit 6e7132ed3c07bd8a6ce3db4bb307ef2852b322dc ]

There was reported lockup when we exit a snapshot with many exceptions.
Fix this by adding "cond_resched" to the loop that frees the exceptions.

Reported-by: default avatarJohn Pittman <jpittman@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarLi Lingfeng <lilingfeng3@huawei.com>
parent 3e487df5
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -685,8 +685,10 @@ static void dm_exception_table_exit(struct dm_exception_table *et,
	for (i = 0; i < size; i++) {
		slot = et->table + i;

		hlist_bl_for_each_entry_safe(ex, pos, n, slot, hash_list)
		hlist_bl_for_each_entry_safe(ex, pos, n, slot, hash_list) {
			kmem_cache_free(mem, ex);
			cond_resched();
		}
	}

	vfree(et->table);