KEYCTL_INVALIDATE(2const)

๐Ÿ’… KEYCTL_INVALIDATE (it's a 2const page, bestie)

okay so welcome to the group chat, we're talking about KEYCTL_INVALIDATE from the linux/keyctl.h cinematic universe ๐ŸŽ€

โœจ NAME โœจ

KEYCTL_INVALIDATE โ€” invalidate a key. that's it. that's the whole job. she ghosts the key ๐Ÿ’€

๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C library (libc, -lc) โ€” the classic, the icon, the one you already have ๐Ÿซถ

๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <linux/keyctl.h>  /* Definition of KEY* constants */
#include <sys/syscall.h>   /* Definition of SYS_* constants */
#include <unistd.h>

long syscall(SYS_keyctl, KEYCTL_INVALIDATE, key_serial_t key);

no cap, that's the whole summoning circle ๐Ÿ”ฎ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so picture this: you have a key, and you want it marked as invalid. That's the vibe. That's the function.

The ID of the key you're about to send to the shadow realm is specified in key โœจ

But here's the thing, bestie โ€” to invalidate a key, the caller must have search permission on the key. no permission, no invalidation, no exceptions. it's giving "you can't sit with us" ๐Ÿšซ

So when you do call it: this operation marks the key as invalid and schedules immediate garbage collection. The garbage collector then:

  • removes the invalidated key from all keyrings ๐ŸŒˆ
  • deletes the key when its reference count reaches zero ๐Ÿ’€

And after this operation, the key will be ignored by all searches, even if it hasn't actually been deleted yet. She's out of the search results already, she just hasn't finished packing her bags ๐Ÿงณ

Keys that are marked invalid become invisible to normal key operations immediately, though โ€” plot twist โ€” they are still visible in /proc/keys (marked with an 'i' flag) until they are actually removed. so she's gone but the receipts are still there ๐Ÿ™ˆ

fr fr: invisible to operations โ‰  deleted. the 'i' flag is your only warning in /proc/keys.

๐Ÿ”ฅ RETURN VALUE ๐Ÿ”ฅ

  • On success, 0 is returned. slay. โœจ
  • On error, -1 is returned, and errno is set to indicate the error. ๐Ÿ˜ญ

โญ VERSIONS โญ

A wrapper is provided in the libkeyutils library: keyctl_invalidate(3). use it if you don't wanna hand-roll the syscall, iykyk ๐Ÿ’…

๐Ÿ‘‘ STANDARDS ๐Ÿ‘‘

Linux. just Linux. that's the standard. periodt ๐Ÿซถ

๐ŸŽ€ HISTORY ๐ŸŽ€

Linux 3.5 โ€” she's been iconic since 2012-ish, we stan a legacy queen ๐ŸŒธ

๐Ÿ’œ SEE ALSO ๐Ÿ’œ


and that's the page, bestie ๐Ÿ’– this came to you courtesy of Linux man-pages 6.20, dated 2026-02-08 โ€” go invalidate something (respectfully), mwah ๐Ÿซถโœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms