projects/linux·commit bb2cbf5e

Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security

bb2cbf5e · Linus Torvalds <[email protected]> · 2014-08-06 08:06:39 -07:00

Pull security subsystem updates from James Morris:
 "In this release:

   - PKCS#7 parser for the key management subsystem from David Howells
   - appoint Kees Cook as seccomp maintainer
   - bugfixes and general maintenance across the subsystem"

* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (94 commits)
  X.509: Need to export x509_request_asymmetric_key()
  netlabel: shorter names for the NetLabel catmap funcs/structs
  netlabel: fix the catmap walking functions
  netlabel: fix the horribly broken catmap functions
  netlabel: fix a problem when setting bits below the previously lowest bit
  PKCS#7: X.509 certificate issuer and subject are mandatory fields in the ASN.1
  tpm: simplify code by using %*phN specifier
  tpm: Provide a generic means to override the chip returned timeouts
  tpm: missing tpm_chip_put in tpm_get_random()
  tpm: Properly clean sysfs entries in error path
  tpm: Add missing tpm_do_selftest to ST33 I2C driver
  PKCS#7: Use x509_request_asymmetric_key()
  Revert "selinux: fix the default socket labeling in sock_graft()"
  X.509: x509_request_asymmetric_keys() doesn't need string length arguments
  PKCS#7: fix sparse non static symbol warning
  KEYS: revert encrypted key change
  ima: add support for measuring and appraising firmware
  firmware_class: perform new LSM checks
  security: introduce kernel_fw_from_file hook
  PKCS#7: Missing inclusion of linux/err.h
  ...
Commit
bb2cbf5e9367d8598fecd0c48dead69560750223
Parents
e7fda6c4 · 478d0855

Merge commit. Changes below are compared with the first parent: e7fda6c4.

Changes

110 files changed · +4480 −834

