14 Dec, 2020

1 commit

  • Secure keys are derieved using CAAM crypto block.

    Secure keys derieved are the random number symmetric keys from CAAM.
    Blobs corresponding to the key are formed using CAAM. User space
    will only be able to view the blob of the key.

    Signed-off-by: Udit Agarwal

    Reviewed-by: Sahil Malhotra
    [ Aisheng: fix minior conflicts due to
    47f9c2796891 ("KEYS: trusted: Create trusted keys subsystem") ]
    Sign-off-by: Dong Aisheng

    Udit Agarwal
     

10 Sep, 2020

2 commits

  • Commit 15322a0d90b6 ("lsm: remove current_security()") removed
    current_security() from the sources.

    Signed-off-by: Denis Efremov
    Link: https://lore.kernel.org/r/20200830142509.5738-1-efremov@linux.com
    Signed-off-by: Jonathan Corbet

    Denis Efremov
     
  • The parameters in command examples for tpm2_createprimary and
    tpm2_evictcontrol are outdated, people (like me) are not able to create
    trusted key by these command examples.

    This patch updates the parameters of command example tpm2_createprimary
    and tpm2_evictcontrol in trusted-encrypted.rst. With Linux kernel v5.8
    and tpm2-tools-4.1, people can create a trusted key by following the
    examples in this document.

    Signed-off-by: Coly Li
    Reviewed-by: Jarkko Sakkinen
    Reviewed-by: Stefan Berger
    Cc: Dan Williams
    Cc: James Bottomley
    Cc: Jason Gunthorpe
    Cc: Mimi Zohar
    Cc: Peter Huewe
    Link: https://lore.kernel.org/r/20200821135356.15737-1-colyli@suse.de
    Signed-off-by: Jonathan Corbet

    Coly Li
     

13 Jul, 2020

1 commit

  • Drop the doubled word "in".

    Signed-off-by: Randy Dunlap
    Acked-by: Jarkko Sakkinen
    Cc: Jonathan Corbet
    Cc: linux-doc@vger.kernel.org
    Cc: James Bottomley
    Cc: Jarkko Sakkinen
    Cc: Mimi Zohar
    Cc: linux-integrity@vger.kernel.org
    Cc: keyrings@vger.kernel.org
    Link: https://lore.kernel.org/r/20200707180414.10467-19-rdunlap@infradead.org
    Signed-off-by: Jonathan Corbet

    Randy Dunlap
     

07 Jul, 2020

1 commit


06 Jul, 2020

1 commit

  • When making access control choices from a file-based context, f_cred
    must be used instead of current_cred() to avoid confused deputy attacks
    where an open file may get passed to a more privileged process. Add a
    short paragraph to explicitly state the rationale.

    Cc: Jonathan Corbet
    Cc: linux-doc@vger.kernel.org
    Signed-off-by: Kees Cook
    Link: https://lore.kernel.org/r/202007031038.8833A35DE4@keescook
    Signed-off-by: Jonathan Corbet

    Kees Cook
     

20 Jun, 2020

1 commit

  • This file is almost compatible with ReST. Just minor changes
    were needed:

    - Adjust document and titles markups;
    - Adjust numbered list markups;
    - Add a comments markup for the Contents section;
    - Add markups for literal blocks.

    Acked-by: Jarkko Sakkinen
    Signed-off-by: Mauro Carvalho Chehab
    Link: https://lore.kernel.org/r/c2275ea94e0507a01b020ab66dfa824d8b1c2545.1592203650.git.mchehab+huawei@kernel.org
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab
     

14 Jun, 2020

