mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bradley Morgan <brads@mainlining.org>
To: cui.tao@linux.dev
Cc: brauner@kernel.org, containers@vger.kernel.org,
	cuitao@kylinos.cn, cyphar@cyphar.com, jack@suse.cz,
	kees@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] userns: remove dead key_put() on the create_user_ns() error path
Date: Fri, 28 Aug 2026 12:45:32 +0100	[thread overview]
Message-ID: <8183F79B-615C-4A04-8FAB-C3384AD2F77F@mainlining.org> (raw)
In-Reply-To: <20260828091659.358700-2-cui.tao@linux.dev>

On 28 August 2026 10:16:58 BST, Tao Cui <cui.tao@linux.dev> wrote:
>From: Tao Cui <cuitao@kylinos.cn>
>
>create_user_ns() jumps to fail_keyring when setup_userns_sysctls()
>fails.  At that point ns was freshly allocated with
>kmem_cache_zalloc() and ns->persistent_keyring_register is only ever
>assigned later, lazily, from key_get_persistent()
>(security/keys/persistent.c).  The key_put() therefore always
>receives NULL.
>
>Remove the dead call.
>

Agreed,

Reviewed-by: Bradley Morgan <brads@mainlining.org>

>Signed-off-by: Tao Cui <cuitao@kylinos.cn>
>---
> kernel/user_namespace.c | 3 ---
> 1 file changed, 3 deletions(-)
>
>diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
>index 0bed462e9b2a..e9e04ce167df 100644
>--- a/kernel/user_namespace.c
>+++ b/kernel/user_namespace.c
>@@ -162,9 +162,6 @@ int create_user_ns(struct cred *new)
> 	ns_tree_add(ns);
> 	return 0;
> fail_keyring:
>-#ifdef CONFIG_PERSISTENT_KEYRINGS
>-	key_put(ns->persistent_keyring_register);
>-#endif
> 	ns_common_free(ns);
> fail_free:
> 	kmem_cache_free(user_ns_cachep, ns);
>


--- Thanks!
https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/

  parent reply	other threads:[~2026-08-28 11:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28  9:16 [PATCH 0/2] userns: clean up dead code on error paths Tao Cui
2026-08-28  9:16 ` [PATCH 1/2] userns: remove dead key_put() on the create_user_ns() error path Tao Cui
2026-08-28  9:41   ` Jan Kara
2026-08-28 11:45   ` Bradley Morgan [this message]
2026-08-28  9:16 ` [PATCH 2/2] userns: don't clear the install target map on map_write() failure Tao Cui
2026-08-28  9:51   ` Jan Kara
2026-08-31 10:08     ` Christian Brauner
2026-08-31 13:08       ` Tao Cui
2026-08-28 13:34   ` Bradley Morgan
2026-08-31 10:12 ` (subset) [PATCH 0/2] userns: clean up dead code on error paths Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8183F79B-615C-4A04-8FAB-C3384AD2F77F@mainlining.org \
    --to=brads@mainlining.org \
    --cc=brauner@kernel.org \
    --cc=containers@vger.kernel.org \
    --cc=cui.tao@linux.dev \
    --cc=cuitao@kylinos.cn \
    --cc=cyphar@cyphar.com \
    --cc=jack@suse.cz \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®