aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-05-19 12:21:36 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-19 12:21:36 -0400
commitf4f27d0028aabce57e44c16c2fdefccd6310d2f3 (patch)
tree09f25601316d22b64165c19042da51c101bde3c4 /include
parent2600a46ee0ed57c0e0a382c2a37ebac64d374d20 (diff)
parentb937190c40de0f6f07f592042e3097b16c6b0130 (diff)
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security subsystem updates from James Morris: "Highlights: - A new LSM, "LoadPin", from Kees Cook is added, which allows forcing of modules and firmware to be loaded from a specific device (this is from ChromeOS, where the device as a whole is verified cryptographically via dm-verity). This is disabled by default but can be configured to be enabled by default (don't do this if you don't know what you're doing). - Keys: allow authentication data to be stored in an asymmetric key. Lots of general fixes and updates. - SELinux: add restrictions for loading of kernel modules via finit_module(). Distinguish non-init user namespace capability checks. Apply execstack check on thread stacks" * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (48 commits) LSM: LoadPin: provide enablement CONFIG Yama: use atomic allocations when reporting seccomp: Fix comment typo ima: add support for creating files using the mknodat syscall ima: fix ima_inode_post_setattr vfs: forbid write access when reading a file into memory fs: fix over-zealous use of "const" selinux: apply execstack check on thread stacks selinux: distinguish non-init user namespace capability checks LSM: LoadPin for kernel file loading restrictions fs: define a string representation of the kernel_read_file_id enumeration Yama: consolidate error reporting string_helpers: add kstrdup_quotable_file string_helpers: add kstrdup_quotable_cmdline string_helpers: add kstrdup_quotable selinux: check ss_initialized before revalidating an inode label selinux: delay inode label lookup as long as possible selinux: don't revalidate an inode's label when explicitly setting it selinux: Change bool variable name to index. KEYS: Add KEYCTL_DH_COMPUTE command ...
Diffstat (limited to 'include')
-rw-r--r--include/crypto/pkcs7.h6
-rw-r--r--include/crypto/public_key.h33
-rw-r--r--include/keys/asymmetric-subtype.h2
-rw-r--r--include/keys/asymmetric-type.h13
-rw-r--r--include/keys/system_keyring.h41
-rw-r--r--include/linux/fs.h31
-rw-r--r--include/linux/ima.h6
-rw-r--r--include/linux/key-type.h1
-rw-r--r--include/linux/key.h44
-rw-r--r--include/linux/lsm_hooks.h6
-rw-r--r--include/linux/string_helpers.h6
-rw-r--r--include/linux/verification.h49
-rw-r--r--include/linux/verify_pefile.h22
-rw-r--r--include/uapi/linux/keyctl.h10
14 files changed, 175 insertions, 95 deletions
diff --git a/include/crypto/pkcs7.h b/include/crypto/pkcs7.h
index 441aff9b5aa7..583f199400a3 100644
--- a/include/crypto/pkcs7.h
+++ b/include/crypto/pkcs7.h
@@ -12,6 +12,7 @@
12#ifndef _CRYPTO_PKCS7_H 12#ifndef _CRYPTO_PKCS7_H
13#define _CRYPTO_PKCS7_H 13#define _CRYPTO_PKCS7_H
14 14
15#include <linux/verification.h>
15#include <crypto/public_key.h> 16#include <crypto/public_key.h>
16 17
17struct key; 18struct key;
@@ -26,14 +27,13 @@ extern void pkcs7_free_message(struct pkcs7_message *pkcs7);
26 27
27extern int pkcs7_get_content_data(const struct pkcs7_message *pkcs7, 28extern int pkcs7_get_content_data(const struct pkcs7_message *pkcs7,
28 const void **_data, size_t *_datalen, 29 const void **_data, size_t *_datalen,
29 bool want_wrapper); 30 size_t *_headerlen);
30 31
31/* 32/*
32 * pkcs7_trust.c 33 * pkcs7_trust.c
33 */ 34 */
34extern int pkcs7_validate_trust(struct pkcs7_message *pkcs7, 35extern int pkcs7_validate_trust(struct pkcs7_message *pkcs7,
35 struct key *trust_keyring, 36 struct key *trust_keyring);
36 bool *_trusted);
37 37
38/* 38/*
39 * pkcs7_verify.c 39 * pkcs7_verify.c
diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
index aa730ea7faf8..882ca0e1e7a5 100644
--- a/include/crypto/public_key.h
+++ b/include/crypto/public_key.h
@@ -15,20 +15,6 @@
15#define _LINUX_PUBLIC_KEY_H 15#define _LINUX_PUBLIC_KEY_H
16 16
17/* 17/*
18 * The use to which an asymmetric key is being put.
19 */
20enum key_being_used_for {
21 VERIFYING_MODULE_SIGNATURE,
22 VERIFYING_FIRMWARE_SIGNATURE,
23 VERIFYING_KEXEC_PE_SIGNATURE,
24 VERIFYING_KEY_SIGNATURE,
25 VERIFYING_KEY_SELF_SIGNATURE,
26 VERIFYING_UNSPECIFIED_SIGNATURE,
27 NR__KEY_BEING_USED_FOR
28};
29extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR];
30
31/*
32 * Cryptographic data for the public-key subtype of the asymmetric key type. 18 * Cryptographic data for the public-key subtype of the asymmetric key type.
33 * 19 *
34 * Note that this may include private part of the key as well as the public 20 * Note that this may include private part of the key as well as the public
@@ -41,12 +27,13 @@ struct public_key {
41 const char *pkey_algo; 27 const char *pkey_algo;
42}; 28};
43 29
44extern void public_key_destroy(void *payload); 30extern void public_key_free(struct public_key *key);
45 31
46/* 32/*
47 * Public key cryptography signature data 33 * Public key cryptography signature data
48 */ 34 */
49struct public_key_signature { 35struct public_key_signature {
36 struct asymmetric_key_id *auth_ids[2];
50 u8 *s; /* Signature */ 37 u8 *s; /* Signature */
51 u32 s_size; /* Number of bytes in signature */ 38 u32 s_size; /* Number of bytes in signature */
52 u8 *digest; 39 u8 *digest;
@@ -55,17 +42,21 @@ struct public_key_signature {
55 const char *hash_algo; 42 const char *hash_algo;
56}; 43};
57 44
45extern void public_key_signature_free(struct public_key_signature *sig);
46
58extern struct asymmetric_key_subtype public_key_subtype; 47extern struct asymmetric_key_subtype public_key_subtype;
48
59struct key; 49struct key;
50struct key_type;
51union key_payload;
52
53extern int restrict_link_by_signature(struct key *trust_keyring,
54 const struct key_type *type,
55 const union key_payload *payload);
56
60extern int verify_signature(const struct key *key, 57extern int verify_signature(const struct key *key,
61 const struct public_key_signature *sig); 58 const struct public_key_signature *sig);
62 59
63struct asymmetric_key_id;
64extern struct key *x509_request_asymmetric_key(struct key *keyring,
65 const struct asymmetric_key_id *id,
66 const struct asymmetric_key_id *skid,
67 bool partial);
68
69int public_key_verify_signature(const struct public_key *pkey, 60int public_key_verify_signature(const struct public_key *pkey,
70 const struct public_key_signature *sig); 61 const struct public_key_signature *sig);
71 62
diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
index 4915d40d3c3c..2480469ce8fb 100644
--- a/include/keys/asymmetric-subtype.h
+++ b/include/keys/asymmetric-subtype.h
@@ -32,7 +32,7 @@ struct asymmetric_key_subtype {
32 void (*describe)(const struct key *key, struct seq_file *m); 32 void (*describe)(const struct key *key, struct seq_file *m);
33 33
34 /* Destroy a key of this subtype */ 34 /* Destroy a key of this subtype */
35 void (*destroy)(void *payload); 35 void (*destroy)(void *payload_crypto, void *payload_auth);
36 36
37 /* Verify the signature on a key of this subtype (optional) */ 37 /* Verify the signature on a key of this subtype (optional) */
38 int (*verify_signature)(const struct key *key, 38 int (*verify_signature)(const struct key *key,
diff --git a/include/keys/asymmetric-type.h b/include/keys/asymmetric-type.h
index 59c1df9cf922..b38240716d41 100644
--- a/include/keys/asymmetric-type.h
+++ b/include/keys/asymmetric-type.h
@@ -15,6 +15,7 @@
15#define _KEYS_ASYMMETRIC_TYPE_H 15#define _KEYS_ASYMMETRIC_TYPE_H
16 16
17#include <linux/key-type.h> 17#include <linux/key-type.h>
18#include <linux/verification.h>
18 19
19extern struct key_type key_type_asymmetric; 20extern struct key_type key_type_asymmetric;
20 21
@@ -23,9 +24,10 @@ extern struct key_type key_type_asymmetric;
23 * follows: 24 * follows:
24 */ 25 */
25enum asymmetric_payload_bits { 26enum asymmetric_payload_bits {
26 asym_crypto, 27 asym_crypto, /* The data representing the key */
27 asym_subtype, 28 asym_subtype, /* Pointer to an asymmetric_key_subtype struct */
28 asym_key_ids, 29 asym_key_ids, /* Pointer to an asymmetric_key_ids struct */
30 asym_auth /* The key's authorisation (signature, parent key ID) */
29}; 31};
30 32
31/* 33/*
@@ -74,6 +76,11 @@ const struct asymmetric_key_ids *asymmetric_key_ids(const struct key *key)
74 return key->payload.data[asym_key_ids]; 76 return key->payload.data[asym_key_ids];
75} 77}
76 78
79extern struct key *find_asymmetric_key(struct key *keyring,
80 const struct asymmetric_key_id *id_0,
81 const struct asymmetric_key_id *id_1,
82 bool partial);
83
77/* 84/*
78 * The payload is at the discretion of the subtype. 85 * The payload is at the discretion of the subtype.
79 */ 86 */
diff --git a/include/keys/system_keyring.h b/include/keys/system_keyring.h
index 39fd38cfa8c9..fbd4647767e9 100644
--- a/include/keys/system_keyring.h
+++ b/include/keys/system_keyring.h
@@ -12,51 +12,40 @@
12#ifndef _KEYS_SYSTEM_KEYRING_H 12#ifndef _KEYS_SYSTEM_KEYRING_H
13#define _KEYS_SYSTEM_KEYRING_H 13#define _KEYS_SYSTEM_KEYRING_H
14 14
15#include <linux/key.h>
16
15#ifdef CONFIG_SYSTEM_TRUSTED_KEYRING 17#ifdef CONFIG_SYSTEM_TRUSTED_KEYRING
16 18
17#include <linux/key.h> 19extern int restrict_link_by_builtin_trusted(struct key *keyring,
18#include <crypto/public_key.h> 20 const struct key_type *type,
21 const union key_payload *payload);
19 22
20extern struct key *system_trusted_keyring;
21static inline struct key *get_system_trusted_keyring(void)
22{
23 return system_trusted_keyring;
24}
25#else 23#else
26static inline struct key *get_system_trusted_keyring(void) 24#define restrict_link_by_builtin_trusted restrict_link_reject
27{
28 return NULL;
29}
30#endif 25#endif
31 26
32#ifdef CONFIG_SYSTEM_DATA_VERIFICATION 27#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING
33extern int system_verify_data(const void *data, unsigned long len, 28extern int restrict_link_by_builtin_and_secondary_trusted(
34 const void *raw_pkcs7, size_t pkcs7_len, 29 struct key *keyring,
35 enum key_being_used_for usage); 30 const struct key_type *type,
31 const union key_payload *payload);
32#else
33#define restrict_link_by_builtin_and_secondary_trusted restrict_link_by_builtin_trusted
36#endif 34#endif
37 35
38#ifdef CONFIG_IMA_MOK_KEYRING 36#ifdef CONFIG_IMA_BLACKLIST_KEYRING
39extern struct key *ima_mok_keyring;
40extern struct key *ima_blacklist_keyring; 37extern struct key *ima_blacklist_keyring;
41 38
42static inline struct key *get_ima_mok_keyring(void)
43{
44 return ima_mok_keyring;
45}
46static inline struct key *get_ima_blacklist_keyring(void) 39static inline struct key *get_ima_blacklist_keyring(void)
47{ 40{
48 return ima_blacklist_keyring; 41 return ima_blacklist_keyring;
49} 42}
50#else 43#else
51static inline struct key *get_ima_mok_keyring(void)
52{
53 return NULL;
54}
55static inline struct key *get_ima_blacklist_keyring(void) 44static inline struct key *get_ima_blacklist_keyring(void)
56{ 45{
57 return NULL; 46 return NULL;
58} 47}
59#endif /* CONFIG_IMA_MOK_KEYRING */ 48#endif /* CONFIG_IMA_BLACKLIST_KEYRING */
60 49
61 50
62#endif /* _KEYS_SYSTEM_KEYRING_H */ 51#endif /* _KEYS_SYSTEM_KEYRING_H */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 851390c8d75b..10d3d8f8a65b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2634,15 +2634,34 @@ static inline void i_readcount_inc(struct inode *inode)
2634#endif 2634#endif
2635extern int do_pipe_flags(int *, int); 2635extern int do_pipe_flags(int *, int);
2636 2636
2637#define __kernel_read_file_id(id) \
2638 id(UNKNOWN, unknown) \
2639 id(FIRMWARE, firmware) \
2640 id(MODULE, kernel-module) \
2641 id(KEXEC_IMAGE, kexec-image) \
2642 id(KEXEC_INITRAMFS, kexec-initramfs) \
2643 id(POLICY, security-policy) \
2644 id(MAX_ID, )
2645
2646#define __fid_enumify(ENUM, dummy) READING_ ## ENUM,
2647#define __fid_stringify(dummy, str) #str,
2648
2637enum kernel_read_file_id { 2649enum kernel_read_file_id {
2638 READING_FIRMWARE = 1, 2650 __kernel_read_file_id(__fid_enumify)
2639 READING_MODULE, 2651};
2640 READING_KEXEC_IMAGE, 2652
2641 READING_KEXEC_INITRAMFS, 2653static const char * const kernel_read_file_str[] = {
2642 READING_POLICY, 2654 __kernel_read_file_id(__fid_stringify)
2643 READING_MAX_ID
2644}; 2655};
2645 2656
2657static inline const char *kernel_read_file_id_str(enum kernel_read_file_id id)
2658{
2659 if (id < 0 || id >= READING_MAX_ID)
2660 return kernel_read_file_str[READING_UNKNOWN];
2661
2662 return kernel_read_file_str[id];
2663}
2664
2646extern int kernel_read(struct file *, loff_t, char *, unsigned long); 2665extern int kernel_read(struct file *, loff_t, char *, unsigned long);
2647extern int kernel_read_file(struct file *, void **, loff_t *, loff_t, 2666extern int kernel_read_file(struct file *, void **, loff_t *, loff_t,
2648 enum kernel_read_file_id); 2667 enum kernel_read_file_id);
diff --git a/include/linux/ima.h b/include/linux/ima.h
index e6516cbbe9bf..0eb7c2e7f0d6 100644
--- a/include/linux/ima.h
+++ b/include/linux/ima.h
@@ -21,6 +21,7 @@ extern int ima_file_mmap(struct file *file, unsigned long prot);
21extern int ima_read_file(struct file *file, enum kernel_read_file_id id); 21extern int ima_read_file(struct file *file, enum kernel_read_file_id id);
22extern int ima_post_read_file(struct file *file, void *buf, loff_t size, 22extern int ima_post_read_file(struct file *file, void *buf, loff_t size,
23 enum kernel_read_file_id id); 23 enum kernel_read_file_id id);
24extern void ima_post_path_mknod(struct dentry *dentry);
24 25
25#else 26#else
26static inline int ima_bprm_check(struct linux_binprm *bprm) 27static inline int ima_bprm_check(struct linux_binprm *bprm)
@@ -54,6 +55,11 @@ static inline int ima_post_read_file(struct file *file, void *buf, loff_t size,
54 return 0; 55 return 0;
55} 56}
56 57
58static inline void ima_post_path_mknod(struct dentry *dentry)
59{
60 return;
61}
62
57#endif /* CONFIG_IMA */ 63#endif /* CONFIG_IMA */
58 64
59#ifdef CONFIG_IMA_APPRAISE 65#ifdef CONFIG_IMA_APPRAISE
diff --git a/include/linux/key-type.h b/include/linux/key-type.h
index 7463355a198b..eaee981c5558 100644
--- a/include/linux/key-type.h
+++ b/include/linux/key-type.h
@@ -45,7 +45,6 @@ struct key_preparsed_payload {
45 size_t datalen; /* Raw datalen */ 45 size_t datalen; /* Raw datalen */
46 size_t quotalen; /* Quota length for proposed payload */ 46 size_t quotalen; /* Quota length for proposed payload */
47 time_t expiry; /* Expiry time of key */ 47 time_t expiry; /* Expiry time of key */
48 bool trusted; /* True if key is trusted */
49}; 48};
50 49
51typedef int (*request_key_actor_t)(struct key_construction *key, 50typedef int (*request_key_actor_t)(struct key_construction *key,
diff --git a/include/linux/key.h b/include/linux/key.h
index 5f5b1129dc92..722914798f37 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -173,11 +173,9 @@ struct key {
173#define KEY_FLAG_NEGATIVE 5 /* set if key is negative */ 173#define KEY_FLAG_NEGATIVE 5 /* set if key is negative */
174#define KEY_FLAG_ROOT_CAN_CLEAR 6 /* set if key can be cleared by root without permission */ 174#define KEY_FLAG_ROOT_CAN_CLEAR 6 /* set if key can be cleared by root without permission */
175#define KEY_FLAG_INVALIDATED 7 /* set if key has been invalidated */ 175#define KEY_FLAG_INVALIDATED 7 /* set if key has been invalidated */
176#define KEY_FLAG_TRUSTED 8 /* set if key is trusted */ 176#define KEY_FLAG_BUILTIN 8 /* set if key is built in to the kernel */
177#define KEY_FLAG_TRUSTED_ONLY 9 /* set if keyring only accepts links to trusted keys */ 177#define KEY_FLAG_ROOT_CAN_INVAL 9 /* set if key can be invalidated by root without permission */
178#define KEY_FLAG_BUILTIN 10 /* set if key is builtin */ 178#define KEY_FLAG_KEEP 10 /* set if key should not be removed */
179#define KEY_FLAG_ROOT_CAN_INVAL 11 /* set if key can be invalidated by root without permission */
180#define KEY_FLAG_KEEP 12 /* set if key should not be removed */
181 179
182 /* the key type and key description string 180 /* the key type and key description string
183 * - the desc is used to match a key against search criteria 181 * - the desc is used to match a key against search criteria
@@ -205,6 +203,20 @@ struct key {
205 }; 203 };
206 int reject_error; 204 int reject_error;
207 }; 205 };
206
207 /* This is set on a keyring to restrict the addition of a link to a key
208 * to it. If this method isn't provided then it is assumed that the
209 * keyring is open to any addition. It is ignored for non-keyring
210 * keys.
211 *
212 * This is intended for use with rings of trusted keys whereby addition
213 * to the keyring needs to be controlled. KEY_ALLOC_BYPASS_RESTRICTION
214 * overrides this, allowing the kernel to add extra keys without
215 * restriction.
216 */
217 int (*restrict_link)(struct key *keyring,
218 const struct key_type *type,
219 const union key_payload *payload);
208}; 220};
209 221
210extern struct key *key_alloc(struct key_type *type, 222extern struct key *key_alloc(struct key_type *type,
@@ -212,14 +224,17 @@ extern struct key *key_alloc(struct key_type *type,
212 kuid_t uid, kgid_t gid, 224 kuid_t uid, kgid_t gid,
213 const struct cred *cred, 225 const struct cred *cred,
214 key_perm_t perm, 226 key_perm_t perm,
215 unsigned long flags); 227 unsigned long flags,
228 int (*restrict_link)(struct key *,
229 const struct key_type *,
230 const union key_payload *));
216 231
217 232
218#define KEY_ALLOC_IN_QUOTA 0x0000 /* add to quota, reject if would overrun */ 233#define KEY_ALLOC_IN_QUOTA 0x0000 /* add to quota, reject if would overrun */
219#define KEY_ALLOC_QUOTA_OVERRUN 0x0001 /* add to quota, permit even if overrun */ 234#define KEY_ALLOC_QUOTA_OVERRUN 0x0001 /* add to quota, permit even if overrun */
220#define KEY_ALLOC_NOT_IN_QUOTA 0x0002 /* not in quota */ 235#define KEY_ALLOC_NOT_IN_QUOTA 0x0002 /* not in quota */
221#define KEY_ALLOC_TRUSTED 0x0004 /* Key should be flagged as trusted */ 236#define KEY_ALLOC_BUILT_IN 0x0004 /* Key is built into kernel */
222#define KEY_ALLOC_BUILT_IN 0x0008 /* Key is built into kernel */ 237#define KEY_ALLOC_BYPASS_RESTRICTION 0x0008 /* Override the check on restricted keyrings */
223 238
224extern void key_revoke(struct key *key); 239extern void key_revoke(struct key *key);
225extern void key_invalidate(struct key *key); 240extern void key_invalidate(struct key *key);
@@ -288,8 +303,15 @@ extern struct key *keyring_alloc(const char *description, kuid_t uid, kgid_t gid
288 const struct cred *cred, 303 const struct cred *cred,
289 key_perm_t perm, 304 key_perm_t perm,
290 unsigned long flags, 305 unsigned long flags,
306 int (*restrict_link)(struct key *,
307 const struct key_type *,
308 const union key_payload *),
291 struct key *dest); 309 struct key *dest);
292 310
311extern int restrict_link_reject(struct key *keyring,
312 const struct key_type *type,
313 const union key_payload *payload);
314
293extern int keyring_clear(struct key *keyring); 315extern int keyring_clear(struct key *keyring);
294 316
295extern key_ref_t keyring_search(key_ref_t keyring, 317extern key_ref_t keyring_search(key_ref_t keyring,
diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
index 512fd000562b..7ae397669d8b 100644
--- a/include/linux/lsm_hooks.h
+++ b/include/linux/lsm_hooks.h
@@ -1805,7 +1805,6 @@ struct security_hook_heads {
1805 struct list_head tun_dev_attach_queue; 1805 struct list_head tun_dev_attach_queue;
1806 struct list_head tun_dev_attach; 1806 struct list_head tun_dev_attach;
1807 struct list_head tun_dev_open; 1807 struct list_head tun_dev_open;
1808 struct list_head skb_owned_by;
1809#endif /* CONFIG_SECURITY_NETWORK */ 1808#endif /* CONFIG_SECURITY_NETWORK */
1810#ifdef CONFIG_SECURITY_NETWORK_XFRM 1809#ifdef CONFIG_SECURITY_NETWORK_XFRM
1811 struct list_head xfrm_policy_alloc_security; 1810 struct list_head xfrm_policy_alloc_security;
@@ -1894,5 +1893,10 @@ extern void __init yama_add_hooks(void);
1894#else 1893#else
1895static inline void __init yama_add_hooks(void) { } 1894static inline void __init yama_add_hooks(void) { }
1896#endif 1895#endif
1896#ifdef CONFIG_SECURITY_LOADPIN
1897void __init loadpin_add_hooks(void);
1898#else
1899static inline void loadpin_add_hooks(void) { };
1900#endif
1897 1901
1898#endif /* ! __LINUX_LSM_HOOKS_H */ 1902#endif /* ! __LINUX_LSM_HOOKS_H */
diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
index dabe643eb5fa..5ce9538f290e 100644
--- a/include/linux/string_helpers.h
+++ b/include/linux/string_helpers.h
@@ -3,6 +3,8 @@
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5 5
6struct file;
7
6/* Descriptions of the types of units to 8/* Descriptions of the types of units to
7 * print in */ 9 * print in */
8enum string_size_units { 10enum string_size_units {
@@ -68,4 +70,8 @@ static inline int string_escape_str_any_np(const char *src, char *dst,
68 return string_escape_str(src, dst, sz, ESCAPE_ANY_NP, only); 70 return string_escape_str(src, dst, sz, ESCAPE_ANY_NP, only);
69} 71}
70 72
73char *kstrdup_quotable(const char *src, gfp_t gfp);
74char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp);
75char *kstrdup_quotable_file(struct file *file, gfp_t gfp);
76
71#endif 77#endif
diff --git a/include/linux/verification.h b/include/linux/verification.h
new file mode 100644
index 000000000000..a10549a6c7cd
--- /dev/null
+++ b/include/linux/verification.h
@@ -0,0 +1,49 @@
1/* Signature verification
2 *
3 * Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _LINUX_VERIFICATION_H
13#define _LINUX_VERIFICATION_H
14
15/*
16 * The use to which an asymmetric key is being put.
17 */
18enum key_being_used_for {
19 VERIFYING_MODULE_SIGNATURE,
20 VERIFYING_FIRMWARE_SIGNATURE,
21 VERIFYING_KEXEC_PE_SIGNATURE,
22 VERIFYING_KEY_SIGNATURE,
23 VERIFYING_KEY_SELF_SIGNATURE,
24 VERIFYING_UNSPECIFIED_SIGNATURE,
25 NR__KEY_BEING_USED_FOR
26};
27extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR];
28
29#ifdef CONFIG_SYSTEM_DATA_VERIFICATION
30
31struct key;
32
33extern int verify_pkcs7_signature(const void *data, size_t len,
34 const void *raw_pkcs7, size_t pkcs7_len,
35 struct key *trusted_keys,
36 enum key_being_used_for usage,
37 int (*view_content)(void *ctx,
38 const void *data, size_t len,
39 size_t asn1hdrlen),
40 void *ctx);
41
42#ifdef CONFIG_SIGNED_PE_FILE_VERIFICATION
43extern int verify_pefile_signature(const void *pebuf, unsigned pelen,
44 struct key *trusted_keys,
45 enum key_being_used_for usage);
46#endif
47
48#endif /* CONFIG_SYSTEM_DATA_VERIFICATION */
49#endif /* _LINUX_VERIFY_PEFILE_H */
diff --git a/include/linux/verify_pefile.h b/include/linux/verify_pefile.h
deleted file mode 100644
index da2049b5161c..000000000000
--- a/include/linux/verify_pefile.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/* Signed PE file verification
2 *
3 * Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _LINUX_VERIFY_PEFILE_H
13#define _LINUX_VERIFY_PEFILE_H
14
15#include <crypto/public_key.h>
16
17extern int verify_pefile_signature(const void *pebuf, unsigned pelen,
18 struct key *trusted_keyring,
19 enum key_being_used_for usage,
20 bool *_trusted);
21
22#endif /* _LINUX_VERIFY_PEFILE_H */
diff --git a/include/uapi/linux/keyctl.h b/include/uapi/linux/keyctl.h
index 840cb990abe2..86eddd6241f3 100644
--- a/include/uapi/linux/keyctl.h
+++ b/include/uapi/linux/keyctl.h
@@ -12,6 +12,8 @@
12#ifndef _LINUX_KEYCTL_H 12#ifndef _LINUX_KEYCTL_H
13#define _LINUX_KEYCTL_H 13#define _LINUX_KEYCTL_H
14 14
15#include <linux/types.h>
16
15/* special process keyring shortcut IDs */ 17/* special process keyring shortcut IDs */
16#define KEY_SPEC_THREAD_KEYRING -1 /* - key ID for thread-specific keyring */ 18#define KEY_SPEC_THREAD_KEYRING -1 /* - key ID for thread-specific keyring */
17#define KEY_SPEC_PROCESS_KEYRING -2 /* - key ID for process-specific keyring */ 19#define KEY_SPEC_PROCESS_KEYRING -2 /* - key ID for process-specific keyring */
@@ -57,5 +59,13 @@
57#define KEYCTL_INSTANTIATE_IOV 20 /* instantiate a partially constructed key */ 59#define KEYCTL_INSTANTIATE_IOV 20 /* instantiate a partially constructed key */
58#define KEYCTL_INVALIDATE 21 /* invalidate a key */ 60#define KEYCTL_INVALIDATE 21 /* invalidate a key */
59#define KEYCTL_GET_PERSISTENT 22 /* get a user's persistent keyring */ 61#define KEYCTL_GET_PERSISTENT 22 /* get a user's persistent keyring */
62#define KEYCTL_DH_COMPUTE 23 /* Compute Diffie-Hellman values */
63
64/* keyctl structures */
65struct keyctl_dh_params {
66 __s32 private;
67 __s32 prime;
68 __s32 base;
69};
60 70
61#endif /* _LINUX_KEYCTL_H */ 71#endif /* _LINUX_KEYCTL_H */