key_link(9)
π key_link β like, the kernel API manual, but make it make sense β¨
okay so bestie, welcome to key_link(9) from the Kernel API Manual π β this is the page where the kernel learns how to introduce two of its little guys to each other. it's giving matchmaker energy fr fr π
β¨ NAME β¨
key_link β Link a key to a keyring π¦
like... literally that. that's the whole assignment. link a key to a keyring. no cap π
πΈ SYNOPSIS πΈ
int key_link (struct key *keyring , struct key *key );
two pointer arguments, one int coming back at you β classic signature behavior, we love to see it π
π ARGUMENTS π
keyringβ the keyring you're making the link in. the destination. the vibe. the group chat the key is getting added to π«Άkeyβ the key you're linking to. the new member. the main character being introduced π
π DESCRIPTION π
so what actually happens π β this function makes a link in a keyring to a key, such that the keyring holds a reference on that key and the key can potentially be found by searching that keyring. lowkey important detail: "potentially" β that's the manpage's word, not mine, so don't come for me π
heads up on the side effects, because there are some and they're real:
- this function is gonna write-lock the keyring's semaphore π β yes, it takes the lock, yes, that's normal, breathe
- it also consumes some of the user's key data quota to hold the link π so like... it's not free, bestie, there's a budget and you're spending from it
β return values, aka the vibe check β
0β slay, it worked, successful π-ENOTDIRβ the keyring isn't a keyring π like, wrong type entirely-EKEYREVOKEDβ the keyring has been revoked π it's over, it's done-ENFILEβ the keyring is full π« there's no room at the inn-EDQUOTβ insufficient key data quota remaining to add another link π the budget said no-ENOMEMβ insufficient memory π§ π₯ out of RAM, out of luck
β οΈ okay important caveat time, pay attention bestie: it is assumed that the caller has checked that it is permitted for a link to be made β the keyring should have Write permission and the key Link permission. that's on you, not on this function. it's not gonna do the permission check for you, it's not your mom π do your homework before you call it, fr fr β¨
π SEE ALSO π
the whole friend group, in the order the page listed them π«Ά
Kernel file ./security/keys/keyring.c, then:
key_put_tag(9)key_remove_domain(9)restrict_link_reject(9)keyring_search_rcu(9)keyring_search(9)keyring_restrict(9)key_unlink(9)key_move(9)keyring_clear(9)
go read all of them, i'll wait π π
π§ cute little sign-off π§
this gem lives under ./security/keys, dated October 2026, and it's page key_link(9) of the Kernel API Manual β mwah, bye bestie, go link some keys 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