FileStatusAddDelContent
Documentation/ABI/testing/ima_policymodified+3−1View file
Documentation/kernel-parameters.txtmodified+22−0View file
Documentation/security/keys.txtmodified+10−4View file
MAINTAINERSmodified+10−0View file
arch/Kconfigmodified+1−0View file
arch/arm/include/uapi/asm/unistd.hmodified+1−0View file
arch/arm/kernel/calls.Smodified+1−0View file
arch/mips/include/uapi/asm/unistd.hmodified+9−6View file
arch/mips/kernel/scall32-o32.Smodified+1−0View file
arch/mips/kernel/scall64-64.Smodified+1−0View file
arch/mips/kernel/scall64-n32.Smodified+1−0View file
arch/mips/kernel/scall64-o32.Smodified+1−0View file
arch/x86/syscalls/syscall_32.tblmodified+1−0View file
arch/x86/syscalls/syscall_64.tblmodified+1−0View file
crypto/asymmetric_keys/Kconfigmodified+32−2View file
crypto/asymmetric_keys/Makefilemodified+37−0View file
crypto/asymmetric_keys/asymmetric_keys.hmodified+2−0View file
crypto/asymmetric_keys/asymmetric_type.cmodified+34−44View file
crypto/asymmetric_keys/mscode.asn1added+28−0View file
crypto/asymmetric_keys/mscode_parser.cadded+126−0View file
crypto/asymmetric_keys/pkcs7.asn1added+127−0View file
crypto/asymmetric_keys/pkcs7_key_type.cadded+100−0View file
crypto/asymmetric_keys/pkcs7_parser.cadded+396−0View file
crypto/asymmetric_keys/pkcs7_parser.hadded+61−0View file
crypto/asymmetric_keys/pkcs7_trust.cadded+166−0View file
crypto/asymmetric_keys/pkcs7_verify.cadded+321−0View file
crypto/asymmetric_keys/verify_pefile.cadded+457−0View file
crypto/asymmetric_keys/verify_pefile.hadded+42−0View file
crypto/asymmetric_keys/x509.asn1modified+1−1View file
crypto/asymmetric_keys/x509_cert_parser.cmodified+20−0View file
crypto/asymmetric_keys/x509_parser.hmodified+12−1View file
crypto/asymmetric_keys/x509_public_key.cmodified+113−2View file
drivers/base/firmware_class.cmodified+26−4View file
drivers/char/tpm/tpm-interface.cmodified+48−25View file
drivers/char/tpm/tpm_eventlog.cmodified+1−3View file
drivers/char/tpm/tpm_i2c_stm_st33.cmodified+1−0View file
drivers/char/tpm/tpm_tis.cmodified+31−0View file
fs/exec.cmodified+3−3View file
fs/nfs/idmap.cmodified+8−2View file
fs/proc/array.cmodified+1−10View file
include/crypto/pkcs7.hadded+36−0View file
include/crypto/public_key.hmodified+4−0View file
include/keys/big_key-type.hmodified+2−1View file
include/keys/system_keyring.hmodified+9−1View file
include/keys/user-type.hmodified+2−1View file
include/linux/capability.hmodified+4−1View file
include/linux/ima.hmodified+6−0View file
include/linux/key-type.hmodified+4−1View file
include/linux/key.hmodified+2−0View file
include/linux/oid_registry.hmodified+7−1View file
include/linux/pe.hadded+448−0View file
include/linux/sched.hmodified+15−3View file
include/linux/seccomp.hmodified+5−3View file
include/linux/security.hmodified+17−0View file
include/linux/syscalls.hmodified+2−0View file
include/linux/tpm.hmodified+3−0View file
include/linux/verify_pefile.hadded+18−0View file
include/net/netlabel.hmodified+53−41View file
include/uapi/asm-generic/unistd.hmodified+3−1View file
include/uapi/linux/seccomp.hmodified+7−0View file
kernel/audit.cmodified+1−1View file
kernel/capability.cmodified+4−0View file
kernel/fork.cmodified+48−1View file
kernel/seccomp.cmodified+353−59View file
kernel/sys.cmodified+2−2View file
kernel/sys_ni.cmodified+3−0View file
kernel/system_keyring.cmodified+1−0View file
lib/Kconfigmodified+2−1View file
net/ceph/crypto.cmodified+14−12View file
net/dns_resolver/dns_key.cmodified+25−18View file
net/dns_resolver/dns_query.cmodified+1−0View file
net/ipv4/cipso_ipv4.cmodified+16−31View file
net/netlabel/netlabel_kapi.cmodified+227−100View file
net/rxrpc/ar-key.cmodified+97−68View file
scripts/selinux/genheaders/Makefilemodified+0−1View file
scripts/selinux/mdp/Makefilemodified+1−1View file
security/apparmor/domain.cmodified+2−2View file
security/capability.cmodified+6−0View file
security/commoncap.cmodified+33−42View file
security/integrity/digsig.cmodified+28−0View file
security/integrity/ima/Kconfigmodified+10−0View file
security/integrity/ima/ima.hmodified+14−1View file
security/integrity/ima/ima_appraise.cmodified+9−1View file
security/integrity/ima/ima_crypto.cmodified+309−3View file
security/integrity/ima/ima_main.cmodified+21−7View file
security/integrity/ima/ima_policy.cmodified+10−3View file
security/integrity/integrity.hmodified+12−2View file
security/keys/big_key.cmodified+25−16View file
security/keys/key.cmodified+44−5View file
security/keys/keyctl.cmodified+18−3View file
security/keys/keyring.cmodified+23−11View file
security/keys/request_key_auth.cmodified+13−0View file
security/keys/user_defined.cmodified+22−19View file
security/security.cmodified+11−0View file
security/selinux/hooks.cmodified+14−0View file
security/selinux/include/netif.hmodified+2−0View file
security/selinux/include/netnode.hmodified+2−0View file
security/selinux/include/netport.hmodified+2−0View file
security/selinux/include/security.hmodified+2−1View file
security/selinux/netif.cmodified+1−14View file
security/selinux/netnode.cmodified+1−14View file
security/selinux/netport.cmodified+1−14View file
security/selinux/ss/conditional.cmodified+3−8View file
security/selinux/ss/ebitmap.cmodified+52−81View file
security/selinux/ss/ebitmap.hmodified+4−4View file
security/selinux/ss/policydb.cmodified+41−100View file
security/selinux/ss/services.cmodified+32−9View file
security/smack/smack_access.cmodified+4−7View file
security/smack/smack_lsm.cmodified+3−3View file
security/smack/smackfs.cmodified+7−7View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/ABI/testing/ima_policy

View file
diff --git a/Documentation/ABI/testing/ima_policy b/Documentation/ABI/testing/ima_policy
index 4c3efe4..d0d0c57 100644
--- a/Documentation/ABI/testing/ima_policy
+++ b/Documentation/ABI/testing/ima_policy
@@ -26,6 +26,7 @@ Description:
option: [[appraise_type=]] [permit_directio]
base: func:= [BPRM_CHECK][MMAP_CHECK][FILE_CHECK][MODULE_CHECK]
+ [FIRMWARE_CHECK]
mask:= [MAY_READ] [MAY_WRITE] [MAY_APPEND] [MAY_EXEC]
fsmagic:= hex value
fsuuid:= file system UUID (e.g 8bcbe394-4f13-4144-be8e-5aa9ea2ce2f6)
@@ -57,7 +58,8 @@ Description:
measure func=BPRM_CHECK
measure func=FILE_MMAP mask=MAY_EXEC
measure func=FILE_CHECK mask=MAY_READ uid=0
- measure func=MODULE_CHECK uid=0
+ measure func=MODULE_CHECK
+ measure func=FIRMWARE_CHECK
appraise fowner=0
The default policy measures all executables in bprm_check,

Documentation/kernel-parameters.txt

