KEYCTL_SESSION_TO_PARENT(2const)

πŸ’… KEYCTL_SESSION_TO_PARENT β€” like, the parent's session keyring glow-up

okay bestie, gather round, because this is a keyctl(2) operation and it's giving main character energy but like, for your parent process. Yes. Your parent. We're doing nepotism but for keyrings. πŸŽ€

Manual page: KEYCTL_SESSION_TO_PARENT(2const) β€” it lives in the const neighborhood of the keyctl pages, iykyk. πŸ¦‹


✨ NAME ✨

KEYCTL_SESSION_TO_PARENT β€” set the parent process's session keyring. That's it, that's the whole job. πŸ’–


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc). The classic. The blueprint. πŸ‘‘


🌸 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_SESSION_TO_PARENT);

note: this is a raw syscall situation, no cute little libc wrapper, so you're literally calling syscall() yourself like the independent icon you are. no cap. πŸ’…


πŸ’« DESCRIPTION πŸ’«

so here's the tea: this operation replaces the session keyring that the parent of the calling process subscribes to with the session keyring of the calling process. like, your parent's keyring? boom. swapped for yours. slay.

and here's the wild part β€” the keyring gets replaced in the parent process at the point where the parent next transitions from kernel space to user space. so it's not instant-instant, it's ✨ scheduled ✨. your parent will find out. eventually. πŸ™ˆ

now, the requirements. and bestie, there are requirements:

  • The keyring must exist.
  • It must grant the caller link permission.
  • The parent process must be single-threaded.
  • The parent must have the same effective ownership as this process.
  • The parent must not be set-user-ID or set-group-ID.
  • The UID of the parent process's existing session keyring (f it has one), as well as the UID of the caller's session keyring much match the caller's effective UID.

so basically: single-threaded parent, matching ownership, no set-user-ID or set-group-ID shenanigans, and the UIDs have to line up like a perfectly curated outfit. miss one and it's a no from the kernel. πŸ’€

and why is it the parent that's affected? the whole point is that it lets a program such as the shell start a child process that uses this operation to change the shell's own session keyring. so the kid goes out, does the thing, and comes back and fixes the parent's whole vibe. (This is what the keyctl(1) new_session command does.) fr fr, it's a family business. 🫢


πŸ”₯ RETURN VALUE πŸ”₯

  • On success, 0 is returned. πŸŽ‰
  • On error, -1 is returned, and errno is set to indicate the error. 😭

πŸ’€ ERRORS πŸ’€

every single one of these is EPERM, and honestly? it's giving strict parent energy. (and yes, "parent" is doing double duty here, I know, iconic.)

  • EPERM β€” All of the UIDs (GIDs) of the parent process do not match the effective UID (GID) of the calling process.
  • EPERM β€” The UID of the parent's existing session keyring or the UID of the caller's session keyring did not match the effective UID of the caller.
  • EPERM β€” The parent process is not single-threaded.
  • EPERM β€” The parent process is init(1) or a kernel thread.
⚠️ bestie, notice that init(1) and kernel threads are straight-up off limits. do not even try it. that's not your parent, that's everyone's parent. 🚫

πŸ¦‹ VERSIONS πŸ¦‹

A wrapper is provided in the libkeyutils library: keyctl_session_to_parent(3) β€” so if you don't wanna hand-roll the syscall, there's a glowier path. ✨


🌈 STANDARDS 🌈

Linux. just Linux. periodt. 🐧


⭐ HISTORY ⭐

Linux 2.6.32. an elder. a legend. lowkey a vintage. πŸŽ€


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page bestie!! πŸ’– this was Linux man-pages 6.20, dated 2026-02-08 β€” so you know it's fresh, so you know it's slay. go set that parent's session keyring, but only if it's single-threaded, 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