09 Sep, 2015

1 commit

  • Pull security subsystem updates from James Morris:
    "Highlights:

    - PKCS#7 support added to support signed kexec, also utilized for
    module signing. See comments in 3f1e1bea.

    ** 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
    ...

    Linus Torvalds
     

03 Sep, 2015

1 commit

  • Pull SG updates from Jens Axboe:
    "This contains a set of scatter-gather related changes/fixes for 4.3:

    - Add support for limited chaining of sg tables even for
    architectures that do not set ARCH_HAS_SG_CHAIN. From Christoph.

    - Add sg chain support to target_rd. From Christoph.

    - Fixup open coded sg->page_link in crypto/omap-sham. From
    Christoph.

    - Fixup open coded crypto ->page_link manipulation. From Dan.

    - Also from Dan, automated fixup of manual sg_unmark_end()
    manipulations.

    - Also from Dan, automated fixup of open coded sg_phys()
    implementations.

    - From Robert Jarzmik, addition of an sg table splitting helper that
    drivers can use"

    * 'for-4.3/sg' of git://git.kernel.dk/linux-block:
    lib: scatterlist: add sg splitting function
    scatterlist: use sg_phys()
    crypto/omap-sham: remove an open coded access to ->page_link
    scatterlist: remove open coded sg_unmark_end instances
    crypto: replace scatterwalk_sg_chain with sg_chain
    target/rd: always chain S/G list
    scatterlist: allow limited chaining without ARCH_HAS_SG_CHAIN

    Linus Torvalds
     

21 Aug, 2015

2 commits

  • This patch adds the helper AHASH_REQUEST_ON_STACK for those users
    of ahash that are synchronous only.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • This patch introduces the crypto skcipher interface which aims
    to replace both blkcipher and ablkcipher.

    It's very similar to the existing ablkcipher interface. The
    main difference is the removal of the givcrypt interface. In
    order to make the transition easier for blkcipher users, there
    is a helper SKCIPHER_REQUEST_ON_STACK which can be used to place
    a request on the stack for synchronous transforms.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

17 Aug, 2015

3 commits


13 Aug, 2015

1 commit

  • A PKCS#7 or CMS message can have per-signature authenticated attributes
    that are digested as a lump and signed by the authorising key for that
    signature. If such attributes exist, the content digest isn't itself
    signed, but rather it is included in a special authattr which then
    contributes to the signature.

    Further, we already require the master message content type to be
    pkcs7_signedData - but there's also a separate content type for the data
    itself within the SignedData object and this must be repeated inside the
    authattrs for each signer [RFC2315 9.2, RFC5652 11.1].

    We should really validate the authattrs if they exist or forbid them
    entirely as appropriate. To this end:

    (1) Alter the PKCS#7 parser to reject any message that has more than one
    signature where at least one signature has authattrs and at least one
    that does not.

    (2) Validate authattrs if they are present and strongly restrict them.
    Only the following authattrs are permitted and all others are
    rejected:

    (a) contentType. This is checked to be an OID that matches the
    content type in the SignedData object.

    (b) messageDigest. This must match the crypto digest of the data.

    (c) signingTime. If present, we check that this is a valid, parseable
    UTCTime or GeneralTime and that the date it encodes fits within
    the validity window of the matching X.509 cert.

    (d) S/MIME capabilities. We don't check the contents.

    (e) Authenticode SP Opus Info. We don't check the contents.

    (f) Authenticode Statement Type. We don't check the contents.

    The message is rejected if (a) or (b) are missing. If the message is
    an Authenticode type, the message is rejected if (e) is missing; if
    not Authenticode, the message is rejected if (d) - (f) are present.

    The S/MIME capabilities authattr (d) unfortunately has to be allowed
    to support kernels already signed by the pesign program. This only
    affects kexec. sign-file suppresses them (CMS_NOSMIMECAP).

    The message is also rejected if an authattr is given more than once or
    if it contains more than one element in its set of values.

    (3) Add a parameter to pkcs7_verify() to select one of the following
    restrictions and pass in the appropriate option from the callers:

    (*) VERIFYING_MODULE_SIGNATURE

    This requires that the SignedData content type be pkcs7-data and
    forbids authattrs. sign-file sets CMS_NOATTR. We could be more
    flexible and permit authattrs optionally, but only permit minimal
    content.

    (*) VERIFYING_FIRMWARE_SIGNATURE

    This requires that the SignedData content type be pkcs7-data and
    requires authattrs. In future, this will require an attribute
    holding the target firmware name in addition to the minimal set.

    (*) VERIFYING_UNSPECIFIED_SIGNATURE

    This requires that the SignedData content type be pkcs7-data but
    allows either no authattrs or only permits the minimal set.

    (*) VERIFYING_KEXEC_PE_SIGNATURE

    This only supports the Authenticode SPC_INDIRECT_DATA content type
    and requires at least an SpcSpOpusInfo authattr in addition to the
    minimal set. It also permits an SPC_STATEMENT_TYPE authattr (and
    an S/MIME capabilities authattr because the pesign program doesn't
    remove these).

    (*) VERIFYING_KEY_SIGNATURE
    (*) VERIFYING_KEY_SELF_SIGNATURE

    These are invalid in this context but are included for later use
    when limiting the use of X.509 certs.

    (4) The pkcs7_test key type is given a module parameter to select between
    the above options for testing purposes. For example:

    echo 1 >/sys/module/pkcs7_test_key/parameters/usage
    keyctl padd pkcs7_test foo @s
    Signed-off-by: David Howells
    Reviewed-by: Marcel Holtmann
    Reviewed-by: David Woodhouse

    David Howells
     

07 Aug, 2015

3 commits

  • Provide a utility that:

    (1) Digests a module using the specified hash algorithm (typically sha256).

    [The digest can be dumped into a file by passing the '-d' flag]

    (2) Generates a PKCS#7 message that:

    (a) Has detached data (ie. the module content).

    (b) Is signed with the specified private key.

    (c) Refers to the specified X.509 certificate.

    (d) Has an empty X.509 certificate list.

    [The PKCS#7 message can be dumped into a file by passing the '-p' flag]

    (3) Generates a signed module by concatenating the old module, the PKCS#7
    message, a descriptor and a magic string. The descriptor contains the
    size of the PKCS#7 message and indicates the id_type as PKEY_ID_PKCS7.

    (4) Either writes the signed module to the specified destination or renames
    it over the source module.

    This allows module signing to reuse the PKCS#7 handling code that was added
    for PE file parsing for signed kexec.

    Note that the utility is written in C and must be linked against the OpenSSL
    crypto library.

    Note further that I have temporarily dropped support for handling externally
    created signatures until we can work out the best way to do those. Hopefully,
    whoever creates the signature can give me a PKCS#7 certificate.

    Signed-off-by: David Howells
    Tested-by: Vivek Goyal

    David Howells
     
  • It is possible for a PKCS#7 message to have detached data. However, to verify
    the signatures on a PKCS#7 message, we have to be able to digest the data.
    Provide a function to supply that data. An error is given if the PKCS#7
    message included embedded data.

    This is used in a subsequent patch to supply the data to module signing where
    the signature is in the form of a PKCS#7 message with detached data, whereby
    the detached data is the module content that is signed.

    Signed-off-by: David Howells
    Tested-by: Vivek Goyal

    David Howells
     
  • If an X.509 certificate has an AuthorityKeyIdentifier extension that provides
    an issuer and serialNumber, then make it so that these are used in preference
    to the keyIdentifier field also held therein for searching for the signing
    certificate.

    If both the issuer+serialNumber and the keyIdentifier are supplied, then the
    certificate is looked up by the former but the latter is checked as well. If
    the latter doesn't match the subjectKeyIdentifier of the parent certificate,
    EKEYREJECTED is returned.

    This makes it possible to chain X.509 certificates based on the issuer and
    serialNumber fields rather than on subjectKeyIdentifier. This is necessary as
    we are having to deal with keys that are represented by X.509 certificates
    that lack a subjectKeyIdentifier.

    Signed-off-by: David Howells
    Tested-by: Vivek Goyal

    David Howells
     

04 Aug, 2015

1 commit


17 Jul, 2015

2 commits


14 Jul, 2015

4 commits


22 Jun, 2015

1 commit

  • Currently we free the default RNG when its use count hits zero.
    This was OK when the IV generators would latch onto the RNG at
    instance creation time and keep it until the instance is torn
    down.

    Now that IV generators only keep the RNG reference during init
    time this scheme causes the default RNG to come and go at a high
    frequencey. This is highly undesirable as we want to keep a single
    RNG in use unless the admin wants it to be removed.

    This patch changes the scheme so that the system RNG once allocated
    is never removed unless a specifically requested.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

19 Jun, 2015

1 commit

  • The struct aead_instance is meant to extend struct crypto_instance
    by incorporating the extra members of struct aead_alg. However,
    the current layout which is copied from shash/ahash does not specify
    the struct fully. In particular only aead_alg is present.

    For shash/ahash this works because users there add extra headroom
    to sizeof(struct crypto_instance) when allocating the instance.
    Unfortunately for aead, this bit was lost when the new aead_instance
    was added.

    Rather than fixing it like shash/ahash, this patch simply expands
    struct aead_instance to contain what is supposed to be there, i.e.,
    adding struct crypto_instance.

    In order to not break existing AEAD users, this is done through an
    anonymous union.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

17 Jun, 2015

2 commits


10 Jun, 2015

2 commits

  • As required by SP800-90A, the DRBG implements are reseeding threshold.
    This threshold is at 2**48 (64 bit) and 2**32 bit (32 bit) as
    implemented in drbg_max_requests.

    With the recently introduced changes, the DRBG is now always used as a
    stdrng which is initialized very early in the boot cycle. To ensure that
    sufficient entropy is present, the Jitter RNG is added to even provide
    entropy at early boot time.

    However, the 2nd seed source, the nonblocking pool, is usually
    degraded at that time. Therefore, the DRBG is seeded with the Jitter RNG
    (which I believe contains good entropy, which however is questioned by
    others) and is seeded with a degradded nonblocking pool. This seed is
    now used for quasi the lifetime of the system (2**48 requests is a lot).

    The patch now changes the reseed threshold as follows: up until the time
    the DRBG obtains a seed from a fully iniitialized nonblocking pool, the
    reseeding threshold is lowered such that the DRBG is forced to reseed
    itself resonably often. Once it obtains the seed from a fully
    initialized nonblocking pool, the reseed threshold is set to the value
    required by SP800-90A.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • The get_blocking_random_bytes API is broken because the wait can
    be arbitrarily long (potentially forever) so there is no safe way
    of calling it from within the kernel.

    This patch replaces it with the new callback API which does not
    have this problem.

    The patch also removes the entropy buffer registered with the DRBG
    handle in favor of stack variables to hold the seed data.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     

04 Jun, 2015

1 commit


03 Jun, 2015

5 commits


28 May, 2015

2 commits

  • This patch adds some common IV generation code currently duplicated
    by seqiv and echainiv. For example, the setkey and setauthsize
    functions are completely identical.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • This patch defines the behaviour of AD in the new interface more
    clearly. In particular, it specifies that if the user must copy
    the AD to the destination manually when src != dst if they wish
    to guarantee that the destination buffer contains a copy of the
    AD.

    The reason for this is that otherwise every AEAD implementation
    would have to perform such a copy when src != dst. In reality
    most users do in-place processing where src == dst so this is
    not an issue.

    This patch also kills some remaining references to cryptoff.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

27 May, 2015

3 commits

  • During initialization, the DRBG now tries to allocate a handle of the
    Jitter RNG. If such a Jitter RNG is available during seeding, the DRBG
    pulls the required entropy/nonce string from get_random_bytes and
    concatenates it with a string of equal size from the Jitter RNG. That
    combined string is now the seed for the DRBG.

    Written differently, the initial seed of the DRBG is now:

    get_random_bytes(entropy/nonce) || jitterentropy (entropy/nonce)

    If the Jitter RNG is not available, the DRBG only seeds from
    get_random_bytes.

    CC: Andreas Steffen
    CC: Theodore Ts'o
    CC: Sandy Harris
    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • The async seeding operation is triggered during initalization right
    after the first non-blocking seeding is completed. As required by the
    asynchronous operation of random.c, a callback function is provided that
    is triggered by random.c once entropy is available. That callback
    function performs the actual seeding of the DRBG.

    CC: Andreas Steffen
    CC: Theodore Ts'o
    CC: Sandy Harris
    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • In order to prepare for the addition of the asynchronous seeding call,
    the invocation of seeding the DRBG is moved out into a helper function.

    In addition, a block of memory is allocated during initialization time
    that will be used as a scratchpad for obtaining entropy. That scratchpad
    is used for the initial seeding operation as well as by the
    asynchronous seeding call. The memory must be zeroized every time the
    DRBG seeding call succeeds to avoid entropy data lingering in memory.

    CC: Andreas Steffen
    CC: Theodore Ts'o
    CC: Sandy Harris
    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     

25 May, 2015

2 commits


22 May, 2015

3 commits

  • This patch converts the seqiv IV generator to work with the new
    AEAD interface where IV generators are just normal AEAD algorithms.

    Full backwards compatibility is paramount at this point since
    no users have yet switched over to the new interface. Nor can
    they switch to the new interface until IV generation is fully
    supported by it.

    So this means we are adding two versions of seqiv alongside the
    existing one. The first one is the one that will be used when
    the underlying AEAD algorithm has switched over to the new AEAD
    interface. The second one handles the current case where the
    underlying AEAD algorithm still uses the old interface.

    Both versions export themselves through the new AEAD interface.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • This patch adds a default null skcipher for users such as gcm
    to perform copies on SG lists.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • This patch adds the basic structure of the new AEAD type. Unlike
    the current version, there is no longer any concept of geniv. IV
    generation will still be carried out by wrappers but they will be
    normal AEAD algorithms that simply take the IPsec sequence number
    as the IV.

    Signed-off-by: Herbert Xu

    Herbert Xu