View file
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 6c062a6..883901b 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -566,6 +566,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
possible to determine what the correct size should be.
This option provides an override for these situations.
+ ca_keys= [KEYS] This parameter identifies a specific key(s) on
+ the system trusted keyring to be used for certificate
+ trust validation.
+ format: { id:<keyid> | builtin }
+
ccw_timeout_log [S390]
See Documentation/s390/CommonIO for details.
@@ -1319,6 +1324,23 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
Formats: { "ima" | "ima-ng" }
Default: "ima-ng"
+ ima.ahash_minsize= [IMA] Minimum file size for asynchronous hash usage
+ Format: <min_file_size>
+ Set the minimal file size for using asynchronous hash.
+ If left unspecified, ahash usage is disabled.
+
+ ahash performance varies for different data sizes on
+ different crypto accelerators. This option can be used
+ to achieve the best performance for a particular HW.
+
+ ima.ahash_bufsize= [IMA] Asynchronous hash buffer size
+ Format: <bufsize>
+ Set hashing buffer size. Default: 4k.
+
+ ahash performance varies for different chunk sizes on
+ different crypto accelerators. This option can be used
+ to achieve best performance for particular HW.
+
init= [KNL]
Format: <full_path>
Run specified binary instead of /sbin/init as init

Documentation/security/keys.txt

View file
diff --git a/Documentation/security/keys.txt b/Documentation/security/keys.txt
index a4c33f1..8727c19 100644
--- a/Documentation/security/keys.txt
+++ b/Documentation/security/keys.txt
@@ -1150,20 +1150,24 @@ The structure has a number of fields, some of which are mandatory:
const void *data;
size_t datalen;
size_t quotalen;
+ time_t expiry;
};
Before calling the method, the caller will fill in data and datalen with
the payload blob parameters; quotalen will be filled in with the default
- quota size from the key type and the rest will be cleared.
+ quota size from the key type; expiry will be set to TIME_T_MAX and the
+ rest will be cleared.
If a description can be proposed from the payload contents, that should be
attached as a string to the description field. This will be used for the
key description if the caller of add_key() passes NULL or "".
The method can attach anything it likes to type_data[] and payload. These
- are merely passed along to the instantiate() or update() operations.
+ are merely passed along to the instantiate() or update() operations. If
+ set, the expiry time will be applied to the key if it is instantiated from
+ this data.
- The method should return 0 if success ful or a negative error code
+ The method should return 0 if successful or a negative error code
otherwise.
@@ -1172,7 +1176,9 @@ The structure has a number of fields, some of which are mandatory:
This method is only required if the preparse() method is provided,
otherwise it is unused. It cleans up anything attached to the
description, type_data and payload fields of the key_preparsed_payload
- struct as filled in by the preparse() method.
+ struct as filled in by the preparse() method. It will always be called
+ after preparse() returns successfully, even if instantiate() or update()
+ succeed.
(*) int (*instantiate)(struct key *key, struct key_preparsed_payload *prep);

MAINTAINERS

View file
diff --git a/MAINTAINERS b/MAINTAINERS
index f777763..b9d0293 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8002,6 +8002,16 @@ S: Maintained
F: drivers/mmc/host/sdhci.*
F: drivers/mmc/host/sdhci-pltfm.[ch]
+SECURE COMPUTING
+M: Kees Cook <[email protected]>
+T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git seccomp
+S: Supported
+F: kernel/seccomp.c
+F: include/uapi/linux/seccomp.h
+F: include/linux/seccomp.h
+K: \bsecure_computing
+K: \bTIF_SECCOMP\b
+
SECURE DIGITAL HOST CONTROLLER INTERFACE, OPEN FIRMWARE BINDINGS (SDHCI-OF)
M: Anton Vorontsov <[email protected]>

arch/Kconfig

View file
diff --git a/arch/Kconfig b/arch/Kconfig
index 97ff872..0eae9df 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -321,6 +321,7 @@ config HAVE_ARCH_SECCOMP_FILTER
- secure_computing is called from a ptrace_event()-safe context
- secure_computing return value is checked and a return value of -1
results in the system call being skipped immediately.
+ - seccomp syscall wired up
config SECCOMP_FILTER
def_bool y

arch/arm/include/uapi/asm/unistd.h

View file
diff --git a/arch/arm/include/uapi/asm/unistd.h b/arch/arm/include/uapi/asm/unistd.h
index acd5b66..767ea20 100644
--- a/arch/arm/include/uapi/asm/unistd.h
+++ b/arch/arm/include/uapi/asm/unistd.h
@@ -409,6 +409,7 @@
#define __NR_sched_setattr (__NR_SYSCALL_BASE+380)
#define __NR_sched_getattr (__NR_SYSCALL_BASE+381)
#define __NR_renameat2 (__NR_SYSCALL_BASE+382)
+#define __NR_seccomp (__NR_SYSCALL_BASE+383)
/*
* The following SWIs are ARM private.

arch/arm/kernel/calls.S

View file
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S
index 8f51bdc..bea85f9 100644
--- a/arch/arm/kernel/calls.S
+++ b/arch/arm/kernel/calls.S
@@ -392,6 +392,7 @@
/* 380 */ CALL(sys_sched_setattr)
CALL(sys_sched_getattr)
CALL(sys_renameat2)
+ CALL(sys_seccomp)
#ifndef syscalls_counted
.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls
#define syscalls_counted

