key_unlink(9)
π key_unlink β ok so we're removing a link bestie
Hey so this is key_unlink(9), a page from the Kernel API Manual β the kernel-key-management lore, iykyk. Grab a snack, we're detaching a key from a keyring and it's literally not that deep. π
β¨ NAME β¨
key_unlink β unlink the first link to a key from a keyring. That's it, that's the whole vibe. π«
β¨ SYNOPSIS β¨
int key_unlink (struct key *keyring , struct key *key );
β¨ ARGUMENTS β¨
keyringβ the keyring we're removing the link from. Like, the group chat you're leaving, not the message. π«Άkeyβ the key that the link points at. The message, in this extremely good analogy.
β¨ DESCRIPTION β¨
Okay so the whole job: remove a link from a keyring to a key. One link. First one. Slay.
Heads up though β this function will write-lock the keyring's semaphore. So like, it's holding the door, nobody else is coming through while it does its thing. Respect the lock bestie. π
Return values, because of course there are return values:
0if it's successful β icon behavior, no notes π-ENOTDIRif the keyring... isn't a keyring?? like you passed the wrong thing entirely π-ENOENTif the key isn't linked to by the keyring β the link you're looking for doesn't exist, ghosted fr fr π»-ENOMEMif there's insufficient memory β the universe said no π«
β οΈ Big important caveat: it is assumed that the caller has already checked that it's permitted for a link to be removed. That means the keyring should have Write permission, and β plot twist β no permissions are required on the key. Do your homework before you call this, okay? Don't make it weird. π
β¨ SEE ALSO β¨
Kernel file ./security/keys/keyring.c
Plus the whole friend group:
key_put_tag(9)key_remove_domain(9)restrict_link_reject(9)keyring_search_rcu(9)keyring_search(9)keyring_restrict(9)key_link(9)key_move(9)keyring_clear(9)
β¨ that's the whole page, you ate that β¨ This little number lives in ./security/keys and it's dated October 2026 β so mark your calendar bestie, and go unlink responsibly ππ¦
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms