History

keys: Namespace keyring names

Keyring names are held in a single global list that any process can pick from by means of keyctl_join_session_keyring (provided the keyring grants Search permission). This isn't very container friendly, however. Make the following changes: (1) Make default session, process and thread keyring names begin with a '.' instead of '_'. (2) Keyrings whose names begin with a '.' aren't added to the list. Such keyrings are system specials. (3) Replace the global list with per-user_namespace lists. A keyring adds its name to the list for the user_namespace that it is currently in. (4) When a user_namespace is deleted, it just removes itself from the keyring name list. The global keyring_name_lock is retained for accessing the name lists. This allows (4) to work. This can be tested by: # keyctl newring foo @s 995906392 # unshare -U $ keyctl show ... 995906392 --alswrv 65534 65534 \_ keyring: foo ... $ keyctl session foo Joined session keyring: 935622349 As can be seen, a new session keyring was created. The capability bit KEYCTL_CAPS1_NS_KEYRING_NAME is set if the kernel is employing this feature.

David Howells committed 7 years ago

Commit b206f281 parent dcf49db7 files · +60 −60Browse files

Showing the changes to include/linux (2 of 7 files). Show all

Unified · Split

2 files
  1. include/linux/key.h +2 −0
  2. include/linux/user_namespace.h +5 −0
include/linux/key.h+2−0
@@ -361,6 +361,7 @@ extern void key_set_timeout(struct key *, unsigned); · 360 unmodified lines
361361
362362 extern key_ref_t lookup_user_key(key_serial_t id, unsigned long flags,
363363 key_perm_t perm);
364+extern void key_free_user_ns(struct user_namespace *);
364365
365366 /*
366367 * The permissions required on a key that we're looking up.
@@ -434,6 +435,7 @@ extern void key_init(void); · 67 unmodified lines
434435 #define key_fsuid_changed(c) do { } while(0)
435436 #define key_fsgid_changed(c) do { } while(0)
436437 #define key_init() do { } while(0)
438+#define key_free_user_ns(ns) do { } while(0)
437439
438440 #endif /* CONFIG_KEYS */
439441 #endif /* __KERNEL__ */
include/linux/user_namespace.h+5−0
@@ -64,6 +64,11 @@ struct user_namespace { · 63 unmodified lines
6464 struct ns_common ns;
6565 unsigned long flags;
6666
67+#ifdef CONFIG_KEYS
68+ /* List of joinable keyrings in this namespace */
69+ struct list_head keyring_name_list;
70+#endif
71+
6772 /* Register of per-UID persistent keyrings for this namespace */
6873 #ifdef CONFIG_PERSISTENT_KEYRINGS
6974 struct key *persistent_keyring_register;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t