Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a38e122 authored by David Howells's avatar David Howells Committed by Linus Torvalds
Browse files

keys: allow the callout data to be passed as a blob rather than a string



Allow the callout data to be passed as a blob rather than a string for
internal kernel services that call any request_key_*() interface other than
request_key().  request_key() itself still takes a NUL-terminated string.

The functions that change are:

	request_key_with_auxdata()
	request_key_async()
	request_key_async_with_auxdata()

Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Cc: Paul Moore <paul.moore@hp.com>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: James Morris <jmorris@namei.org>
Cc: Kevin Coffman <kwc@citi.umich.edu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent dceba994
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -11,26 +11,29 @@ request_key*():

	struct key *request_key(const struct key_type *type,
				const char *description,
				const char *callout_string);
				const char *callout_info);

or:

	struct key *request_key_with_auxdata(const struct key_type *type,
					     const char *description,
					     const char *callout_string,
					     const char *callout_info,
					     size_t callout_len,
					     void *aux);

or:

	struct key *request_key_async(const struct key_type *type,
				      const char *description,
				      const char *callout_string);
				      const char *callout_info,
				      size_t callout_len);

or:

	struct key *request_key_async_with_auxdata(const struct key_type *type,
						   const char *description,
						   const char *callout_string,
						   const char *callout_info,
					     	   size_t callout_len,
						   void *aux);

Or by userspace invoking the request_key system call:
+9 −5
Original line number Diff line number Diff line
@@ -771,7 +771,7 @@ payload contents" for more information.

	struct key *request_key(const struct key_type *type,
				const char *description,
				const char *callout_string);
				const char *callout_info);

    This is used to request a key or keyring with a description that matches
    the description specified according to the key type's match function. This
@@ -793,24 +793,28 @@ payload contents" for more information.

	struct key *request_key_with_auxdata(const struct key_type *type,
					     const char *description,
					     const char *callout_string,
					     const void *callout_info,
					     size_t callout_len,
					     void *aux);

    This is identical to request_key(), except that the auxiliary data is
    passed to the key_type->request_key() op if it exists.
    passed to the key_type->request_key() op if it exists, and the callout_info
    is a blob of length callout_len, if given (the length may be 0).


(*) A key can be requested asynchronously by calling one of:

	struct key *request_key_async(const struct key_type *type,
				      const char *description,
				      const char *callout_string);
				      const void *callout_info,
				      size_t callout_len);

    or:

	struct key *request_key_async_with_auxdata(const struct key_type *type,
						   const char *description,
						   const char *callout_string,
						   const char *callout_info,
					     	   size_t callout_len,
					     	   void *aux);

    which are asynchronous equivalents of request_key() and
+6 −3
Original line number Diff line number Diff line
@@ -208,16 +208,19 @@ extern struct key *request_key(struct key_type *type,

extern struct key *request_key_with_auxdata(struct key_type *type,
					    const char *description,
					    const char *callout_info,
					    const void *callout_info,
					    size_t callout_len,
					    void *aux);

extern struct key *request_key_async(struct key_type *type,
				     const char *description,
				     const char *callout_info);
				     const void *callout_info,
				     size_t callout_len);

extern struct key *request_key_async_with_auxdata(struct key_type *type,
						  const char *description,
						  const char *callout_info,
						  const void *callout_info,
						  size_t callout_len,
						  void *aux);

extern int wait_for_key_construction(struct key *key, bool intr);
+6 −3
Original line number Diff line number Diff line
@@ -109,7 +109,8 @@ extern int install_process_keyring(struct task_struct *tsk);

extern struct key *request_key_and_link(struct key_type *type,
					const char *description,
					const char *callout_info,
					const void *callout_info,
					size_t callout_len,
					void *aux,
					struct key *dest_keyring,
					unsigned long flags);
@@ -120,13 +121,15 @@ extern struct key *request_key_and_link(struct key_type *type,
struct request_key_auth {
	struct key		*target_key;
	struct task_struct	*context;
	char			*callout_info;
	void			*callout_info;
	size_t			callout_len;
	pid_t			pid;
};

extern struct key_type key_type_request_key_auth;
extern struct key *request_key_auth_new(struct key *target,
					const char *callout_info);
					const void *callout_info,
					size_t callout_len);

extern struct key *key_get_instantiation_authkey(key_serial_t target_id);

+5 −2
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@ asmlinkage long sys_request_key(const char __user *_type,
	struct key_type *ktype;
	struct key *key;
	key_ref_t dest_ref;
	size_t callout_len;
	char type[32], *description, *callout_info;
	long ret;

@@ -169,12 +170,14 @@ asmlinkage long sys_request_key(const char __user *_type,

	/* pull the callout info into kernel space */
	callout_info = NULL;
	callout_len = 0;
	if (_callout_info) {
		callout_info = strndup_user(_callout_info, PAGE_SIZE);
		if (IS_ERR(callout_info)) {
			ret = PTR_ERR(callout_info);
			goto error2;
		}
		callout_len = strlen(callout_info);
	}

	/* get the destination keyring if specified */
@@ -195,8 +198,8 @@ asmlinkage long sys_request_key(const char __user *_type,
	}

	/* do the search */
	key = request_key_and_link(ktype, description, callout_info, NULL,
				   key_ref_to_ptr(dest_ref),
	key = request_key_and_link(ktype, description, callout_info,
				   callout_len, NULL, key_ref_to_ptr(dest_ref),
				   KEY_ALLOC_IN_QUOTA);
	if (IS_ERR(key)) {
		ret = PTR_ERR(key);
Loading