Skip to content

KEYS: Sanitize the garbage collector

Jarkko Sakkinen keyrings linux-cifs linux-integrity linux-nfs linux-s390 linux-security-module lkml netdev stable 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest13 patches 3 repliesIn review
  2. v512 patches 4 repliesSuperseded
  3. v411 patches 1 replySuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v3 RFC11 patches1 replySuperseded
v2 RFC11 patches20 repliesApplied
v1 RFC4 patches8 repliesSuperseded

Changes in v6 from the cover letter

- Split "KEYS: trusted: TEE: Synchronize session lifetime" into two patches:
1. "KEYS: trusted: Update static calls before init"
2. "KEYS: trusted: TEE: Synchronize session lifetime" No actual code changes.

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13KEYS: Add key_gc_flush() for draining RCU callbacksinclude/linux/key.h security/keys/gc.c security/keys/internal.h +1 more+25 -50 replies
2/13dns_resolver: Move the key type into a separate modulenet/Makefile net/dns_resolver/Kconfig net/dns_resolver/Makefile +3 more+92 -630 replies
3/13NFSv4: Clear idmap keyring cache when the last client unloadsfs/nfs/nfs4idmap.c+21 -00 replies
4/13smb: client: Clear idmap/SPNEGO caches when the last session is unloadedfs/smb/client/cifs_spnego.c fs/smb/client/cifsacl.c fs/smb/client/cifsproto.h +1 more+49 -20 replies
5/13s390/cert_store: Start tracking subsystem keysarch/s390/kernel/cert_store.c+67 -940 replies
6/13KEYS: trusted: Update static calls before initsecurity/keys/trusted-keys/trusted_core.c+10 -50 replies
7/13KEYS: trusted: TEE: Synchronize session lifetimesecurity/keys/trusted-keys/trusted_tee.c+65 -210 replies
8/13KEYS: trusted: TEE: Disable sysfs bind attributessecurity/keys/trusted-keys/trusted_tee.c+2 -10 replies
9/13rxrpc: Release conn->key when init_connection_security() failsnet/rxrpc/conn_event.c net/rxrpc/proc.c+7 -20 replies
10/13rxrpc: Move key types to their own moduleDocumentation/networking/rxrpc.rst net/Makefile net/rxrpc/Kconfig +8 more+411 -3430 replies
11/13KEYS: Pin the backing kernel module for a key typeinclude/linux/key-type.h security/keys/gc.c security/keys/key.c +1 more+83 -210 replies
12/13KEYS: Remove key_type_deadsecurity/keys/gc.c security/keys/internal.h security/keys/key.c +1 more+9 -1900 replies
13/13KEYS: key_garbage_collector(): process in chunkssecurity/keys/gc.c security/keys/internal.h security/keys/key.c +1 more+116 -590 replies

Reviews trailers per patch

2 of 13 patches have a Reviewed-by or Acked-by.

PatchSumit Garg
1/13
2/13
3/13
4/13
5/13
6/13
7/13R-b
8/13R-b
9/13
10/13
11/13
12/13
13/13

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [PATCH v6 00/13] KEYS: Sanitize the garbage collector

1. Replace key_type_dead retyping with module reference pinning so live keys and restrictions keep their backing key_type module loaded until key_gc_unused_keys() or keyring_destroy() completes.
2. Process serial-tree scans and graveyard destruction in fixed 64-key chunks to a bound workqueue execution latency without hurting overall throughput for a significant amount.

The first part has a user-space visible effect: rmmod returns -EBUSY while keys or keyring restrictions still pin the backing module.

Internal key caches or transport state bottlenecks are addressed by either clearing their private caches on last-client teardown or splitting key types into dedicated provider modules.

CHANGES
=======

v6:
- Split "KEYS: trusted: TEE: Synchronize session lifetime" into two patches:
1. "KEYS: trusted: Update static calls before init"
2. "KEYS: trusted: TEE: Synchronize session lifetime" No actual code changes.

v5:
- Another round of fixes resolving Sashiko remarks.
- Reordered TEE session lifetime synchronization patch before suppressing sysfs bind attributes.
- Release conn->key in rxrpc_process_event() on init_connection_security() failure
- Update Documentation/networking/rxrpc.rst to reference net/rxrpc/security.c instead of net/rxrpc/server_key.c.
- Store the delay-adjusted reap timestamp in gc->end in key_garbage_collector() instead of recording unadjusted key->expiry and adding key_gc_delay a second time.

v4:
- Replaced WARN_ON() around fallible keyring_clear() in CIFS idmap and SPNEGO cache-clearing helpers with pr_warn_ratelimited().
- Moved key garbage collection from the shared events workqueue onto a dedicated WQ_MEM_RECLAIM | WQ_PERCPU workqueue (key_gc), allocated in key_init(), so WQ_MEM_RECLAIM workers (nfsiod/cifsiod) and reclaim paths can flush key GC safely.

v3:
- Split dns_resolver and rxrpc key types into dedicated provider modules (dns_resolver_key.ko and rxrpc_keys.ko) instead of client refcounting, so cached or retained keys do not pin dns_resolver.ko or rxrpc.ko.
- Dropped the standalone nvme-keyring fix as it was picked up by the subsystem maintainers.
- Hardened key_gc_flush() to serialize against chunked key_gc_work continuations, and fixed a restriction module reference leak on failed keyring instantiation.

v2:
- Used v1 as a test probe for Sashiko to detect the corner cases instead of trying to resolve even the known ones beforehand.
- Converted the client subsystems to be compatible with the module pinning semantics.

VERSIONS
========

- v5:
https://lore.kernel.org/keyrings/[email protected]/#t
- v4:
https://lore.kernel.org/keyrings/[email protected]/
- v3:
https://lore.kernel.org/keyrings/[email protected]/
- v2:
https://lore.kernel.org/linux-integrity/[email protected]/

Cc Alexander Gordeev <[email protected]>
Cc Anna Schumaker <[email protected]>
Cc Bharath SM <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Biggers <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc James Bottomley <[email protected]>
Cc James Morris <[email protected]>
Cc Jarkko Sakkinen <[email protected]>
Cc Marc Dionne <[email protected]>
Cc Mimi Zohar <[email protected]>
Cc Namjae Jeon <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Paul Moore <[email protected]>
Cc Paulo Alcantara <[email protected]>
Cc Ronnie Sahlberg <[email protected]>
Cc "Serge E. Hallyn" <[email protected]>
Cc Shyam Prasad N <[email protected]>
Cc Simon Horman <[email protected]>
Cc Sumit Garg <[email protected]>
Cc Sven Schnelle <[email protected]>
Cc Tom Talpey <[email protected]>
Cc Trond Myklebust <[email protected]>
Cc Vasily Gorbik <[email protected]>

Jarkko Sakkinen (13):
KEYS: Add key_gc_flush() for draining RCU callbacks
dns_resolver: Move the key type into a separate module
NFSv4: Clear idmap keyring cache when the last client unloads
smb: client: Clear idmap/SPNEGO caches when the last session is
unloaded
s390/cert_store: Start tracking subsystem keys
KEYS: trusted: Update static calls before init
KEYS: trusted: TEE: Synchronize session lifetime
KEYS: trusted: TEE: Disable sysfs bind attributes
rxrpc: Release conn->key when init_connection_security() fails
rxrpc: Move key types to their own module
KEYS: Pin the backing kernel module for a key type
KEYS: Remove key_type_dead
KEYS: key_garbage_collector(): process in chunks

 Documentation/networking/rxrpc.rst        |   2 +-
 arch/s390/kernel/cert_store.c             | 161 +++++-------
 fs/nfs/nfs4idmap.c                        |  21 ++
 fs/smb/client/cifs_spnego.c               |  12 +
 fs/smb/client/cifsacl.c                   |  12 +
 fs/smb/client/cifsproto.h                 |   8 +
 fs/smb/client/misc.c                      |  19 +-
 include/linux/key-type.h                  |   6 +-
 include/linux/key.h                       |   2 +
 net/Makefile                              |   4 +-
 net/dns_resolver/Kconfig                  |  15 ++
 net/dns_resolver/Makefile                 |   4 +-
 net/dns_resolver/dns_key.c                |  65 +----
 net/dns_resolver/dns_query.c              |  64 +++++
 net/dns_resolver/internal.h               |   5 -
 net/rxrpc/Kconfig                         |  20 ++
 net/rxrpc/Makefile                        |   7 +-
 net/rxrpc/af_rxrpc.c                      |  19 +-
 net/rxrpc/ar-internal.h                   |  25 +-
 net/rxrpc/conn_event.c                    |   7 +-
 net/rxrpc/key.c                           | 122 +++------
 net/rxrpc/proc.c                          |   2 +-
 net/rxrpc/rxgk.c                          |  66 -----
 net/rxrpc/rxkad.c                         |  47 ----
 net/rxrpc/security.c                      | 184 ++++++++++++++
 net/rxrpc/server_key.c                    | 260 +++++++++++--------
 security/keys/gc.c                        | 289 ++++++++++------------
 security/keys/internal.h                  |   8 +-
 security/keys/key.c                       |  65 +++--
 security/keys/keyring.c                   |  88 +++----
 security/keys/trusted-keys/trusted_core.c |  15 +-
 security/keys/trusted-keys/trusted_tee.c  |  89 +++++--
 32 files changed, 932 insertions(+), 781 deletions(-)

--
2.47.3