1 commit

  • …git/dhowells/linux-fs

    Pull notification queue from David Howells:
    "This adds a general notification queue concept and adds an event
    source for keys/keyrings, such as linking and unlinking keys and
    changing their attributes.

    Thanks to Debarshi Ray, we do have a pull request to use this to fix a
    problem with gnome-online-accounts - as mentioned last time:

    https://gitlab.gnome.org/GNOME/gnome-online-accounts/merge_requests/47

    Without this, g-o-a has to constantly poll a keyring-based kerberos
    cache to find out if kinit has changed anything.

    [ There are other notification pending: mount/sb fsinfo notifications
    for libmount that Karel Zak and Ian Kent have been working on, and
    Christian Brauner would like to use them in lxc, but let's see how
    this one works first ]

    LSM hooks are included:

    - A set of hooks are provided that allow an LSM to rule on whether or
    not a watch may be set. Each of these hooks takes a different
    "watched object" parameter, so they're not really shareable. The
    LSM should use current's credentials. [Wanted by SELinux & Smack]

    - A hook is provided to allow an LSM to rule on whether or not a
    particular message may be posted to a particular queue. This is
    given the credentials from the event generator (which may be the
    system) and the watch setter. [Wanted by Smack]

    I've provided SELinux and Smack with implementations of some of these
    hooks.

    WHY
    ===

    Key/keyring notifications are desirable because if you have your
    kerberos tickets in a file/directory, your Gnome desktop will monitor
    that using something like fanotify and tell you if your credentials
    cache changes.

    However, we also have the ability to cache your kerberos tickets in
    the session, user or persistent keyring so that it isn't left around
    on disk across a reboot or logout. Keyrings, however, cannot currently
    be monitored asynchronously, so the desktop has to poll for it - not
    so good on a laptop. This facility will allow the desktop to avoid the
    need to poll.

    DESIGN DECISIONS
    ================

    - The notification queue is built on top of a standard pipe. Messages
    are effectively spliced in. The pipe is opened with a special flag:

    pipe2(fds, O_NOTIFICATION_PIPE);

    The special flag has the same value as O_EXCL (which doesn't seem
    like it will ever be applicable in this context)[?]. It is given up
    front to make it a lot easier to prohibit splice&co from accessing
    the pipe.

    [?] Should this be done some other way? I'd rather not use up a new
    O_* flag if I can avoid it - should I add a pipe3() system call
    instead?

    The pipe is then configured::

    ioctl(fds[1], IOC_WATCH_QUEUE_SET_SIZE, queue_depth);
    ioctl(fds[1], IOC_WATCH_QUEUE_SET_FILTER, &filter);

    Messages are then read out of the pipe using read().

    - It should be possible to allow write() to insert data into the
    notification pipes too, but this is currently disabled as the
    kernel has to be able to insert messages into the pipe *without*
    holding pipe->mutex and the code to make this work needs careful
    auditing.

    - sendfile(), splice() and vmsplice() are disabled on notification
    pipes because of the pipe->mutex issue and also because they
    sometimes want to revert what they just did - but one or more
    notification messages might've been interleaved in the ring.

    - The kernel inserts messages with the wait queue spinlock held. This
    means that pipe_read() and pipe_write() have to take the spinlock
    to update the queue pointers.

    - Records in the buffer are binary, typed and have a length so that
    they can be of varying size.

    This allows multiple heterogeneous sources to share a common
    buffer; there are 16 million types available, of which I've used
    just a few, so there is scope for others to be used. Tags may be
    specified when a watchpoint is created to help distinguish the
    sources.

    - Records are filterable as types have up to 256 subtypes that can be
    individually filtered. Other filtration is also available.

    - Notification pipes don't interfere with each other; each may be
    bound to a different set of watches. Any particular notification
    will be copied to all the queues that are currently watching for it
    - and only those that are watching for it.

    - When recording a notification, the kernel will not sleep, but will
    rather mark a queue as having lost a message if there's
    insufficient space. read() will fabricate a loss notification
    message at an appropriate point later.

    - The notification pipe is created and then watchpoints are attached
    to it, using one of:

    keyctl_watch_key(KEY_SPEC_SESSION_KEYRING, fds[1], 0x01);
    watch_mount(AT_FDCWD, "/", 0, fd, 0x02);
    watch_sb(AT_FDCWD, "/mnt", 0, fd, 0x03);

    where in both cases, fd indicates the queue and the number after is
    a tag between 0 and 255.

    - Watches are removed if either the notification pipe is destroyed or
    the watched object is destroyed. In the latter case, a message will
    be generated indicating the enforced watch removal.

    Things I want to avoid:

    - Introducing features that make the core VFS dependent on the
    network stack or networking namespaces (ie. usage of netlink).

    - Dumping all this stuff into dmesg and having a daemon that sits
    there parsing the output and distributing it as this then puts the
    responsibility for security into userspace and makes handling
    namespaces tricky. Further, dmesg might not exist or might be
    inaccessible inside a container.

    - Letting users see events they shouldn't be able to see.

    TESTING AND MANPAGES
    ====================

    - The keyutils tree has a pipe-watch branch that has keyctl commands
    for making use of notifications. Proposed manual pages can also be
    found on this branch, though a couple of them really need to go to
    the main manpages repository instead.

    If the kernel supports the watching of keys, then running "make
    test" on that branch will cause the testing infrastructure to spawn
    a monitoring process on the side that monitors a notifications pipe
    for all the key/keyring changes induced by the tests and they'll
    all be checked off to make sure they happened.

    https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/log/?h=pipe-watch

    - A test program is provided (samples/watch_queue/watch_test) that
    can be used to monitor for keyrings, mount and superblock events.
    Information on the notifications is simply logged to stdout"

    * tag 'notifications-20200601' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
    smack: Implement the watch_key and post_notification hooks
    selinux: Implement the watch_key security hook
    keys: Make the KEY_NEED_* perms an enum rather than a mask
    pipe: Add notification lossage handling
    pipe: Allow buffers to be marked read-whole-or-error for notifications
    Add sample notification program
    watch_queue: Add a key/keyring notification facility
    security: Add hooks to rule on setting a watch
    pipe: Add general notification queue support
    pipe: Add O_NOTIFICATION_PIPE
    security: Add a hook for the point of notification insertion
    uapi: General notification queue definitions

    Linus Torvalds
     

11 Jun, 2020

1 commit

  • Pull more documentation updates from Jonathan Corbet:
    "A handful of late-arriving docs fixes, along with a patch changing a
    lot of HTTP links to HTTPS that had to be yanked and redone before the
    first pull"

    * tag 'docs-5.8-2' of git://git.lwn.net/linux:
    docs/memory-barriers.txt/kokr: smp_mb__{before,after}_atomic(): update Documentation
    Documentation: devres: add missing entry for devm_platform_get_and_ioremap_resource()
    Replace HTTP links with HTTPS ones: documentation
    docs: it_IT: address invalid reference warnings
    doc: zh_CN: use doc reference to resolve undefined label warning
    docs: Update the location of the LF NDA program
    docs: dev-tools: coccinelle: underlines

    Linus Torvalds
     

08 Jun, 2020

1 commit

  • Rationale:
    Reduces attack surface on kernel devs opening the links for MITM
    as HTTPS traffic is much harder to manipulate.

    Deterministic algorithm:
    For each file:
    For each line:
    If doesn't contain `\bxmlns\b`:
    For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
    If both the HTTP and HTTPS versions
    return 200 OK and serve the same content:
    Replace HTTP with HTTPS.

    Signed-off-by: Alexander A. Klimov
    Link: https://lore.kernel.org/r/20200526060544.25127-1-grandmaster@al2klimov.de
    Signed-off-by: Jonathan Corbet

    Alexander A. Klimov
     

05 Jun, 2020

1 commit

  • Pull keyring updates from David Howells:

    - Fix a documentation warning.

    - Replace a zero-length array with a flexible one

    - Make the big_key key type use ChaCha20Poly1305 and use the crypto
    algorithm directly rather than going through the crypto layer.

    - Implement the update op for the big_key type.

    * tag 'keys-next-20200602' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
    keys: Implement update for the big_key type
    security/keys: rewrite big_key crypto to use library interface
    KEYS: Replace zero-length array with flexible-array
    Documentation: security: core.rst: add missing argument

    Linus Torvalds
     

03 Jun, 2020

1 commit


02 Jun, 2020

1 commit

  • Pull documentation updates from Jonathan Corbet:
    "A fair amount of stuff this time around, dominated by yet another
    massive set from Mauro toward the completion of the RST conversion. I
    *really* hope we are getting close to the end of this. Meanwhile,
    those patches reach pretty far afield to update document references
    around the tree; there should be no actual code changes there. There
    will be, alas, more of the usual trivial merge conflicts.

    Beyond that we have more translations, improvements to the sphinx
    scripting, a number of additions to the sysctl documentation, and lots
    of fixes"

    * tag 'docs-5.8' of git://git.lwn.net/linux: (130 commits)
    Documentation: fixes to the maintainer-entry-profile template
    zswap: docs/vm: Fix typo accept_threshold_percent in zswap.rst
    tracing: Fix events.rst section numbering
    docs: acpi: fix old http link and improve document format
    docs: filesystems: add info about efivars content
    Documentation: LSM: Correct the basic LSM description
    mailmap: change email for Ricardo Ribalda
    docs: sysctl/kernel: document unaligned controls
    Documentation: admin-guide: update bug-hunting.rst
    docs: sysctl/kernel: document ngroups_max
    nvdimm: fixes to maintainter-entry-profile
    Documentation/features: Correct RISC-V kprobes support entry
    Documentation/features: Refresh the arch support status files
    Revert "docs: sysctl/kernel: document ngroups_max"
    docs: move locking-specific documents to locking/
    docs: move digsig docs to the security book
    docs: move the kref doc into the core-api book
    docs: add IRQ documentation at the core-api book
    docs: debugging-via-ohci1394.txt: add it to the core-api book
    docs: fix references for ipmi.rst file
    ...

    Linus Torvalds
     

26 May, 2020

1 commit

  • This is a first pass at updating the basic documentation on
    Linux Security Modules (LSM), which is frighteningly out of date.
    Remove untrue statements about the LSM framework. Replace them
    with true statements where it is convenient to do so. This is
    the beginnig of a larger effort to bring the LSM documentation
    up to date.

    Signed-off-by: Casey Schaufler
    Link: https://lore.kernel.org/r/4c053d72-2d58-612f-6d6b-f04226d0181e@schaufler-ca.com
    Signed-off-by: Jonathan Corbet

    Casey Schaufler
     

19 May, 2020