arch/mips/include/uapi/asm/unistd.h

View file
diff --git a/arch/mips/include/uapi/asm/unistd.h b/arch/mips/include/uapi/asm/unistd.h
index 5805414..9bc13ea 100644
--- a/arch/mips/include/uapi/asm/unistd.h
+++ b/arch/mips/include/uapi/asm/unistd.h
@@ -372,16 +372,17 @@
#define __NR_sched_setattr (__NR_Linux + 349)
#define __NR_sched_getattr (__NR_Linux + 350)
#define __NR_renameat2 (__NR_Linux + 351)
+#define __NR_seccomp (__NR_Linux + 352)
/*
* Offset of the last Linux o32 flavoured syscall
*/
-#define __NR_Linux_syscalls 351
+#define __NR_Linux_syscalls 352
#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
#define __NR_O32_Linux 4000
-#define __NR_O32_Linux_syscalls 351
+#define __NR_O32_Linux_syscalls 352
#if _MIPS_SIM == _MIPS_SIM_ABI64
@@ -701,16 +702,17 @@
#define __NR_sched_setattr (__NR_Linux + 309)
#define __NR_sched_getattr (__NR_Linux + 310)
#define __NR_renameat2 (__NR_Linux + 311)
+#define __NR_seccomp (__NR_Linux + 312)
/*
* Offset of the last Linux 64-bit flavoured syscall
*/
-#define __NR_Linux_syscalls 311
+#define __NR_Linux_syscalls 312
#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
#define __NR_64_Linux 5000
-#define __NR_64_Linux_syscalls 311
+#define __NR_64_Linux_syscalls 312
#if _MIPS_SIM == _MIPS_SIM_NABI32
@@ -1034,15 +1036,16 @@
#define __NR_sched_setattr (__NR_Linux + 313)
#define __NR_sched_getattr (__NR_Linux + 314)
#define __NR_renameat2 (__NR_Linux + 315)
+#define __NR_seccomp (__NR_Linux + 316)
/*
* Offset of the last N32 flavoured syscall
*/
-#define __NR_Linux_syscalls 315
+#define __NR_Linux_syscalls 316
#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
#define __NR_N32_Linux 6000
-#define __NR_N32_Linux_syscalls 315
+#define __NR_N32_Linux_syscalls 316
#endif /* _UAPI_ASM_UNISTD_H */

arch/mips/kernel/scall32-o32.S

View file
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index 3245474..ab02d14 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -578,3 +578,4 @@ EXPORT(sys_call_table)
PTR sys_sched_setattr
PTR sys_sched_getattr /* 4350 */
PTR sys_renameat2
+ PTR sys_seccomp

arch/mips/kernel/scall64-64.S

View file
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index be2fedd..010dccf 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -431,4 +431,5 @@ EXPORT(sys_call_table)
PTR sys_sched_setattr
PTR sys_sched_getattr /* 5310 */
PTR sys_renameat2
+ PTR sys_seccomp
.size sys_call_table,.-sys_call_table

arch/mips/kernel/scall64-n32.S

View file
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index c1dbcda..c3b3b65 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -424,4 +424,5 @@ EXPORT(sysn32_call_table)
PTR sys_sched_setattr
PTR sys_sched_getattr
PTR sys_renameat2 /* 6315 */
+ PTR sys_seccomp
.size sysn32_call_table,.-sysn32_call_table

arch/mips/kernel/scall64-o32.S

View file
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index f1343cc..bb1550b 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -557,4 +557,5 @@ EXPORT(sys32_call_table)
PTR sys_sched_setattr
PTR sys_sched_getattr /* 4350 */
PTR sys_renameat2
+ PTR sys_seccomp
.size sys32_call_table,.-sys32_call_table

arch/x86/syscalls/syscall_32.tbl

View file
diff --git a/arch/x86/syscalls/syscall_32.tbl b/arch/x86/syscalls/syscall_32.tbl
index d6b8679..7527eac 100644
--- a/arch/x86/syscalls/syscall_32.tbl
+++ b/arch/x86/syscalls/syscall_32.tbl
@@ -360,3 +360,4 @@
351 i386 sched_setattr sys_sched_setattr
352 i386 sched_getattr sys_sched_getattr
353 i386 renameat2 sys_renameat2
+354 i386 seccomp sys_seccomp

arch/x86/syscalls/syscall_64.tbl

View file
diff --git a/arch/x86/syscalls/syscall_64.tbl b/arch/x86/syscalls/syscall_64.tbl
index ec255a1..16272a6 100644
--- a/arch/x86/syscalls/syscall_64.tbl
+++ b/arch/x86/syscalls/syscall_64.tbl
@@ -323,6 +323,7 @@
314 common sched_setattr sys_sched_setattr
315 common sched_getattr sys_sched_getattr
316 common renameat2 sys_renameat2
+317 common seccomp sys_seccomp
#
# x32-specific system call numbers start at 512 to avoid cache impact

crypto/asymmetric_keys/Kconfig

View file
diff --git a/crypto/asymmetric_keys/Kconfig b/crypto/asymmetric_keys/Kconfig
index 03a6eb9..4870f28 100644
--- a/crypto/asymmetric_keys/Kconfig
+++ b/crypto/asymmetric_keys/Kconfig
@@ -22,7 +22,6 @@ config ASYMMETRIC_PUBLIC_KEY_SUBTYPE
config PUBLIC_KEY_ALGO_RSA
tristate "RSA public-key algorithm"
- select MPILIB_EXTRA
select MPILIB
help
This option enables support for the RSA algorithm (PKCS#1, RFC3447).
@@ -33,8 +32,39 @@ config X509_CERTIFICATE_PARSER
select ASN1
select OID_REGISTRY
help
- This option procides support for parsing X.509 format blobs for key
+ This option provides support for parsing X.509 format blobs for key
data and provides the ability to instantiate a crypto key from a
public key packet found inside the certificate.
+config PKCS7_MESSAGE_PARSER
+ tristate "PKCS#7 message parser"
+ depends on X509_CERTIFICATE_PARSER
+ select ASN1
+ select OID_REGISTRY
+ help
+ This option provides support for parsing PKCS#7 format messages for
+ signature data and provides the ability to verify the signature.
+
+config PKCS7_TEST_KEY
+ tristate "PKCS#7 testing key type"
+ depends on PKCS7_MESSAGE_PARSER
+ select SYSTEM_TRUSTED_KEYRING
+ help
+ This option provides a type of key that can be loaded up from a
+ PKCS#7 message - provided the message is signed by a trusted key. If
+ it is, the PKCS#7 wrapper is discarded and reading the key returns
+ just the payload. If it isn't, adding the key will fail with an
+ error.
+
+ This is intended for testing the PKCS#7 parser.
+
+config SIGNED_PE_FILE_VERIFICATION
+ bool "Support for PE file signature verification"
+ depends on PKCS7_MESSAGE_PARSER=y
+ select ASN1
+ select OID_REGISTRY
+ help
+ This option provides support for verifying the signature(s) on a
+ signed PE binary.
+
endif # ASYMMETRIC_KEY_TYPE

crypto/asymmetric_keys/Makefile

View file
diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index 0727204..e47fcd9 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -25,3 +25,40 @@ $(obj)/x509_rsakey-asn1.o: $(obj)/x509_rsakey-asn1.c $(obj)/x509_rsakey-asn1.h
clean-files += x509-asn1.c x509-asn1.h
clean-files += x509_rsakey-asn1.c x509_rsakey-asn1.h
+
+#
+# PKCS#7 message handling
+#
+obj-$(CONFIG_PKCS7_MESSAGE_PARSER) += pkcs7_message.o
+pkcs7_message-y := \
+ pkcs7-asn1.o \
+ pkcs7_parser.o \
+ pkcs7_trust.o \
+ pkcs7_verify.o
+
+$(obj)/pkcs7_parser.o: $(obj)/pkcs7-asn1.h
+$(obj)/pkcs7-asn1.o: $(obj)/pkcs7-asn1.c $(obj)/pkcs7-asn1.h
+
+clean-files += pkcs7-asn1.c pkcs7-asn1.h
+
+#
+# PKCS#7 parser testing key
+#
+obj-$(CONFIG_PKCS7_TEST_KEY) += pkcs7_test_key.o
+pkcs7_test_key-y := \
+ pkcs7_key_type.o
+
+#
+# Signed PE binary-wrapped key handling
+#
+obj-$(CONFIG_SIGNED_PE_FILE_VERIFICATION) += verify_signed_pefile.o
+
+verify_signed_pefile-y := \
+ verify_pefile.o \
+ mscode_parser.o \
+ mscode-asn1.o
+
+$(obj)/mscode_parser.o: $(obj)/mscode-asn1.h $(obj)/mscode-asn1.h
+$(obj)/mscode-asn1.o: $(obj)/mscode-asn1.c $(obj)/mscode-asn1.h
+
+clean-files += mscode-asn1.c mscode-asn1.h

crypto/asymmetric_keys/asymmetric_keys.h

View file
diff --git a/crypto/asymmetric_keys/asymmetric_keys.h b/crypto/asymmetric_keys/asymmetric_keys.h
index 515b634..a63c551 100644
--- a/crypto/asymmetric_keys/asymmetric_keys.h
+++ b/crypto/asymmetric_keys/asymmetric_keys.h
@@ -9,6 +9,8 @@
* 2 of the Licence, or (at your option) any later version.
*/
+int asymmetric_keyid_match(const char *kid, const char *id);
+
static inline const char *asymmetric_key_id(const struct key *key)
{
return key->type_data.p[1];

crypto/asymmetric_keys/asymmetric_type.c

View file
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index b77eb53..eb8cd46 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -23,6 +23,35 @@ static LIST_HEAD(asymmetric_key_parsers);
static DECLARE_RWSEM(asymmetric_key_parsers_sem);
/*
+ * Match asymmetric key id with partial match
+ * @id: key id to match in a form "id:<id>"
+ */
+int asymmetric_keyid_match(const char *kid, const char *id)
+{
+ size_t idlen, kidlen;
+
+ if (!kid || !id)
+ return 0;
+
+ /* make it possible to use id as in the request: "id:<id>" */
+ if (strncmp(id, "id:", 3) == 0)
+ id += 3;
+
+ /* Anything after here requires a partial match on the ID string */
+ idlen = strlen(id);
+ kidlen = strlen(kid);
+ if (idlen > kidlen)
+ return 0;
+
+ kid += kidlen - idlen;
+ if (strcasecmp(id, kid) != 0)
+ return 0;
+
+ return 1;
+}
+EXPORT_SYMBOL_GPL(asymmetric_keyid_match);
+
+/*
* Match asymmetric keys on (part of) their name
* We have some shorthand methods for matching keys. We allow:
*
@@ -34,9 +63,8 @@ static int asymmetric_key_match(const struct key *key, const void *description)
{
const struct asymmetric_key_subtype *subtype = asymmetric_key_subtype(key);
const char *spec = description;
- const char *id, *kid;
+ const char *id;
ptrdiff_t speclen;
- size_t idlen, kidlen;
if (!subtype || !spec || !*spec)
return 0;
@@ -55,23 +83,8 @@ static int asymmetric_key_match(const struct key *key, const void *description)
speclen = id - spec;
id++;
- /* Anything after here requires a partial match on the ID string */
- kid = asymmetric_key_id(key);
- if (!kid)
- return 0;
-
- idlen = strlen(id);
- kidlen = strlen(kid);
- if (idlen > kidlen)
- return 0;
-
- kid += kidlen - idlen;
- if (strcasecmp(id, kid) != 0)
- return 0;
-
- if (speclen == 2 &&
- memcmp(spec, "id", 2) == 0)
- return 1;
+ if (speclen == 2 && memcmp(spec, "id", 2) == 0)
+ return asymmetric_keyid_match(asymmetric_key_id(key), id);
if (speclen == subtype->name_len &&
memcmp(spec, subtype->name, speclen) == 0)
@@ -156,7 +169,7 @@ static void asymmetric_key_free_preparse(struct key_preparsed_payload *prep)
pr_devel("==>%s()\n", __func__);
if (subtype) {
- subtype->destroy(prep->payload);
+ subtype->destroy(prep->payload[0]);
module_put(subtype->owner);
}
kfree(prep->type_data[1]);
@@ -164,29 +177,6 @@ static void asymmetric_key_free_preparse(struct key_preparsed_payload *prep)
}
/*
- * Instantiate a asymmetric_key defined key. The key was preparsed, so we just
- * have to transfer the data here.
- */
-static int asymmetric_key_instantiate(struct key *key, struct key_preparsed_payload *prep)
-{
- int ret;
-
- pr_devel("==>%s()\n", __func__);
-
- ret = key_payload_reserve(key, prep->quotalen);
- if (ret == 0) {
- key->type_data.p[0] = prep->type_data[0];
- key->type_data.p[1] = prep->type_data[1];
- key->payload.data = prep->payload;
- prep->type_data[0] = NULL;
- prep->type_data[1] = NULL;
- prep->payload = NULL;
- }
- pr_devel("<==%s() = %d\n", __func__, ret);
- return ret;
-}
-
-/*
* dispose of the data dangling from the corpse of a asymmetric key
*/
static void asymmetric_key_destroy(struct key *key)
@@ -205,7 +195,7 @@ struct key_type key_type_asymmetric = {
.name = "asymmetric",
.preparse = asymmetric_key_preparse,
.free_preparse = asymmetric_key_free_preparse,
- .instantiate = asymmetric_key_instantiate,
+ .instantiate = generic_key_instantiate,
.match = asymmetric_key_match,
.destroy = asymmetric_key_destroy,
.describe = asymmetric_key_describe,

crypto/asymmetric_keys/mscode.asn1

View file
diff --git a/crypto/asymmetric_keys/mscode.asn1 b/crypto/asymmetric_keys/mscode.asn1
new file mode 100644
index 0000000..6d09ba4
--- /dev/null
+++ b/crypto/asymmetric_keys/mscode.asn1
@@ -0,0 +1,28 @@
+--- Microsoft individual code signing data blob parser
+---
+--- Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
+--- Written by David Howells ([email protected])
+---
+--- This program is free software; you can redistribute it and/or
+--- modify it under the terms of the GNU General Public Licence
+--- as published by the Free Software Foundation; either version
+--- 2 of the Licence, or (at your option) any later version.
+---
+
+MSCode ::= SEQUENCE {
+ type SEQUENCE {
+ contentType ContentType,
+ parameters ANY
+ },
+ content SEQUENCE {
+ digestAlgorithm DigestAlgorithmIdentifier,
+ digest OCTET STRING ({ mscode_note_digest })
+ }
+}
+
+ContentType ::= OBJECT IDENTIFIER ({ mscode_note_content_type })
+
+DigestAlgorithmIdentifier ::= SEQUENCE {
+ algorithm OBJECT IDENTIFIER ({ mscode_note_digest_algo }),
+ parameters ANY OPTIONAL
+}

crypto/asymmetric_keys/mscode_parser.c

View file
diff --git a/crypto/asymmetric_keys/mscode_parser.c b/crypto/asymmetric_keys/mscode_parser.c
new file mode 100644
index 0000000..214a992
--- /dev/null
+++ b/crypto/asymmetric_keys/mscode_parser.c
@@ -0,0 +1,126 @@
+/* Parse a Microsoft Individual Code Signing blob
+ *
+ * Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#define pr_fmt(fmt) "MSCODE: "fmt
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <linux/oid_registry.h>
+#include <crypto/pkcs7.h>
+#include "verify_pefile.h"
+#include "mscode-asn1.h"
+
+/*
+ * Parse a Microsoft Individual Code Signing blob
+ */
+int mscode_parse(struct pefile_context *ctx)
+{
+ const void *content_data;
+ size_t data_len;
+ int ret;
+
+ ret = pkcs7_get_content_data(ctx->pkcs7, &content_data, &data_len, 1);
+
+ if (ret) {
+ pr_debug("PKCS#7 message does not contain data\n");
+ return ret;
+ }
+
+ pr_devel("Data: %zu [%*ph]\n", data_len, (unsigned)(data_len),
+ content_data);
+

This diff is incomplete. Download the complete patch.

crypto/asymmetric_keys/pkcs7.asn1

View file

This diff is incomplete. Download the complete patch.

crypto/asymmetric_keys/pkcs7_key_type.c

View file

This diff is incomplete. Download the complete patch.

crypto/asymmetric_keys/pkcs7_parser.c

View file

This diff is incomplete. Download the complete patch.

crypto/asymmetric_keys/pkcs7_parser.h

View file

This diff is incomplete. Download the complete patch.

crypto/asymmetric_keys/pkcs7_trust.c

View file

This diff is incomplete. Download the complete patch.

crypto/asymmetric_keys/pkcs7_verify.c

View file

This diff is incomplete. Download the complete patch.

crypto/asymmetric_keys/verify_pefile.c

View file

This diff is incomplete. Download the complete patch.

crypto/asymmetric_keys/verify_pefile.h

View file

This diff is incomplete. Download the complete patch.

crypto/asymmetric_keys/x509.asn1

View file

This diff is incomplete. Download the complete patch.

crypto/asymmetric_keys/x509_cert_parser.c

View file

This diff is incomplete. Download the complete patch.

crypto/asymmetric_keys/x509_parser.h

View file

This diff is incomplete. Download the complete patch.

crypto/asymmetric_keys/x509_public_key.c

View file

This diff is incomplete. Download the complete patch.

drivers/base/firmware_class.c

View file

This diff is incomplete. Download the complete patch.

drivers/char/tpm/tpm-interface.c

View file

This diff is incomplete. Download the complete patch.

drivers/char/tpm/tpm_eventlog.c

View file

This diff is incomplete. Download the complete patch.

drivers/char/tpm/tpm_i2c_stm_st33.c

View file

This diff is incomplete. Download the complete patch.

drivers/char/tpm/tpm_tis.c

View file

This diff is incomplete. Download the complete patch.

fs/exec.c

View file

This diff is incomplete. Download the complete patch.

fs/nfs/idmap.c

View file

This diff is incomplete. Download the complete patch.

fs/proc/array.c

View file

This diff is incomplete. Download the complete patch.

include/crypto/pkcs7.h

View file

This diff is incomplete. Download the complete patch.

include/crypto/public_key.h

View file

This diff is incomplete. Download the complete patch.

include/keys/big_key-type.h

View file

This diff is incomplete. Download the complete patch.

include/keys/system_keyring.h

View file

This diff is incomplete. Download the complete patch.

include/keys/user-type.h

View file

This diff is incomplete. Download the complete patch.

include/linux/capability.h

View file

This diff is incomplete. Download the complete patch.

include/linux/ima.h

View file

This diff is incomplete. Download the complete patch.

include/linux/key-type.h

View file

This diff is incomplete. Download the complete patch.

include/linux/key.h

View file

This diff is incomplete. Download the complete patch.

include/linux/oid_registry.h

View file

This diff is incomplete. Download the complete patch.

include/linux/pe.h

View file

This diff is incomplete. Download the complete patch.

include/linux/sched.h

View file

This diff is incomplete. Download the complete patch.

include/linux/seccomp.h

View file

This diff is incomplete. Download the complete patch.

include/linux/security.h

View file

This diff is incomplete. Download the complete patch.

include/linux/syscalls.h

View file

This diff is incomplete. Download the complete patch.

include/linux/tpm.h

View file

This diff is incomplete. Download the complete patch.

include/linux/verify_pefile.h

View file

This diff is incomplete. Download the complete patch.

include/net/netlabel.h

View file

This diff is incomplete. Download the complete patch.

include/uapi/asm-generic/unistd.h

View file

This diff is incomplete. Download the complete patch.

include/uapi/linux/seccomp.h

View file

This diff is incomplete. Download the complete patch.

kernel/audit.c

View file

This diff is incomplete. Download the complete patch.

kernel/capability.c

View file

This diff is incomplete. Download the complete patch.

kernel/fork.c

View file

This diff is incomplete. Download the complete patch.

kernel/seccomp.c

View file

This diff is incomplete. Download the complete patch.

kernel/sys.c

View file

This diff is incomplete. Download the complete patch.

kernel/sys_ni.c

View file

This diff is incomplete. Download the complete patch.

kernel/system_keyring.c

View file

This diff is incomplete. Download the complete patch.

lib/Kconfig

View file

This diff is incomplete. Download the complete patch.

net/ceph/crypto.c

View file

This diff is incomplete. Download the complete patch.

net/dns_resolver/dns_key.c

View file

This diff is incomplete. Download the complete patch.

net/dns_resolver/dns_query.c

View file

This diff is incomplete. Download the complete patch.

net/ipv4/cipso_ipv4.c

View file

This diff is incomplete. Download the complete patch.

net/netlabel/netlabel_kapi.c

View file

This diff is incomplete. Download the complete patch.

net/rxrpc/ar-key.c

View file

This diff is incomplete. Download the complete patch.

scripts/selinux/genheaders/Makefile

View file

This diff is incomplete. Download the complete patch.

scripts/selinux/mdp/Makefile

View file

This diff is incomplete. Download the complete patch.

security/apparmor/domain.c

View file

This diff is incomplete. Download the complete patch.

security/capability.c

View file

This diff is incomplete. Download the complete patch.

security/commoncap.c

View file

This diff is incomplete. Download the complete patch.

security/integrity/digsig.c

View file

This diff is incomplete. Download the complete patch.

security/integrity/ima/Kconfig

View file

This diff is incomplete. Download the complete patch.

security/integrity/ima/ima.h

View file

This diff is incomplete. Download the complete patch.

security/integrity/ima/ima_appraise.c

View file

This diff is incomplete. Download the complete patch.

security/integrity/ima/ima_crypto.c

View file

This diff is incomplete. Download the complete patch.

security/integrity/ima/ima_main.c

View file

This diff is incomplete. Download the complete patch.

security/integrity/ima/ima_policy.c

View file

This diff is incomplete. Download the complete patch.

security/integrity/integrity.h

View file

This diff is incomplete. Download the complete patch.

security/keys/big_key.c

View file

This diff is incomplete. Download the complete patch.

security/keys/key.c

View file

This diff is incomplete. Download the complete patch.

security/keys/keyctl.c

View file

This diff is incomplete. Download the complete patch.

security/keys/keyring.c

View file

This diff is incomplete. Download the complete patch.

security/keys/request_key_auth.c

View file

This diff is incomplete. Download the complete patch.

security/keys/user_defined.c

View file

This diff is incomplete. Download the complete patch.

security/security.c

View file

This diff is incomplete. Download the complete patch.

security/selinux/hooks.c

View file

This diff is incomplete. Download the complete patch.

security/selinux/include/netif.h

View file

This diff is incomplete. Download the complete patch.

security/selinux/include/netnode.h

View file

This diff is incomplete. Download the complete patch.

security/selinux/include/netport.h

View file

This diff is incomplete. Download the complete patch.

security/selinux/include/security.h

View file

This diff is incomplete. Download the complete patch.

security/selinux/netif.c

View file

This diff is incomplete. Download the complete patch.

security/selinux/netnode.c

View file

This diff is incomplete. Download the complete patch.

security/selinux/netport.c

View file

This diff is incomplete. Download the complete patch.

security/selinux/ss/conditional.c

View file

This diff is incomplete. Download the complete patch.

security/selinux/ss/ebitmap.c

View file

This diff is incomplete. Download the complete patch.

security/selinux/ss/ebitmap.h

View file

This diff is incomplete. Download the complete patch.

security/selinux/ss/policydb.c

View file

This diff is incomplete. Download the complete patch.

security/selinux/ss/services.c

View file

This diff is incomplete. Download the complete patch.

security/smack/smack_access.c

View file

This diff is incomplete. Download the complete patch.

security/smack/smack_lsm.c

View file

This diff is incomplete. Download the complete patch.

security/smack/smackfs.c

View file

This diff is incomplete. Download the complete patch.