Skip to content

Commit

Permalink
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/…
Browse files Browse the repository at this point in the history
…jmorris/linux-security

Pull security subsystem update from James Morris:
 "This is mostly maintenance updates across the subsystem, with a
  notable update for TPM 2.0, and addition of Jarkko Sakkinen as a
  maintainer of that"

* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (40 commits)
  apparmor: clarify CRYPTO dependency
  selinux: Use a kmem_cache for allocation struct file_security_struct
  selinux: ioctl_has_perm should be static
  selinux: use sprintf return value
  selinux: use kstrdup() in security_get_bools()
  selinux: use kmemdup in security_sid_to_context_core()
  selinux: remove pointless cast in selinux_inode_setsecurity()
  selinux: introduce security_context_str_to_sid
  selinux: do not check open perm on ftruncate call
  selinux: change CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE default
  KEYS: Merge the type-specific data with the payload data
  KEYS: Provide a script to extract a module signature
  KEYS: Provide a script to extract the sys cert list from a vmlinux file
  keys: Be more consistent in selection of union members used
  certs: add .gitignore to stop git nagging about x509_certificate_list
  KEYS: use kvfree() in add_key
  Smack: limited capability for changing process label
  TPM: remove unnecessary little endian conversion
  vTPM: support little endian guests
  char: Drop owner assignment from i2c_driver
  ...
  • Loading branch information
torvalds committed Nov 5, 2015
2 parents 3460b01 + ba94c3f commit 1873499
Show file tree
Hide file tree
Showing 89 changed files with 1,748 additions and 492 deletions.
19 changes: 12 additions & 7 deletions Documentation/ABI/testing/sysfs-driver-ppi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
What: /sys/devices/pnp0/<bus-num>/ppi/
What: /sys/class/tpm/tpmX/ppi/
Date: August 2012
Kernel Version: 3.6
Contact: [email protected]
Expand All @@ -8,17 +8,22 @@ Description:
folder makes sense. The folder path can be got by command
'find /sys/ -name 'pcrs''. For the detail information of PPI,
please refer to the PPI specification from

http://www.trustedcomputinggroup.org/

What: /sys/devices/pnp0/<bus-num>/ppi/version
In Linux 4.2 ppi was moved to the character device directory.
A symlink from tpmX/device/ppi to tpmX/ppi to provide backwards
compatibility.

What: /sys/class/tpm/tpmX/ppi/version
Date: August 2012
Contact: [email protected]
Description:
This attribute shows the version of the PPI supported by the
platform.
This file is readonly.

What: /sys/devices/pnp0/<bus-num>/ppi/request
What: /sys/class/tpm/tpmX/ppi/request
Date: August 2012
Contact: [email protected]
Description:
Expand All @@ -28,7 +33,7 @@ Description:
integer value range from 1 to 160, and 0 means no request.
This file can be read and written.

What: /sys/devices/pnp0/00:<bus-num>/ppi/response
What: /sys/class/tpm/tpmX/ppi/response
Date: August 2012
Contact: [email protected]
Description:
Expand All @@ -37,7 +42,7 @@ Description:
: <response description>".
This file is readonly.

What: /sys/devices/pnp0/<bus-num>/ppi/transition_action
What: /sys/class/tpm/tpmX/ppi/transition_action
Date: August 2012
Contact: [email protected]
Description:
Expand All @@ -47,7 +52,7 @@ Description:
description>".
This file is readonly.

What: /sys/devices/pnp0/<bus-num>/ppi/tcg_operations
What: /sys/class/tpm/tpmX/ppi/tcg_operations
Date: August 2012
Contact: [email protected]
Description:
Expand All @@ -58,7 +63,7 @@ Description:
This attribute is only supported by PPI version 1.2+.
This file is readonly.

What: /sys/devices/pnp0/<bus-num>/ppi/vs_operations
What: /sys/class/tpm/tpmX/ppi/vs_operations
Date: August 2012
Contact: [email protected]
Description:
Expand Down
27 changes: 14 additions & 13 deletions Documentation/crypto/asymmetric-keys.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ and looks like the following:
const struct public_key_signature *sig);
};

