mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-21 06:01:23 +00:00
KEYS: Add invalidation support
Add support for invalidating a key - which renders it immediately invisible to further searches and causes the garbage collector to immediately wake up, remove it from keyrings and then destroy it when it's no longer referenced. It's better not to do this with keyctl_revoke() as that marks the key to start returning -EKEYREVOKED to searches when what is actually desired is to have the key refetched. To invalidate a key the caller must be granted SEARCH permission by the key. This may be too strict. It may be better to also permit invalidation if the caller has any of READ, WRITE or SETATTR permission. The primary use for this is to evict keys that are cached in special keyrings, such as the DNS resolver or an ID mapper. Signed-off-by: David Howells <dhowells@redhat.com>
This commit is contained in:
parent
31d5a79d7f
commit
fd75815f72
11 changed files with 131 additions and 28 deletions
|
@ -160,6 +160,7 @@ struct key {
|
|||
#define KEY_FLAG_USER_CONSTRUCT 4 /* set if key is being constructed in userspace */
|
||||
#define KEY_FLAG_NEGATIVE 5 /* set if key is negative */
|
||||
#define KEY_FLAG_ROOT_CAN_CLEAR 6 /* set if key can be cleared by root without permission */
|
||||
#define KEY_FLAG_INVALIDATED 7 /* set if key has been invalidated */
|
||||
|
||||
/* the description string
|
||||
* - this is used to match a key against search criteria
|
||||
|
@ -203,6 +204,7 @@ extern struct key *key_alloc(struct key_type *type,
|
|||
#define KEY_ALLOC_NOT_IN_QUOTA 0x0002 /* not in quota */
|
||||
|
||||
extern void key_revoke(struct key *key);
|
||||
extern void key_invalidate(struct key *key);
|
||||
extern void key_put(struct key *key);
|
||||
|
||||
static inline struct key *key_get(struct key *key)
|
||||
|
@ -323,6 +325,7 @@ extern void key_init(void);
|
|||
#define key_serial(k) 0
|
||||
#define key_get(k) ({ NULL; })
|
||||
#define key_revoke(k) do { } while(0)
|
||||
#define key_invalidate(k) do { } while(0)
|
||||
#define key_put(k) do { } while(0)
|
||||
#define key_ref_put(k) do { } while(0)
|
||||
#define make_key_ref(k, p) NULL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue