Skip to content

Commit b793c00

Browse files
committed
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security subsystem updates from James Morris: "Highlights: - PKCS#7 support added to support signed kexec, also utilized for module signing. See comments in 3f1e1be. ** NOTE: this requires linking against the OpenSSL library, which must be installed, e.g. the openssl-devel on Fedora ** - Smack - add IPv6 host labeling; ignore labels on kernel threads - support smack labeling mounts which use binary mount data - SELinux: - add ioctl whitelisting (see http://kernsec.org/files/lss2015/vanderstoep.pdf) - fix mprotect PROT_EXEC regression caused by mm change - Seccomp: - add ptrace options for suspend/resume" * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (57 commits) PKCS#7: Add OIDs for sha224, sha284 and sha512 hash algos and use them Documentation/Changes: Now need OpenSSL devel packages for module signing scripts: add extract-cert and sign-file to .gitignore modsign: Handle signing key in source tree modsign: Use if_changed rule for extracting cert from module signing key Move certificate handling to its own directory sign-file: Fix warning about BIO_reset() return value PKCS#7: Add MODULE_LICENSE() to test module Smack - Fix build error with bringup unconfigured sign-file: Document dependency on OpenSSL devel libraries PKCS#7: Appropriately restrict authenticated attributes and content type KEYS: Add a name for PKEY_ID_PKCS7 PKCS#7: Improve and export the X.509 ASN.1 time object decoder modsign: Use extract-cert to process CONFIG_SYSTEM_TRUSTED_KEYS extract-cert: Cope with multiple X.509 certificates in a single file sign-file: Generate CMS message as signature instead of PKCS#7 PKCS#7: Support CMS messages also [RFC5652] X.509: Change recorded SKID & AKID to not include Subject or Issuer PKCS#7: Check content type and versions MAINTAINERS: The keyrings mailing list has moved ...
2 parents 6f0a2fc + 07f081f commit b793c00

76 files changed

Lines changed: 3588 additions & 1407 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ GTAGS
9797
# Leavings from module signing
9898
#
9999
extra_certificates
100+
signing_key.pem
100101
signing_key.priv
101102
signing_key.x509
102103
x509.genkey

‎Documentation/Changes‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ o udev 081 # udevd --version
4343
o grub 0.93 # grub --version || grub-install --version
4444
o mcelog 0.6 # mcelog --version
4545
o iptables 1.4.2 # iptables -V
46+
o openssl & libcrypto 1.0.1k # openssl version
4647

4748

4849
Kernel compilation
@@ -79,6 +80,17 @@ BC
7980
You will need bc to build kernels 3.10 and higher
8081

8182

83+
OpenSSL
84+
-------
85+
86+
Module signing and external certificate handling use the OpenSSL program and
87+
crypto library to do key creation and signature generation.
88+
89+
You will need openssl to build kernels 3.7 and higher if module signing is
90+
enabled. You will also need openssl development packages to build kernels 4.3
91+
and higher.
92+
93+
8294
System utilities
8395
================
8496

@@ -295,6 +307,10 @@ Binutils
295307
--------
296308
o <ftp://ftp.kernel.org/pub/linux/devel/binutils/>
297309

310+
OpenSSL
311+
-------
312+
o <https://www.openssl.org/>
313+
298314
System utilities
299315
****************
300316

@@ -392,4 +408,3 @@ o <http://oprofile.sf.net/download/>
392408
NFS-Utils
393409
---------
394410
o <http://nfs.sourceforge.net/>
395-

‎Documentation/kbuild/kbuild.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ The output directory is often set using "O=..." on the commandline.
174174

175175
The value can be overridden in which case the default value is ignored.
176176

177+
KBUILD_SIGN_PIN
178+
--------------------------------------------------
179+
This variable allows a passphrase or PIN to be passed to the sign-file
180+
utility when signing kernel modules, if the private key requires such.
181+
177182
KBUILD_MODPOST_WARN
178183
--------------------------------------------------
179184
KBUILD_MODPOST_WARN can be set to avoid errors in case of undefined

‎Documentation/module-signing.txt‎

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,32 @@ This has a number of options available:
8989
their signatures checked without causing a dependency loop.
9090

9191

92+
(4) "File name or PKCS#11 URI of module signing key" (CONFIG_MODULE_SIG_KEY)
93+
94+
Setting this option to something other than its default of
95+
"certs/signing_key.pem" will disable the autogeneration of signing keys
96+
and allow the kernel modules to be signed with a key of your choosing.
97+
The string provided should identify a file containing both a private key
98+
and its corresponding X.509 certificate in PEM form, or — on systems where
99+
the OpenSSL ENGINE_pkcs11 is functional — a PKCS#11 URI as defined by
100+
RFC7512. In the latter case, the PKCS#11 URI should reference both a
101+
certificate and a private key.
102+
103+
If the PEM file containing the private key is encrypted, or if the
104+
PKCS#11 token requries a PIN, this can be provided at build time by
105+
means of the KBUILD_SIGN_PIN variable.
106+
107+
108+
(5) "Additional X.509 keys for default system keyring" (CONFIG_SYSTEM_TRUSTED_KEYS)
109+
110+
This option can be set to the filename of a PEM-encoded file containing
111+
additional certificates which will be included in the system keyring by
112+
default.
113+
114+
Note that enabling module signing adds a dependency on the OpenSSL devel
115+
packages to the kernel build processes for the tool that does the signing.
116+
117+
92118
=======================
93119
GENERATING SIGNING KEYS
94120
=======================
@@ -100,16 +126,16 @@ it can be deleted or stored securely. The public key gets built into the
100126
kernel so that it can be used to check the signatures as the modules are
101127
loaded.
102128

103-
Under normal conditions, the kernel build will automatically generate a new
104-
keypair using openssl if one does not exist in the files:
129+
Under normal conditions, when CONFIG_MODULE_SIG_KEY is unchanged from its
130+
default, the kernel build will automatically generate a new keypair using
131+
openssl if one does not exist in the file:
105132

106-
signing_key.priv
107-
signing_key.x509
133+
certs/signing_key.pem
108134

109135
during the building of vmlinux (the public part of the key needs to be built
110136
into vmlinux) using parameters in the:
111137

112-
x509.genkey
138+
certs/x509.genkey
113139

114140
file (which is also generated if it does not already exist).
115141

@@ -135,8 +161,12 @@ kernel sources tree and the openssl command. The following is an example to
135161
generate the public/private key files:
136162

137163
openssl req -new -nodes -utf8 -sha256 -days 36500 -batch -x509 \
138-
-config x509.genkey -outform DER -out signing_key.x509 \
139-
-keyout signing_key.priv
164+
-config x509.genkey -outform PEM -out kernel_key.pem \
165+
-keyout kernel_key.pem
166+
167+
The full pathname for the resulting kernel_key.pem file can then be specified
168+
in the CONFIG_MODULE_SIG_KEY option, and the certificate and key therein will
169+
be used instead of an autogenerated keypair.
140170

141171

142172
=========================
@@ -152,10 +182,9 @@ in a keyring called ".system_keyring" that can be seen by:
152182
302d2d52 I------ 1 perm 1f010000 0 0 asymmetri Fedora kernel signing key: d69a84e6bce3d216b979e9505b3e3ef9a7118079: X509.RSA a7118079 []
153183
...
154184

155-
Beyond the public key generated specifically for module signing, any file
156-
placed in the kernel source root directory or the kernel build root directory
157-
whose name is suffixed with ".x509" will be assumed to be an X.509 public key
158-
and will be added to the keyring.
185+
Beyond the public key generated specifically for module signing, additional
186+
trusted certificates can be provided in a PEM-encoded file referenced by the
187+
CONFIG_SYSTEM_TRUSTED_KEYS configuration option.
159188

160189
Further, the architecture code may take public keys from a hardware store and
161190
add those in also (e.g. from the UEFI key database).
@@ -181,7 +210,7 @@ To manually sign a module, use the scripts/sign-file tool available in
181210
the Linux kernel source tree. The script requires 4 arguments:
182211

183212
1. The hash algorithm (e.g., sha256)
184-
2. The private key filename
213+
2. The private key filename or PKCS#11 URI
185214
3. The public key filename
186215
4. The kernel module to be signed
187216

@@ -194,6 +223,9 @@ The hash algorithm used does not have to match the one configured, but if it
194223
doesn't, you should make sure that hash algorithm is either built into the
195224
kernel or can be loaded without requiring itself.
196225

226+
If the private key requires a passphrase or PIN, it can be provided in the
227+
$KBUILD_SIGN_PIN environment variable.
228+
197229

198230
============================
199231
SIGNED MODULES AND STRIPPING

‎Documentation/security/Smack.txt‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Smack kernels use the CIPSO IP option. Some network
2828
configurations are intolerant of IP options and can impede
2929
access to systems that use them as Smack does.
3030

31+
Smack is used in the Tizen operating system. Please
32+
go to http://wiki.tizen.org for information about how
33+
Smack is used in Tizen.
34+
3135
The current git repository for Smack user space is:
3236

