This is a note to let you know that I've just added the patch titled selinux: fix bad cleanup on error in hashtab_duplicate() to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: selinux-fix-bad-cleanup-on-error-in-hashtab_duplicate.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 6254bd3db316c9ccb3b05caa8b438be63245466f Mon Sep 17 00:00:00 2001 From: Ondrej Mosnacek <omosnace@xxxxxxxxxx> Date: Tue, 17 May 2022 14:08:16 +0200 Subject: selinux: fix bad cleanup on error in hashtab_duplicate() From: Ondrej Mosnacek <omosnace@xxxxxxxxxx> commit 6254bd3db316c9ccb3b05caa8b438be63245466f upstream. The code attempts to free the 'new' pointer using kmem_cache_free(), which is wrong because this function isn't responsible of freeing it. Instead, the function should free new->htable and clear the contents of *new (to prevent double-free). Cc: stable@xxxxxxxxxxxxxxx Fixes: c7c556f1e81b ("selinux: refactor changing booleans") Reported-by: Wander Lairson Costa <wander@xxxxxxxxxx> Signed-off-by: Ondrej Mosnacek <omosnace@xxxxxxxxxx> Signed-off-by: Paul Moore <paul@xxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- security/selinux/ss/hashtab.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/security/selinux/ss/hashtab.c +++ b/security/selinux/ss/hashtab.c @@ -178,7 +178,8 @@ int hashtab_duplicate(struct hashtab *ne kmem_cache_free(hashtab_node_cachep, cur); } } - kmem_cache_free(hashtab_node_cachep, new); + kfree(new->htable); + memset(new, 0, sizeof(*new)); return -ENOMEM; } Patches currently in stable-queue which might be from omosnace@xxxxxxxxxx are queue-5.15/crypto-qcom-rng-fix-infinite-loop-on-requests-not-multiple-of-word_sz.patch queue-5.15/selinux-fix-bad-cleanup-on-error-in-hashtab_duplicate.patch