Asymmetric keys point to this with their type_data[0] member.
Asymmetric keys point to this with their payload[asym_subtype] member.

The owner and name fields should be set to the owning module and the name of
the subtype. Currently, the name is only used for print statements.
Expand Down Expand Up @@ -269,8 +269,7 @@ mandatory:

struct key_preparsed_payload {
char *description;
void *type_data[2];
void *payload;
void *payload[4];
const void *data;
size_t datalen;
size_t quotalen;
Expand All @@ -283,16 +282,18 @@ mandatory:
not theirs.

If the parser is happy with the blob, it should propose a description for
the key and attach it to ->description, ->type_data[0] should be set to
point to the subtype to be used, ->payload should be set to point to the
initialised data for that subtype, ->type_data[1] should point to a hex
fingerprint and quotalen should be updated to indicate how much quota this
key should account for.

When clearing up, the data attached to ->type_data[1] and ->description
will be kfree()'d and the data attached to ->payload will be passed to the
subtype's ->destroy() method to be disposed of. A module reference for
the subtype pointed to by ->type_data[0] will be put.
the key and attach it to ->description, ->payload[asym_subtype] should be
set to point to the subtype to be used, ->payload[asym_crypto] should be
set to point to the initialised data for that subtype,
->payload[asym_key_ids] should point to one or more hex fingerprints and
quotalen should be updated to indicate how much quota this key should
account for.

When clearing up, the data attached to ->payload[asym_key_ids] and
->description will be kfree()'d and the data attached to
->payload[asm_crypto] will be passed to the subtype's ->destroy() method
to be disposed of. A module reference for the subtype pointed to by
->payload[asym_subtype] will be put.


If the data format is not recognised, -EBADMSG should be returned. If it
Expand Down
10 changes: 10 additions & 0 deletions Documentation/security/Smack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,16 @@ unconfined
the access permitted if it wouldn't be otherwise. Note that this
is dangerous and can ruin the proper labeling of your system.
It should never be used in production.
relabel-self
This interface contains a list of labels to which the process can
transition to, by writing to /proc/self/attr/current.
Normally a process can change its own label to any legal value, but only
if it has CAP_MAC_ADMIN. This interface allows a process without
CAP_MAC_ADMIN to relabel itself to one of labels from predefined list.
A process without CAP_MAC_ADMIN can change its label only once. When it
does, this list will be cleared.
The values are set by writing the desired labels, separated
by spaces, to the file or cleared by writing "-" to the file.

If you are using the smackload utility
you can add access rules in /etc/smack/accesses. They take the form:
Expand Down
41 changes: 25 additions & 16 deletions Documentation/security/keys.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1049,12 +1049,12 @@ search a specific keyring, so using keyrings in this way is of limited utility.
NOTES ON ACCESSING PAYLOAD CONTENTS
===================================

The simplest payload is just a number in key->payload.value. In this case,
there's no need to indulge in RCU or locking when accessing the payload.
The simplest payload is just data stored in key->payload directly. In this
case, there's no need to indulge in RCU or locking when accessing the payload.

More complex payload contents must be allocated and a pointer to them set in
key->payload.data. One of the following ways must be selected to access the
data:
More complex payload contents must be allocated and pointers to them set in the
key->payload.data[] array. One of the following ways must be selected to
access the data:

(1) Unmodifiable key type.

Expand Down Expand Up @@ -1092,6 +1092,13 @@ data:
the payload. key->datalen cannot be relied upon to be consistent with the
payload just dereferenced if the key's semaphore is not held.

Note that key->payload.data[0] has a shadow that is marked for __rcu
usage. This is called key->payload.rcu_data0. The following accessors
wrap the RCU calls to this element:

rcu_assign_keypointer(struct key *key, void *data);
void *rcu_dereference_key(struct key *key);


===================
DEFINING A KEY TYPE
Expand Down Expand Up @@ -1143,8 +1150,7 @@ The structure has a number of fields, some of which are mandatory:

struct key_preparsed_payload {
char *description;
void *type_data[2];
void *payload;
union key_payload payload;
const void *data;
size_t datalen;
size_t quotalen;
Expand All @@ -1160,10 +1166,9 @@ The structure has a number of fields, some of which are mandatory:
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. If
set, the expiry time will be applied to the key if it is instantiated from
this data.
The method can attach anything it likes to payload. This is 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 successful or a negative error code
otherwise.
Expand All @@ -1172,11 +1177,10 @@ The structure has a number of fields, some of which are mandatory:
(*) void (*free_preparse)(struct key_preparsed_payload *prep);

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. It will always be called
after preparse() returns successfully, even if instantiate() or update()
succeed.
otherwise it is unused. It cleans up anything attached to the description
and payload fields of the key_preparsed_payload 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);
Expand All @@ -1197,6 +1201,11 @@ The structure has a number of fields, some of which are mandatory:

It is safe to sleep in this method.

generic_key_instantiate() is provided to simply copy the data from
prep->payload.data[] to key->payload.data[], with RCU-safe assignment on
the first element. It will then clear prep->payload.data[] so that the
free_preparse method doesn't release the data.


(*) int (*update)(struct key *key, const void *data, size_t datalen);

Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -10738,6 +10738,7 @@ F: drivers/media/pci/tw68/
TPM DEVICE DRIVER
M: Peter Huewe <[email protected]>
M: Marcel Selhorst <[email protected]>
M: Jarkko Sakkinen <[email protected]>
R: Jason Gunthorpe <[email protected]>
W: http://tpmdd.sourceforge.net
L: [email protected] (moderated for non-subscribers)
Expand Down
40 changes: 30 additions & 10 deletions arch/powerpc/kernel/prom_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1425,27 +1425,45 @@ static void __init prom_instantiate_sml(void)
{
phandle ibmvtpm_node;
ihandle ibmvtpm_inst;
u32 entry = 0, size = 0;
u32 entry = 0, size = 0, succ = 0;
u64 base;
__be32 val;

prom_debug("prom_instantiate_sml: start...\n");

ibmvtpm_node = call_prom("finddevice", 1, 1, ADDR("/ibm,vtpm"));
ibmvtpm_node = call_prom("finddevice", 1, 1, ADDR("/vdevice/vtpm"));
prom_debug("ibmvtpm_node: %x\n", ibmvtpm_node);
if (!PHANDLE_VALID(ibmvtpm_node))
return;

ibmvtpm_inst = call_prom("open", 1, 1, ADDR("/ibm,vtpm"));
ibmvtpm_inst = call_prom("open", 1, 1, ADDR("/vdevice/vtpm"));
if (!IHANDLE_VALID(ibmvtpm_inst)) {
prom_printf("opening vtpm package failed (%x)\n", ibmvtpm_inst);
return;
}

if (call_prom_ret("call-method", 2, 2, &size,
ADDR("sml-get-handover-size"),
ibmvtpm_inst) != 0 || size == 0) {
prom_printf("SML get handover size failed\n");
return;
if (prom_getprop(ibmvtpm_node, "ibm,sml-efi-reformat-supported",
&val, sizeof(val)) != PROM_ERROR) {
if (call_prom_ret("call-method", 2, 2, &succ,
ADDR("reformat-sml-to-efi-alignment"),
ibmvtpm_inst) != 0 || succ == 0) {
prom_printf("Reformat SML to EFI alignment failed\n");
return;
}

if (call_prom_ret("call-method", 2, 2, &size,
ADDR("sml-get-allocated-size"),
ibmvtpm_inst) != 0 || size == 0) {
prom_printf("SML get allocated size failed\n");
return;
}
} else {
if (call_prom_ret("call-method", 2, 2, &size,
ADDR("sml-get-handover-size"),
ibmvtpm_inst) != 0 || size == 0) {
prom_printf("SML get handover size failed\n");
return;
}
}

base = alloc_down(size, PAGE_SIZE, 0);
Expand All @@ -1454,6 +1472,8 @@ static void __init prom_instantiate_sml(void)

prom_printf("instantiating sml at 0x%x...", base);

memset((void *)base, 0, size);

if (call_prom_ret("call-method", 4, 2, &entry,
ADDR("sml-handover"),
ibmvtpm_inst, size, base) != 0 || entry == 0) {
Expand All @@ -1464,9 +1484,9 @@ static void __init prom_instantiate_sml(void)

reserve_mem(base, size);

prom_setprop(ibmvtpm_node, "/ibm,vtpm", "linux,sml-base",
prom_setprop(ibmvtpm_node, "/vdevice/vtpm", "linux,sml-base",
&base, sizeof(base));
prom_setprop(ibmvtpm_node, "/ibm,vtpm", "linux,sml-size",
prom_setprop(ibmvtpm_node, "/vdevice/vtpm", "linux,sml-size",
&size, sizeof(size));

prom_debug("sml base = 0x%x\n", base);
Expand Down
4 changes: 4 additions & 0 deletions certs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#
# Generated files
#
x509_certificate_list
5 changes: 0 additions & 5 deletions crypto/asymmetric_keys/asymmetric_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,3 @@ extern struct asymmetric_key_id *asymmetric_key_hex_to_key_id(const char *id);
extern int __asymmetric_key_hex_to_key_id(const char *id,
struct asymmetric_key_id *match_id,
size_t hexlen);
static inline
const struct asymmetric_key_ids *asymmetric_key_ids(const struct key *key)
{
return key->type_data.p[1];
}
44 changes: 26 additions & 18 deletions crypto/asymmetric_keys/asymmetric_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,26 +306,35 @@ static int asymmetric_key_preparse(struct key_preparsed_payload *prep)
return ret;
}

/*
* Clean up the key ID list
*/
static void asymmetric_key_free_kids(struct asymmetric_key_ids *kids)
{
int i;

if (kids) {
for (i = 0; i < ARRAY_SIZE(kids->id); i++)
kfree(kids->id[i]);
kfree(kids);
}
}

/*
* Clean up the preparse data
*/
static void asymmetric_key_free_preparse(struct key_preparsed_payload *prep)
{
struct asymmetric_key_subtype *subtype = prep->type_data[0];
struct asymmetric_key_ids *kids = prep->type_data[1];
int i;
struct asymmetric_key_subtype *subtype = prep->payload.data[asym_subtype];
struct asymmetric_key_ids *kids = prep->payload.data[asym_key_ids];

pr_devel("==>%s()\n", __func__);

if (subtype) {
subtype->destroy(prep->payload[0]);
subtype->destroy(prep->payload.data[asym_crypto]);
module_put(subtype->owner);
}
if (kids) {
for (i = 0; i < ARRAY_SIZE(kids->id); i++)
kfree(kids->id[i]);
kfree(kids);
}
asymmetric_key_free_kids(kids);
kfree(prep->description);
}

Expand All @@ -335,20 +344,19 @@ static void asymmetric_key_free_preparse(struct key_preparsed_payload *prep)
static void asymmetric_key_destroy(struct key *key)
{
struct asymmetric_key_subtype *subtype = asymmetric_key_subtype(key);
struct asymmetric_key_ids *kids = key->type_data.p[1];
struct asymmetric_key_ids *kids = key->payload.data[asym_key_ids];
void *data = key->payload.data[asym_crypto];

key->payload.data[asym_crypto] = NULL;
key->payload.data[asym_subtype] = NULL;
key->payload.data[asym_key_ids] = NULL;

if (subtype) {
subtype->destroy(key->payload.data);
subtype->destroy(data);
module_put(subtype->owner);
key->type_data.p[0] = NULL;
}

if (kids) {
kfree(kids->id[0]);
kfree(kids->id[1]);
kfree(kids);
key->type_data.p[1] = NULL;
}
asymmetric_key_free_kids(kids);
}

struct key_type key_type_asymmetric = {
Expand Down
Loading

0 comments on commit 1873499

Please sign in to comment.