3337
git://github.com/smack-team/smack.git
@@ -108,6 +112,8 @@ in the smackfs filesystem. This pseudo-filesystem is mounted
108112
on /sys/fs/smackfs.
109113

110114
access
115+
Provided for backward compatibility. The access2 interface
116+
is preferred and should be used instead.
111117
This interface reports whether a subject with the specified
112118
Smack label has a particular access to an object with a
113119
specified Smack label. Write a fixed format access rule to
@@ -136,6 +142,8 @@ change-rule
136142
those in the fourth string. If there is no such rule it will be
137143
created using the access specified in the third and the fourth strings.
138144
cipso
145+
Provided for backward compatibility. The cipso2 interface
146+
is preferred and should be used instead.
139147
This interface allows a specific CIPSO header to be assigned
140148
to a Smack label. The format accepted on write is:
141149
"%24s%4d%4d"["%4d"]...
@@ -157,7 +165,19 @@ direct
157165
doi
158166
This contains the CIPSO domain of interpretation used in
159167
network packets.
168+
ipv6host
169+
This interface allows specific IPv6 internet addresses to be
170+
treated as single label hosts. Packets are sent to single
171+
label hosts only from processes that have Smack write access
172+
to the host label. All packets received from single label hosts
173+
are given the specified label. The format accepted on write is:
174+
"%h:%h:%h:%h:%h:%h:%h:%h label" or
175+
"%h:%h:%h:%h:%h:%h:%h:%h/%d label".
176+
The "::" address shortcut is not supported.
177+
If label is "-DELETE" a matched entry will be deleted.
160178
load
179+
Provided for backward compatibility. The load2 interface
180+
is preferred and should be used instead.
161181
This interface allows access control rules in addition to
162182
the system defined rules to be specified. The format accepted
163183
on write is:
@@ -181,6 +201,8 @@ load2
181201
permissions that are not allowed. The string "r-x--" would
182202
specify read and execute access.
183203
load-self
204+
Provided for backward compatibility. The load-self2 interface
205+
is preferred and should be used instead.
184206
This interface allows process specific access rules to be
185207
defined. These rules are only consulted if access would
186208
otherwise be permitted, and are intended to provide additional
@@ -205,6 +227,8 @@ netlabel
205227
received from single label hosts are given the specified
206228
label. The format accepted on write is:
207229
"%d.%d.%d.%d label" or "%d.%d.%d.%d/%d label".
230+
If the label specified is "-CIPSO" the address is treated
231+
as a host that supports CIPSO headers.
208232
onlycap
209233
This contains labels processes must have for CAP_MAC_ADMIN
210234
and CAP_MAC_OVERRIDE to be effective. If this file is empty
@@ -232,7 +256,8 @@ unconfined
232256
is dangerous and can ruin the proper labeling of your system.
233257
It should never be used in production.
234258

235-
You can add access rules in /etc/smack/accesses. They take the form:
259+
If you are using the smackload utility
260+
you can add access rules in /etc/smack/accesses. They take the form:
236261

237262
subjectlabel objectlabel access
238263

‎Documentation/security/Yama.txt‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
Yama is a Linux Security Module that collects a number of system-wide DAC
2-
security protections that are not handled by the core kernel itself. To
3-
select it at boot time, specify "security=yama" (though this will disable
4-
any other LSM).
5-
6-
Yama is controlled through sysctl in /proc/sys/kernel/yama:
1+
Yama is a Linux Security Module that collects system-wide DAC security
2+
protections that are not handled by the core kernel itself. This is
3+
selectable at build-time with CONFIG_SECURITY_YAMA, and can be controlled
4+
at run-time through sysctls in /proc/sys/kernel/yama:
75

86
- ptrace_scope
97

‎MAINTAINERS‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,6 +2621,15 @@ S: Supported
26212621
F: Documentation/filesystems/ceph.txt
26222622
F: fs/ceph/
26232623

2624+
CERTIFICATE HANDLING:
2625+
M: David Howells <dhowells@redhat.com>
2626+
M: David Woodhouse <dwmw2@infradead.org>
2627+
L: keyrings@linux-nfs.org
2628+
S: Maintained
2629+
F: Documentation/module-signing.txt
2630+
F: certs/
2631+
F: scripts/extract-cert.c
2632+
26242633
CERTIFIED WIRELESS USB (WUSB) SUBSYSTEM:
26252634
L: linux-usb@vger.kernel.org
26262635
S: Orphan
@@ -5994,7 +6003,7 @@ F: kernel/kexec.c
59946003

