key_move(9)
π key_move(9) β like, the actual manual page, bestie
okay so this is key_move(9) from the Kernel API Manual, and honestly? it's giving "small function, big responsibilities." it moves a key from one keyring to another. that's the whole vibe. let's get into it π
β¨ NAME β¨
key_move β move a key from one keyring to another. yes, literally that. no crumbs left behind π¦
πΈ SYNOPSIS πΈ
int key_move (struct key *key , struct key *from_keyring , struct key
*to_keyring , unsigned int flags );
look at her. four parameters. one int return. main character energy fr fr π
π ARGUMENTS π
keyβ the key we're moving. the little guy in question π₯Ίfrom_keyringβ the keyring we're removing the link from. she's losing a link today, it's fine, she'll recover πto_keyringβ the keyring we're making the link in. she's gaining one. slay.flagsβ qualifying flags, likeKEYCTL_MOVE_EXCL. the "qualifying" is doing a lot of work there ngl β¨
π¦ DESCRIPTION π¦
so what actually happens? key_move makes a link in to_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 β and simultaneously removes a link to the key from from_keyring. one motion, two outcomes, iconic behaviour honestly π₯
this function will write-lock both keyring's semaphores and will consume some of the user's key data quota to hold the link on to to_keyring. so yeah, it's not free. budget accordingly π
returns 0 if successful. and if it's not successful, here's the whole mood board of error codes:
-ENOTDIRβ if either keyring isn't a keyring. like bestie, that's not a keyring π-EKEYREVOKEDβ if either keyring has been revoked. oop.-ENFILEβ if the second keyring is full. no room, no vibes π-EDQUOTβ if there is insufficient key data quota remaining to add another link. the quota said no π-ENOMEMβ if there's insufficient memory. classic.-EEXISTβ only ifKEYCTL_MOVE_EXCLis set, and only if there's already a matching key into_keyring. exclusivity is a boundary, respect it π
also important, and i'm not being cute about this one: it is assumed that the caller has checked that it is permitted for a link to be made. meaning the keyring should have Write permission and the key needs Link permission. the function is not doing that check for you β that's your job, bestie π«Ά
π SEE ALSO π
go read these next, they're all part of the same friend group:
- Kernel file
./security/keys/keyring.c 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_unlink(9)keyring_clear(9)
β okay that's the page!! sourced from ./security/keys, dated October 2026 β so like, future-dated documentation, we love a forward-thinking queen. bye bestie, go move some keys ππ§
π¦ 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