1 commit

  • Add a key/keyring change notification facility whereby notifications about
    changes in key and keyring content and attributes can be received.

    Firstly, an event queue needs to be created:

    pipe2(fds, O_NOTIFICATION_PIPE);
    ioctl(fds[1], IOC_WATCH_QUEUE_SET_SIZE, 256);

    then a notification can be set up to report notifications via that queue:

    struct watch_notification_filter filter = {
    .nr_filters = 1,
    .filters = {
    [0] = {
    .type = WATCH_TYPE_KEY_NOTIFY,
    .subtype_filter[0] = UINT_MAX,
    },
    },
    };
    ioctl(fds[1], IOC_WATCH_QUEUE_SET_FILTER, &filter);
    keyctl_watch_key(KEY_SPEC_SESSION_KEYRING, fds[1], 0x01);

    After that, records will be placed into the queue when events occur in
    which keys are changed in some way. Records are of the following format:

    struct key_notification {
    struct watch_notification watch;
    __u32 key_id;
    __u32 aux;
    } *n;

    Where:

    n->watch.type will be WATCH_TYPE_KEY_NOTIFY.

    n->watch.subtype will indicate the type of event, such as
    NOTIFY_KEY_REVOKED.

    n->watch.info & WATCH_INFO_LENGTH will indicate the length of the
    record.

    n->watch.info & WATCH_INFO_ID will be the second argument to
    keyctl_watch_key(), shifted.

    n->key will be the ID of the affected key.

    n->aux will hold subtype-dependent information, such as the key
    being linked into the keyring specified by n->key in the case of
    NOTIFY_KEY_LINKED.

    Note that it is permissible for event records to be of variable length -
    or, at least, the length may be dependent on the subtype. Note also that
    the queue can be shared between multiple notifications of various types.

    Signed-off-by: David Howells
    Reviewed-by: James Morris

    David Howells
     

16 May, 2020

1 commit


08 May, 2020

1 commit

  • The library implementation of the SHA-1 compression function is
    confusingly called just "sha_transform()". Alongside it are some "SHA_"
    constants and "sha_init()". Presumably these are left over from a time
    when SHA just meant SHA-1. But now there are also SHA-2 and SHA-3, and
    moreover SHA-1 is now considered insecure and thus shouldn't be used.

    Therefore, rename these functions and constants to make it very clear
    that they are for SHA-1. Also add a comment to make it clear that these
    shouldn't be used.

    For the extra-misleadingly named "SHA_MESSAGE_BYTES", rename it to
    SHA1_BLOCK_SIZE and define it to just '64' rather than '(512/8)' so that
    it matches the same definition in . This prepares for
    merging into .

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     

21 Mar, 2020

1 commit

  • Changeset 58ad30cf91f0 ("docs: fix reference to core-api/namespaces.rst")
    enabled a new feature at Sphinx: it will now generate index for each
    document title, plus to each chapter inside it.

    There's a drawback, though: one document cannot have two sections
    with the same name anymore.

    A followup patch will change the logic of autosectionlabel to
    avoid most creating references for every single section title,
    but still we need to be able to reference the chapters inside
    a document.

    There are a few places where there are two chapters with the
    same name. This patch renames one of the chapters, in order to
    avoid symbol conflict within the same document.

    PS.: as I don't speach Chinese, I had some help from a friend
    (Wen Liu) at the Chinese translation for "publishing patches"
    for this document:

    Documentation/translations/zh_CN/process/5.Posting.rst

    Fixes: 58ad30cf91f0 ("docs: fix reference to core-api/namespaces.rst")
    Signed-off-by: Mauro Carvalho Chehab
    Link: https://lore.kernel.org/r/2bffb91e4a63d41bf5fae1c23e1e8b3bba0b8806.1584716446.git.mchehab+huawei@kernel.org
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab
     

23 Nov, 2019

1 commit


01 Oct, 2019

1 commit


28 Sep, 2019

1 commit

  • Pull integrity updates from Mimi Zohar:
    "The major feature in this time is IMA support for measuring and
    appraising appended file signatures. In addition are a couple of bug
    fixes and code cleanup to use struct_size().

    In addition to the PE/COFF and IMA xattr signatures, the kexec kernel
    image may be signed with an appended signature, using the same
    scripts/sign-file tool that is used to sign kernel modules.

    Similarly, the initramfs may contain an appended signature.

    This contained a lot of refactoring of the existing appended signature
    verification code, so that IMA could retain the existing framework of
    calculating the file hash once, storing it in the IMA measurement list
    and extending the TPM, verifying the file's integrity based on a file
    hash or signature (eg. xattrs), and adding an audit record containing
    the file hash, all based on policy. (The IMA support for appended
    signatures patch set was posted and reviewed 11 times.)

    The support for appended signature paves the way for adding other
    signature verification methods, such as fs-verity, based on a single
    system-wide policy. The file hash used for verifying the signature and
    the signature, itself, can be included in the IMA measurement list"

    * 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity:
    ima: ima_api: Use struct_size() in kzalloc()
    ima: use struct_size() in kzalloc()
    sefltest/ima: support appended signatures (modsig)
    ima: Fix use after free in ima_read_modsig()
    MODSIGN: make new include file self contained
    ima: fix freeing ongoing ahash_request
    ima: always return negative code for error
    ima: Store the measurement again when appraising a modsig
    ima: Define ima-modsig template
    ima: Collect modsig
    ima: Implement support for module-style appended signatures
    ima: Factor xattr_verify() out of ima_appraise_measurement()
    ima: Add modsig appraise_type option for module-style appended signatures
    integrity: Select CONFIG_KEYS instead of depending on it
    PKCS#7: Introduce pkcs7_get_digest()
    PKCS#7: Refactor verify_pkcs7_signature()
    MODSIGN: Export module signature definitions
    ima: initialize the "template" field with the default template

    Linus Torvalds
     

