Skip to content

Commit

Permalink
security/keys: export key_lookup()
Browse files Browse the repository at this point in the history
For in-kernel consumers one cannot readily assign a user (eg when
running from a workqueue), so the normal key search permissions
cannot be applied.
This patch exports the 'key_lookup()' function for a simple lookup
of keys without checking for permissions.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
  • Loading branch information
Hannes Reinecke authored and Keith Busch committed Oct 11, 2023
1 parent 501cc6f commit 037c343
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ extern void key_init(void);
#define key_init() do { } while(0)
#define key_free_user_ns(ns) do { } while(0)
#define key_remove_domain(d) do { } while(0)
#define key_lookup(k) NULL

#endif /* CONFIG_KEYS */
#endif /* __KERNEL__ */
Expand Down
1 change: 1 addition & 0 deletions security/keys/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ struct key *key_lookup(key_serial_t id)
spin_unlock(&key_serial_lock);
return key;
}
EXPORT_SYMBOL(key_lookup);

/*
* Find and lock the specified key type against removal.
Expand Down

0 comments on commit 037c343

Please sign in to comment.