59956004
KEYS/KEYRINGS:
59966005
M: David Howells <dhowells@redhat.com>
5997-
L: keyrings@linux-nfs.org
6006+
L: keyrings@vger.kernel.org
59986007
S: Maintained
59996008
F: Documentation/security/keys.txt
60006009
F: include/linux/key.h
@@ -6006,7 +6015,7 @@ KEYS-TRUSTED
60066015
M: David Safford <safford@us.ibm.com>
60076016
M: Mimi Zohar <zohar@linux.vnet.ibm.com>
60086017
L: linux-security-module@vger.kernel.org
6009-
L: keyrings@linux-nfs.org
6018+
L: keyrings@vger.kernel.org
60106019
S: Supported
60116020
F: Documentation/security/keys-trusted-encrypted.txt
60126021
F: include/keys/trusted-type.h
@@ -6017,7 +6026,7 @@ KEYS-ENCRYPTED
60176026
M: Mimi Zohar <zohar@linux.vnet.ibm.com>
60186027
M: David Safford <safford@us.ibm.com>
60196028
L: linux-security-module@vger.kernel.org
6020-
L: keyrings@linux-nfs.org
6029+
L: keyrings@vger.kernel.org
60216030
S: Supported
60226031
F: Documentation/security/keys-trusted-encrypted.txt
60236032
F: include/keys/encrypted-type.h
@@ -9264,6 +9273,12 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/jj/apparmor-dev.git
92649273
S: Supported
92659274
F: security/apparmor/
92669275

9276+
YAMA SECURITY MODULE
9277+
M: Kees Cook <keescook@chromium.org>
9278+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git yama/tip
9279+
S: Supported
9280+
F: security/yama/
9281+
92679282
SENSABLE PHANTOM
92689283
M: Jiri Slaby <jirislaby@gmail.com>
92699284
S: Maintained

‎Makefile‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -875,18 +875,17 @@ INITRD_COMPRESS-$(CONFIG_RD_LZ4) := lz4
875875
# export INITRD_COMPRESS := $(INITRD_COMPRESS-y)
876876

877877
ifdef CONFIG_MODULE_SIG_ALL
878-
MODSECKEY = ./signing_key.priv
879-
MODPUBKEY = ./signing_key.x509
880-
export MODPUBKEY
881-
mod_sign_cmd = perl $(srctree)/scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODSECKEY) $(MODPUBKEY)
878+
$(eval $(call config_filename,MODULE_SIG_KEY))
879+
880+
mod_sign_cmd = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY) certs/signing_key.x509
882881
else
883882
mod_sign_cmd = true
884883
endif
885884
export mod_sign_cmd
886885

887886

888887
ifeq ($(KBUILD_EXTMOD),)
889-
core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
888+
core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
890889

891890
vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
892891
$(core-y) $(core-m) $(drivers-y) $(drivers-m) \
@@ -1178,8 +1177,8 @@ MRPROPER_DIRS += include/config usr/include include/generated \
11781177
arch/*/include/generated .tmp_objdiff
11791178
MRPROPER_FILES += .config .config.old .version .old_version \
11801179
Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
1181-
signing_key.priv signing_key.x509 x509.genkey \
1182-
extra_certificates signing_key.x509.keyid \
1180+
signing_key.pem signing_key.priv signing_key.x509 \
1181+
x509.genkey extra_certificates signing_key.x509.keyid \
11831182
signing_key.x509.signer vmlinux-gdb.py
11841183

11851184
# clean - Delete most, but leave enough to build external modules

‎arch/mips/configs/pistachio_defconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ CONFIG_KEYS=y
320320
CONFIG_SECURITY=y
321321
CONFIG_SECURITY_NETWORK=y
322322
CONFIG_SECURITY_YAMA=y
323-
CONFIG_SECURITY_YAMA_STACKED=y
324323
CONFIG_DEFAULT_SECURITY_DAC=y
325324
CONFIG_CRYPTO_AUTHENC=y
326325
CONFIG_CRYPTO_HMAC=y

‎arch/x86/kernel/kexec-bzimage64.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,9 @@ static int bzImage64_verify_sig(const char *kernel, unsigned long kernel_len)
533533
int ret;
534534

535535
ret = verify_pefile_signature(kernel, kernel_len,
536-
system_trusted_keyring, &trusted);
536+
system_trusted_keyring,
537+
VERIFYING_KEXEC_PE_SIGNATURE,
538+
&trusted);
537539
if (ret < 0)
538540
return ret;
539541
if (!trusted)

0 commit comments

Comments
 (0)