18 Sep, 2019

1 commit

  • Pull documentation updates from Jonathan Corbet:
    "It's a somewhat calmer cycle for docs this time, as the churn of the
    mass RST conversion is happily mostly behind us.

    - A new document on reproducible builds.

    - We finally got around to zapping the documentation for hardware
    support that was removed in 2004; one doesn't want to rush these
    things.

    - The usual assortment of fixes, typo corrections, etc"

    * tag 'docs-5.4' of git://git.lwn.net/linux: (67 commits)
    Documentation: kbuild: Add document about reproducible builds
    docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]
    Documentation: Add "earlycon=sbi" to the admin guide
    doc:lock: remove reference to clever use of read-write lock
    devices.txt: improve entry for comedi (char major 98)
    docs: mtd: Update spi nor reference driver
    doc: arm64: fix grammar dtb placed in no attributes region
    Documentation: sysrq: don't recommend 'S' 'U' before 'B'
    mailmap: Update email address for Quentin Perret
    docs: ftrace: clarify when tracing is disabled by the trace file
    docs: process: fix broken link
    Documentation/arm/samsung-s3c24xx: Remove stray U+FEFF character to fix title
    Documentation/arm/sa1100/assabet: Fix 'make assabet_defconfig' command
    Documentation/arm/sa1100: Remove some obsolete documentation
    docs/zh_CN: update Chinese howto.rst for latexdocs making
    Documentation: virt: Fix broken reference to virt tree's index
    docs: Fix typo on pull requests guide
    kernel-doc: Allow anonymous enum
    Documentation: sphinx: Don't parse socket() as identifier reference
    Documentation: sphinx: Add missing comma to list of strings
    ...

    Linus Torvalds
     

02 Sep, 2019

1 commit


06 Aug, 2019

1 commit

  • Define new "d-modsig" template field which holds the digest that is
    expected to match the one contained in the modsig, and also new "modsig"
    template field which holds the appended file signature.

    Add a new "ima-modsig" defined template descriptor with the new fields as
    well as the ones from the "ima-sig" descriptor.

    Change ima_store_measurement() to accept a struct modsig * argument so that
    it can be passed along to the templates via struct ima_event_data.

    Suggested-by: Mimi Zohar
    Signed-off-by: Thiago Jung Bauermann
    Signed-off-by: Mimi Zohar

    Thiago Jung Bauermann
     

01 Aug, 2019

1 commit


15 Jul, 2019

2 commits


11 Jul, 2019

1 commit

  • …el/git/dhowells/linux-fs"

    This reverts merge 0f75ef6a9cff49ff612f7ce0578bced9d0b38325 (and thus
    effectively commits

    7a1ade847596 ("keys: Provide KEYCTL_GRANT_PERMISSION")
    2e12256b9a76 ("keys: Replace uid/gid/perm permissions checking with an ACL")

    that the merge brought in).

    It turns out that it breaks booting with an encrypted volume, and Eric
    biggers reports that it also breaks the fscrypt tests [1] and loading of
    in-kernel X.509 certificates [2].

    The root cause of all the breakage is likely the same, but David Howells
    is off email so rather than try to work it out it's getting reverted in
    order to not impact the rest of the merge window.

    [1] https://lore.kernel.org/lkml/20190710011559.GA7973@sol.localdomain/
    [2] https://lore.kernel.org/lkml/20190710013225.GB7973@sol.localdomain/

    Link: https://lore.kernel.org/lkml/CAHk-=wjxoeMJfeBahnWH=9zShKp2bsVy527vo3_y8HfOdhwAAw@mail.gmail.com/
    Reported-by: Eric Biggers <ebiggers@kernel.org>
    Cc: David Howells <dhowells@redhat.com>
    Cc: James Morris <jmorris@namei.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

    Linus Torvalds
     

10 Jul, 2019

1 commit

  • Pull Documentation updates from Jonathan Corbet:
    "It's been a relatively busy cycle for docs:

    - A fair pile of RST conversions, many from Mauro. These create more
    than the usual number of simple but annoying merge conflicts with
    other trees, unfortunately. He has a lot more of these waiting on
    the wings that, I think, will go to you directly later on.

    - A new document on how to use merges and rebases in kernel repos,
    and one on Spectre vulnerabilities.

    - Various improvements to the build system, including automatic
    markup of function() references because some people, for reasons I
    will never understand, were of the opinion that
    :c:func:``function()`` is unattractive and not fun to type.

    - We now recommend using sphinx 1.7, but still support back to 1.4.

    - Lots of smaller improvements, warning fixes, typo fixes, etc"

    * tag 'docs-5.3' of git://git.lwn.net/linux: (129 commits)
    docs: automarkup.py: ignore exceptions when seeking for xrefs
    docs: Move binderfs to admin-guide
    Disable Sphinx SmartyPants in HTML output
    doc: RCU callback locks need only _bh, not necessarily _irq
    docs: format kernel-parameters -- as code
    Doc : doc-guide : Fix a typo
    platform: x86: get rid of a non-existent document
    Add the RCU docs to the core-api manual
    Documentation: RCU: Add TOC tree hooks
    Documentation: RCU: Rename txt files to rst
    Documentation: RCU: Convert RCU UP systems to reST
    Documentation: RCU: Convert RCU linked list to reST
    Documentation: RCU: Convert RCU basic concepts to reST
    docs: filesystems: Remove uneeded .rst extension on toctables
    scripts/sphinx-pre-install: fix out-of-tree build
    docs: zh_CN: submitting-drivers.rst: Remove a duplicated Documentation/
    Documentation: PGP: update for newer HW devices
    Documentation: Add section about CPU vulnerabilities for Spectre
    Documentation: platform: Delete x86-laptop-drivers.txt
    docs: Note that :c:func: should no longer be used
    ...

    Linus Torvalds
     

09 Jul, 2019

1 commit

  • Pull integrity updates from Mimi Zohar:
    "Bug fixes, code clean up, and new features:

    - IMA policy rules can be defined in terms of LSM labels, making the
    IMA policy dependent on LSM policy label changes, in particular LSM
    label deletions. The new environment, in which IMA-appraisal is
    being used, frequently updates the LSM policy and permits LSM label
    deletions.

    - Prevent an mmap'ed shared file opened for write from also being
    mmap'ed execute. In the long term, making this and other similar
    changes at the VFS layer would be preferable.

    - The IMA per policy rule template format support is needed for a
    couple of new/proposed features (eg. kexec boot command line
    measurement, appended signatures, and VFS provided file hashes).

    - Other than the "boot-aggregate" record in the IMA measuremeent
    list, all other measurements are of file data. Measuring and
    storing the kexec boot command line in the IMA measurement list is
    the first buffer based measurement included in the measurement
    list"

    * 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity:
    integrity: Introduce struct evm_xattr
    ima: Update MAX_TEMPLATE_NAME_LEN to fit largest reasonable definition
    KEXEC: Call ima_kexec_cmdline to measure the boot command line args
    IMA: Define a new template field buf
    IMA: Define a new hook to measure the kexec boot command line arguments
    IMA: support for per policy rule template formats
    integrity: Fix __integrity_init_keyring() section mismatch
    ima: Use designated initializers for struct ima_event_data
    ima: use the lsm policy update notifier
    LSM: switch to blocking policy update notifiers
    x86/ima: fix the Kconfig dependency for IMA_ARCH_POLICY
    ima: Make arch_policy_entry static
    ima: prevent a file already mmap'ed write to be mmap'ed execute
    x86/ima: check EFI SetupMode too

    Linus Torvalds
     

01 Jul, 2019

1 commit

  • A buffer(kexec boot command line arguments) measured into IMA
    measuremnt list cannot be appraised, without already being
    aware of the buffer contents. Since hashes are non-reversible,
    raw buffer is needed for validation or regenerating hash for
    appraisal/attestation.

    Add support to store/read the buffer contents in HEX.
    The kexec cmdline hash is stored in the "d-ng" field of the
    template data. It can be verified using
    sudo cat /sys/kernel/security/integrity/ima/ascii_runtime_measurements |
    grep kexec-cmdline | cut -d' ' -f 6 | xxd -r -p | sha256sum

    - Add two new fields to ima_event_data to hold the buf and
    buf_len
    - Add a new template field 'buf' to be used to store/read
    the buffer data.
    - Updated process_buffer_meaurement to add the buffer to
    ima_event_data. process_buffer_measurement added in
    "Define a new IMA hook to measure the boot command line
    arguments"
    - Add a new template policy name ima-buf to represent
    'd-ng|n-ng|buf'

    Signed-off-by: Prakhar Srivastava
    Reviewed-by: Roberto Sassu
    Reviewed-by: James Morris
    Signed-off-by: Mimi Zohar

    Prakhar Srivastava
     

28 Jun, 2019

2 commits

  • Replace the uid/gid/perm permissions checking on a key with an ACL to allow
    the SETATTR and SEARCH permissions to be split. This will also allow a
    greater range of subjects to represented.

    ============
    WHY DO THIS?
    ============

    The problem is that SETATTR and SEARCH cover a slew of actions, not all of
    which should be grouped together.

    For SETATTR, this includes actions that are about controlling access to a
    key:

    (1) Changing a key's ownership.

    (2) Changing a key's security information.

    (3) Setting a keyring's restriction.

    And actions that are about managing a key's lifetime:

    (4) Setting an expiry time.

    (5) Revoking a key.

    and (proposed) managing a key as part of a cache:

    (6) Invalidating a key.

    Managing a key's lifetime doesn't really have anything to do with
    controlling access to that key.

    Expiry time is awkward since it's more about the lifetime of the content
    and so, in some ways goes better with WRITE permission. It can, however,
    be set unconditionally by a process with an appropriate authorisation token
    for instantiating a key, and can also be set by the key type driver when a
    key is instantiated, so lumping it with the access-controlling actions is
    probably okay.

    As for SEARCH permission, that currently covers:

    (1) Finding keys in a keyring tree during a search.

    (2) Permitting keyrings to be joined.

    (3) Invalidation.

    But these don't really belong together either, since these actions really
    need to be controlled separately.

    Finally, there are number of special cases to do with granting the
    administrator special rights to invalidate or clear keys that I would like
    to handle with the ACL rather than key flags and special checks.

    ===============
    WHAT IS CHANGED
    ===============

    The SETATTR permission is split to create two new permissions:

    (1) SET_SECURITY - which allows the key's owner, group and ACL to be
    changed and a restriction to be placed on a keyring.

    (2) REVOKE - which allows a key to be revoked.

    The SEARCH permission is split to create:

    (1) SEARCH - which allows a keyring to be search and a key to be found.

    (2) JOIN - which allows a keyring to be joined as a session keyring.

    (3) INVAL - which allows a key to be invalidated.

    The WRITE permission is also split to create:

    (1) WRITE - which allows a key's content to be altered and links to be
    added, removed and replaced in a keyring.

    (2) CLEAR - which allows a keyring to be cleared completely. This is
    split out to make it possible to give just this to an administrator.

    (3) REVOKE - see above.

    Keys acquire ACLs which consist of a series of ACEs, and all that apply are
    unioned together. An ACE specifies a subject, such as:

    (*) Possessor - permitted to anyone who 'possesses' a key
    (*) Owner - permitted to the key owner
    (*) Group - permitted to the key group
    (*) Everyone - permitted to everyone

    Note that 'Other' has been replaced with 'Everyone' on the assumption that
    you wouldn't grant a permit to 'Other' that you wouldn't also grant to
    everyone else.

    Further subjects may be made available by later patches.

    The ACE also specifies a permissions mask. The set of permissions is now:

    VIEW Can view the key metadata
    READ Can read the key content
    WRITE Can update/modify the key content
    SEARCH Can find the key by searching/requesting
    LINK Can make a link to the key
    SET_SECURITY Can change owner, ACL, expiry
    INVAL Can invalidate
    REVOKE Can revoke
    JOIN Can join this keyring
    CLEAR Can clear this keyring

    The KEYCTL_SETPERM function is then deprecated.

    The KEYCTL_SET_TIMEOUT function then is permitted if SET_SECURITY is set,
    or if the caller has a valid instantiation auth token.

    The KEYCTL_INVALIDATE function then requires INVAL.

    The KEYCTL_REVOKE function then requires REVOKE.

    The KEYCTL_JOIN_SESSION_KEYRING function then requires JOIN to join an
    existing keyring.

    The JOIN permission is enabled by default for session keyrings and manually
    created keyrings only.

    ======================
    BACKWARD COMPATIBILITY
    ======================

    To maintain backward compatibility, KEYCTL_SETPERM will translate the
    permissions mask it is given into a new ACL for a key - unless
    KEYCTL_SET_ACL has been called on that key, in which case an error will be
    returned.

    It will convert possessor, owner, group and other permissions into separate
    ACEs, if each portion of the mask is non-zero.

    SETATTR permission turns on all of INVAL, REVOKE and SET_SECURITY. WRITE
    permission turns on WRITE, REVOKE and, if a keyring, CLEAR. JOIN is turned
    on if a keyring is being altered.

    The KEYCTL_DESCRIBE function translates the ACL back into a permissions
    mask to return depending on possessor, owner, group and everyone ACEs.

    It will make the following mappings:

    (1) INVAL, JOIN -> SEARCH

    (2) SET_SECURITY -> SETATTR

    (3) REVOKE -> WRITE if SETATTR isn't already set

    (4) CLEAR -> WRITE

    Note that the value subsequently returned by KEYCTL_DESCRIBE may not match
    the value set with KEYCTL_SETATTR.

    =======
    TESTING
    =======

    This passes the keyutils testsuite for all but a couple of tests:

    (1) tests/keyctl/dh_compute/badargs: The first wrong-key-type test now
    returns EOPNOTSUPP rather than ENOKEY as READ permission isn't removed
    if the type doesn't have ->read(). You still can't actually read the
    key.

    (2) tests/keyctl/permitting/valid: The view-other-permissions test doesn't
    work as Other has been replaced with Everyone in the ACL.

    Signed-off-by: David Howells

    David Howells
     
  • Create a request_key_net() function and use it to pass the network
    namespace domain tag into DNS revolver keys and rxrpc/AFS keys so that keys
    for different domains can coexist in the same keyring.

    Signed-off-by: David Howells
    cc: netdev@vger.kernel.org
    cc: linux-nfs@vger.kernel.org
    cc: linux-cifs@vger.kernel.org
    cc: linux-afs@lists.infradead.org

    David Howells
     

