From: Tao Cui <cui.tao@linux.dev>
To: brauner@kernel.org
Cc: jack@suse.cz, kees@kernel.org, cyphar@cyphar.com,
containers@vger.kernel.org, linux-kernel@vger.kernel.org,
cuitao@kylinos.cn, cui.tao@linux.dev
Subject: [PATCH 0/2] userns: clean up dead code on error paths
Date: Fri, 28 Aug 2026 17:16:04 +0800 [thread overview]
Message-ID: <20260828091606.358577-1-cui.tao@linux.dev> (raw)
From: Tao Cui <cuitao@kylinos.cn>
Two small cleanups on the create_user_ns() and map_write() error
paths. Both remove code that provably cannot have an effect; no
behavior change.
user_namespace.c:164-167: the key_put() at fail_keyring has been
dead since it was copy-pasted from free_user_ns() in 2016
(dbec28460a89); persistent_keyring_register is only ever assigned
lazily from key_get_persistent(), long after create_user_ns().
user_namespace.c:1110-1112: the map clearing at the out: label of
map_write() only ever zeroes an already-zero map; the destination
map is untouched on every error path, and a second write to a
mapped namespace is rejected before parsing.
Compile-tested and A/B-tested on next-20260827: identical behavior
on vanilla and patched kernels for single-write map failures,
recovery writes and 300 rounds of userns create/destroy.
Tao Cui (2):
userns: remove dead key_put() on the create_user_ns() error path
userns: don't clear the install target map on map_write() failure
kernel/user_namespace.c | 6 ------
1 file changed, 6 deletions(-)
--
2.43.0
next reply other threads:[~2026-08-28 9:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 9:16 Tao Cui [this message]
2026-08-28 9:16 Tao Cui
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=20260828091606.358577-1-cui.tao@linux.dev \
--to=cui.tao@linux.dev \
--cc=brauner@kernel.org \
--cc=containers@vger.kernel.org \
--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®