All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chengfeng Ye <nicoyip.dev@gmail.com>
To: David Howells <dhowells@redhat.com>, Jarkko Sakkinen <jarkko@kernel.org>
Cc: Paul Moore <paul@paul-moore.com>,
	James Morris <jmorris@namei.org>,
	"Serge E . Hallyn" <serge@hallyn.com>,
	keyrings@vger.kernel.org, linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Chengfeng Ye <nicoyip.dev@gmail.com>
Subject: [PATCH v3 0/2] keys: Fix ownership lifetime and accounting races
Date: Mon, 28 Sep 2026 00:25:26 +0800	[thread overview]
Message-ID: <20260927162528.943886-1-nicoyip.dev@gmail.com> (raw)

This series splits the previous bundled fix into two logical changes,
as requested by Jarkko.

Patch 1 protects key_user lifetime while key->user is replaced. It covers
namespace filtering, quota reservation and instantiated-key count updates,
with explicit locking at the affected access sites.

Patch 2 depends on patch 1 and extends the same critical sections so that
quota and instantiated-key accounting move together with ownership.
Notifications and reference release remain outside the spinlock.

The combined code change is identical to v2 applied to the current base.
Patch 1 fixes the lifetime race; the existing accounting races remain until
patch 2 is applied. Each commit has its own explanation and interleaving.

Changes in v3:
- Split v2 into a lifetime fix and an accounting-serialization fix.
- Rebase onto fd179f8a05be (current mainline at preparation time).
- Include a short, explicitly historical instrumented KASAN excerpt in
  patch 1, and add stable trailers for these long-standing bugs.
- Keep explicit lock acquisition at each reader; no locking accessor.

Validation:
- Built the four affected objects after each patch.
- Built the full x86_64 kernel after applying both patches, with KEYS,
  PROC_FS, USER_NS, WATCH_QUEUE and KEY_NOTIFICATIONS enabled.
- Both patches pass checkpatch --strict without errors or warnings.

Previous version:
https://lore.kernel.org/r/20260904080940.575882-1-nicoyip.dev@gmail.com/
Reviewer request:
https://lore.kernel.org/r/aqHhZO0GjMTOer4j@kernel.org/

Chengfeng Ye (2):
  keys: Protect key_user lifetime during ownership changes
  keys: Serialize ownership transfers with key accounting

 security/keys/key.c     | 13 +++++++++++--
 security/keys/keyctl.c  |  4 ++++
 security/keys/keyring.c |  7 ++++++-
 security/keys/proc.c    | 15 +++++++++++++--
 4 files changed, 34 insertions(+), 5 deletions(-)


base-commit: fd179f8a05be3ccae366b9b96e176b51fbe54aab
-- 
2.43.0


             reply	other threads:[~2026-09-27 16:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27 16:25 Chengfeng Ye [this message]
2026-09-27 16:25 ` [PATCH v3 1/2] keys: Protect key_user lifetime during ownership changes Chengfeng Ye
2026-09-27 16:36   ` sashiko-bot
2026-09-29 21:19   ` Jarkko Sakkinen
2026-10-05  0:58   ` Jarkko Sakkinen
2026-09-27 16:25 ` [PATCH v3 2/2] keys: Serialize ownership transfers with key accounting Chengfeng Ye
2026-09-27 16:33   ` sashiko-bot
2026-09-29 21:20   ` Jarkko Sakkinen
2026-10-05  2:17   ` Jarkko Sakkinen
2026-10-05  2:49     ` Jarkko Sakkinen
2026-10-05  5:53       ` Chengfeng Ye
2026-10-05  6:39         ` Jarkko Sakkinen

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=20260927162528.943886-1-nicoyip.dev@gmail.com \
    --to=nicoyip.dev@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=jarkko@kernel.org \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=serge@hallyn.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.