27 Jun, 2019

2 commits


19 Jun, 2019

4 commits

  • If a filesystem uses keys to hold authentication tokens, then it needs a
    token for each VFS operation that might perform an authentication check -
    either by passing it to the server, or using to perform a check based on
    authentication data cached locally.

    For open files this isn't a problem, since the key should be cached in the
    file struct since it represents the subject performing operations on that
    file descriptor.

    During pathwalk, however, there isn't anywhere to cache the key, except
    perhaps in the nameidata struct - but that isn't exposed to the
    filesystems. Further, a pathwalk can incur a lot of operations, calling
    one or more of the following, for instance:

    ->lookup()
    ->permission()
    ->d_revalidate()
    ->d_automount()
    ->get_acl()
    ->getxattr()

    on each dentry/inode it encounters - and each one may need to call
    request_key(). And then, at the end of pathwalk, it will call the actual
    operation:

    ->mkdir()
    ->mknod()
    ->getattr()
    ->open()
    ...

    which may need to go and get the token again.

    However, it is very likely that all of the operations on a single
    dentry/inode - and quite possibly a sequence of them - will all want to use
    the same authentication token, which suggests that caching it would be a
    good idea.

    To this end:

    (1) Make it so that a positive result of request_key() and co. that didn't
    require upcalling to userspace is cached temporarily in task_struct.

    (2) The cache is 1 deep, so a new result displaces the old one.

    (3) The key is released by exit and by notify-resume.

    (4) The cache is cleared in a newly forked process.

    Signed-off-by: David Howells

    David Howells
     
  • Provide a request_key_rcu() function that can be used to request a key
    under RCU conditions. It can only search and check permissions; it cannot
    allocate a new key, upcall or wait for an upcall to complete. It may
    return a partially constructed key.

    Signed-off-by: David Howells

    David Howells
     
  • Move the RCU locks outwards from the keyring search functions so that it
    will become possible to provide an RCU-capable partial request_key()
    function in a later commit.

    Signed-off-by: David Howells

    David Howells
     
  • The request_key() syscall allows a process to gain access to the 'possessor'
    permits of any key that grants it Search permission by virtue of request_key()
    not checking whether a key it finds grants Link permission to the caller.

    Signed-off-by: David Howells

    David Howells
     

09 Jun, 2019

1 commit

  • Multi-line literal markups only work when they're idented at the
    same level, with is not the case here:

    Documentation/security/keys/core.rst:1597: WARNING: Inline literal start-string without end-string.
    Documentation/security/keys/core.rst:1597: WARNING: Inline emphasis start-string without end-string.
    Documentation/security/keys/core.rst:1597: WARNING: Inline emphasis start-string without end-string.
    Documentation/security/keys/core.rst:1598: WARNING: Inline emphasis start-string without end-string.
    Documentation/security/keys/core.rst:1598: WARNING: Inline emphasis start-string without end-string.
    Documentation/security/keys/core.rst:1600: WARNING: Inline literal start-string without end-string.
    Documentation/security/keys/core.rst:1600: WARNING: Inline emphasis start-string without end-string.
    Documentation/security/keys/core.rst:1600: WARNING: Inline emphasis start-string without end-string.
    Documentation/security/keys/core.rst:1600: WARNING: Inline emphasis start-string without end-string.
    Documentation/security/keys/core.rst:1600: WARNING: Inline emphasis start-string without end-string.
    Documentation/security/keys/core.rst:1666: WARNING: Inline literal start-string without end-string.
    Documentation/security/keys/core.rst:1666: WARNING: Inline emphasis start-string without end-string.
    Documentation/security/keys/core.rst:1666: WARNING: Inline emphasis start-string without end-string.
    Documentation/security/keys/core.rst:1666: WARNING: Inline emphasis start-string without end-string.

    Fix it by using a code-block instead.

    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab