27 Aug, 2014

1 commit

  • Commit 7177a9c4b509 ("fs: call rename2 if exists") changed
    "struct inode_operations"->rename == NULL if
    "struct inode_operations"->rename2 != NULL .

    TOMOYO needs to check for both ->rename and ->rename2 , or
    a system on (e.g.) ext4 filesystem won't boot.

    Signed-off-by: Tetsuo Handa
    Signed-off-by: Serge E. Hallyn

    Tetsuo Handa
     

10 Aug, 2014

1 commit

  • Pull SElinux fixes from Paul Moore:
    "Two small patches to fix a couple of build warnings in SELinux and
    NetLabel. The patches are obvious enough that I don't think any
    additional explanation is necessary, but it basically boils down to
    the usual: I was stupid, and these patches fix some of the stupid.

    Both patches were posted earlier this week to the SELinux list, and
    that is where they sat as I didn't think there were noteworthy enough
    to go upstream at this point in time, but DaveM would rather see them
    upstream now so who am I to argue. As the patches are both very
    small"

    * 'stable-3.17' of git://git.infradead.org/users/pcmoore/selinux:
    selinux: remove unused variabled in the netport, netnode, and netif caches
    netlabel: fix the netlbl_catmap_setlong() dummy function

    Linus Torvalds
     

08 Aug, 2014

1 commit


06 Aug, 2014

2 commits

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

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

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

    Linus Torvalds
     
  • Pull timer and time updates from Thomas Gleixner:
    "A rather large update of timers, timekeeping & co

    - Core timekeeping code is year-2038 safe now for 32bit machines.
    Now we just need to fix all in kernel users and the gazillion of
    user space interfaces which rely on timespec/timeval :)

    - Better cache layout for the timekeeping internal data structures.

    - Proper nanosecond based interfaces for in kernel users.

    - Tree wide cleanup of code which wants nanoseconds but does hoops
    and loops to convert back and forth from timespecs. Some of it
    definitely belongs into the ugly code museum.

    - Consolidation of the timekeeping interface zoo.

    - A fast NMI safe accessor to clock monotonic for tracing. This is a
    long standing request to support correlated user/kernel space
    traces. With proper NTP frequency correction it's also suitable
    for correlation of traces accross separate machines.

    - Checkpoint/restart support for timerfd.

    - A few NOHZ[_FULL] improvements in the [hr]timer code.

    - Code move from kernel to kernel/time of all time* related code.

    - New clocksource/event drivers from the ARM universe. I'm really
    impressed that despite an architected timer in the newer chips SoC
    manufacturers insist on inventing new and differently broken SoC
    specific timers.

    [ Ed. "Impressed"? I don't think that word means what you think it means ]

    - Another round of code move from arch to drivers. Looks like most
    of the legacy mess in ARM regarding timers is sorted out except for
    a few obnoxious strongholds.

    - The usual updates and fixlets all over the place"

    * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (114 commits)
    timekeeping: Fixup typo in update_vsyscall_old definition
    clocksource: document some basic timekeeping concepts
    timekeeping: Use cached ntp_tick_length when accumulating error
    timekeeping: Rework frequency adjustments to work better w/ nohz
    timekeeping: Minor fixup for timespec64->timespec assignment
    ftrace: Provide trace clocks monotonic
    timekeeping: Provide fast and NMI safe access to CLOCK_MONOTONIC
    seqcount: Add raw_write_seqcount_latch()
    seqcount: Provide raw_read_seqcount()
    timekeeping: Use tk_read_base as argument for timekeeping_get_ns()
    timekeeping: Create struct tk_read_base and use it in struct timekeeper
    timekeeping: Restructure the timekeeper some more
    clocksource: Get rid of cycle_last
    clocksource: Move cycle_last validation to core code
    clocksource: Make delta calculation a function
    wireless: ath9k: Get rid of timespec conversions
    drm: vmwgfx: Use nsec based interfaces
    drm: i915: Use nsec based interfaces
    timekeeping: Provide ktime_get_raw()
    hangcheck-timer: Use ktime_get_ns()
    ...

    Linus Torvalds
     

05 Aug, 2014

1 commit

  • Pull scheduler updates from Ingo Molnar:

    - Move the nohz kick code out of the scheduler tick to a dedicated IPI,
    from Frederic Weisbecker.

    This necessiated quite some background infrastructure rework,
    including:

    * Clean up some irq-work internals
    * Implement remote irq-work
    * Implement nohz kick on top of remote irq-work
    * Move full dynticks timer enqueue notification to new kick
    * Move multi-task notification to new kick
    * Remove unecessary barriers on multi-task notification

    - Remove proliferation of wait_on_bit() action functions and allow
    wait_on_bit_action() functions to support a timeout. (Neil Brown)

    - Another round of sched/numa improvements, cleanups and fixes. (Rik
    van Riel)

    - Implement fast idling of CPUs when the system is partially loaded,
    for better scalability. (Tim Chen)

    - Restructure and fix the CPU hotplug handling code that may leave
    cfs_rq and rt_rq's throttled when tasks are migrated away from a dead
    cpu. (Kirill Tkhai)

    - Robustify the sched topology setup code. (Peterz Zijlstra)

    - Improve sched_feat() handling wrt. static_keys (Jason Baron)

    - Misc fixes.

    * 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (37 commits)
    sched/fair: Fix 'make xmldocs' warning caused by missing description
    sched: Use macro for magic number of -1 for setparam
    sched: Robustify topology setup
    sched: Fix sched_setparam() policy == -1 logic
    sched: Allow wait_on_bit_action() functions to support a timeout
    sched: Remove proliferation of wait_on_bit() action functions
    sched/numa: Revert "Use effective_load() to balance NUMA loads"
    sched: Fix static_key race with sched_feat()
    sched: Remove extra static_key*() function indirection
    sched/rt: Fix replenish_dl_entity() comments to match the current upstream code
    sched: Transform resched_task() into resched_curr()
    sched/deadline: Kill task_struct->pi_top_task
    sched: Rework check_for_tasks()
    sched/rt: Enqueue just unthrottled rt_rq back on the stack in __disable_runtime()
    sched/fair: Disable runtime_enabled on dying rq
    sched/numa: Change scan period code to match intent
    sched/numa: Rework best node setting in task_numa_migrate()
    sched/numa: Examine a task move when examining a task swap
    sched/numa: Simplify task_numa_compare()
    sched/numa: Use effective_load() to balance NUMA loads
    ...

    Linus Torvalds
     

02 Aug, 2014

1 commit


01 Aug, 2014

3 commits

  • Historically the NetLabel LSM secattr catmap functions and data
    structures have had very long names which makes a mess of the NetLabel
    code and anyone who uses NetLabel. This patch renames the catmap
    functions and structures from "*_secattr_catmap_*" to just "*_catmap_*"
    which improves things greatly.

    There are no substantial code or logic changes in this patch.

    Signed-off-by: Paul Moore
    Tested-by: Casey Schaufler

    Paul Moore
     
  • The NetLabel secattr catmap functions, and the SELinux import/export
    glue routines, were broken in many horrible ways and the SELinux glue
    code fiddled with the NetLabel catmap structures in ways that we
    probably shouldn't allow. At some point this "worked", but that was
    likely due to a bit of dumb luck and sub-par testing (both inflicted
    by yours truly). This patch corrects these problems by basically
    gutting the code in favor of something less obtuse and restoring the
    NetLabel abstractions in the SELinux catmap glue code.

    Everything is working now, and if it decides to break itself in the
    future this code will be much easier to debug than the code it
    replaces.

    One noteworthy side effect of the changes is that it is no longer
    necessary to allocate a NetLabel catmap before calling one of the
    NetLabel APIs to set a bit in the catmap. NetLabel will automatically
    allocate the catmap nodes when needed, resulting in less allocations
    when the lowest bit is greater than 255 and less code in the LSMs.

    Cc: stable@vger.kernel.org
    Reported-by: Christian Evans
    Signed-off-by: Paul Moore
    Tested-by: Casey Schaufler

    Paul Moore
     
  • The NetLabel category (catmap) functions have a problem in that they
    assume categories will be set in an increasing manner, e.g. the next
    category set will always be larger than the last. Unfortunately, this
    is not a valid assumption and could result in problems when attempting
    to set categories less than the startbit in the lowest catmap node.
    In some cases kernel panics and other nasties can result.

    This patch corrects the problem by checking for this and allocating a
    new catmap node instance and placing it at the front of the list.

    Cc: stable@vger.kernel.org
    Reported-by: Christian Evans
    Signed-off-by: Paul Moore
    Tested-by: Casey Schaufler

    Paul Moore
     

29 Jul, 2014

1 commit


28 Jul, 2014

2 commits

  • This reverts commit 4da6daf4d3df5a977e4623963f141a627fd2efce.

    Unfortunately, the commit in question caused problems with Bluetooth
    devices, specifically it caused them to get caught in the newly
    created BUG_ON() check. The AF_ALG problem still exists, but will be
    addressed in a future patch.

    Cc: stable@vger.kernel.org
    Signed-off-by: Paul Moore

    Paul Moore
     
  • Commit fc7c70e "KEYS: struct key_preparsed_payload should have two
    payload pointers" erroneously modified encrypted-keys. This patch
    reverts the change to that file.

    Signed-off-by: Mimi Zohar
    Signed-off-by: David Howells

    Mimi Zohar
     

26 Jul, 2014

2 commits

  • The "security: introduce kernel_fw_from_file hook" patch defined a
    new security hook to evaluate any loaded firmware that wasn't built
    into the kernel.

    This patch defines ima_fw_from_file(), which is called from the new
    security hook, to measure and/or appraise the loaded firmware's
    integrity.

    Signed-off-by: Mimi Zohar
    Signed-off-by: Kees Cook

    Mimi Zohar
     
  • In order to validate the contents of firmware being loaded, there must be
    a hook to evaluate any loaded firmware that wasn't built into the kernel
    itself. Without this, there is a risk that a root user could load malicious
    firmware designed to mount an attack against kernel memory (e.g. via DMA).

    Signed-off-by: Kees Cook
    Reviewed-by: Takashi Iwai

    Kees Cook
     

24 Jul, 2014

3 commits

  • This is effectively a revert of 7b9a7ec565505699f503b4fcf61500dceb36e744
    plus fixing it a different way...

    We found, when trying to run an application from an application which
    had dropped privs that the kernel does security checks on undefined
    capability bits. This was ESPECIALLY difficult to debug as those
    undefined bits are hidden from /proc/$PID/status.

    Consider a root application which drops all capabilities from ALL 4
    capability sets. We assume, since the application is going to set
    eff/perm/inh from an array that it will clear not only the defined caps
    less than CAP_LAST_CAP, but also the higher 28ish bits which are
    undefined future capabilities.

    The BSET gets cleared differently. Instead it is cleared one bit at a
    time. The problem here is that in security/commoncap.c::cap_task_prctl()
    we actually check the validity of a capability being read. So any task
    which attempts to 'read all things set in bset' followed by 'unset all
    things set in bset' will not even attempt to unset the undefined bits
    higher than CAP_LAST_CAP.

    So the 'parent' will look something like:
    CapInh: 0000000000000000
    CapPrm: 0000000000000000
    CapEff: 0000000000000000
    CapBnd: ffffffc000000000

    All of this 'should' be fine. Given that these are undefined bits that
    aren't supposed to have anything to do with permissions. But they do...

    So lets now consider a task which cleared the eff/perm/inh completely
    and cleared all of the valid caps in the bset (but not the invalid caps
    it couldn't read out of the kernel). We know that this is exactly what
    the libcap-ng library does and what the go capabilities library does.
    They both leave you in that above situation if you try to clear all of
    you capapabilities from all 4 sets. If that root task calls execve()
    the child task will pick up all caps not blocked by the bset. The bset
    however does not block bits higher than CAP_LAST_CAP. So now the child
    task has bits in eff which are not in the parent. These are
    'meaningless' undefined bits, but still bits which the parent doesn't
    have.

    The problem is now in cred_cap_issubset() (or any operation which does a
    subset test) as the child, while a subset for valid cap bits, is not a
    subset for invalid cap bits! So now we set durring commit creds that
    the child is not dumpable. Given it is 'more priv' than its parent. It
    also means the parent cannot ptrace the child and other stupidity.

    The solution here:
    1) stop hiding capability bits in status
    This makes debugging easier!

    2) stop giving any task undefined capability bits. it's simple, it you
    don't put those invalid bits in CAP_FULL_SET you won't get them in init
    and you won't get them in any other task either.
    This fixes the cap_issubset() tests and resulting fallout (which
    made the init task in a docker container untraceable among other
    things)

    3) mask out undefined bits when sys_capset() is called as it might use
    ~0, ~0 to denote 'all capabilities' for backward/forward compatibility.
    This lets 'capsh --caps="all=eip" -- -c /bin/bash' run.

    4) mask out undefined bit when we read a file capability off of disk as
    again likely all bits are set in the xattr for forward/backward
    compatibility.
    This lets 'setcap all+pe /bin/bash; /bin/bash' run

    Signed-off-by: Eric Paris
    Reviewed-by: Kees Cook
    Cc: Andrew Vagin
    Cc: Andrew G. Morgan
    Cc: Serge E. Hallyn
    Cc: Kees Cook
    Cc: Steve Grubb
    Cc: Dan Walsh
    Cc: stable@vger.kernel.org
    Signed-off-by: James Morris

    Eric Paris
     
  • …dhowells/linux-fs into next

    James Morris
     
  • In function cap_task_prctl(), we would allocate a credential
    unconditionally and then check if we support the requested function.
    If not we would release this credential with abort_creds() by using
    RCU method. But on some archs such as powerpc, the sys_prctl is heavily
    used to get/set the floating point exception mode. So the unnecessary
    allocating/releasing of credential not only introduce runtime overhead
    but also do cause OOM due to the RCU implementation.

    This patch removes abort_creds() from cap_task_prctl() by calling
    prepare_creds() only when we need to modify it.

    Reported-by: Kevin Hao
    Signed-off-by: Tetsuo Handa
    Reviewed-by: Paul Moore
    Acked-by: Serge E. Hallyn
    Reviewed-by: Kees Cook
    Signed-off-by: James Morris

    Tetsuo Handa
     

23 Jul, 2014

9 commits


19 Jul, 2014

4 commits


18 Jul, 2014

1 commit

  • Special kernel keys, such as those used to hold DNS results for AFS, CIFS and
    NFS and those used to hold idmapper results for NFS, used to be
    'invalidateable' with key_revoke(). However, since the default permissions for
    keys were reduced:

    Commit: 96b5c8fea6c0861621051290d705ec2e971963f1
    KEYS: Reduce initial permissions on keys

    it has become impossible to do this.

    Add a key flag (KEY_FLAG_ROOT_CAN_INVAL) that will permit a key to be
    invalidated by root. This should not be used for system keyrings as the
    garbage collector will try and remove any invalidate key. For system keyrings,
    KEY_FLAG_ROOT_CAN_CLEAR can be used instead.

    After this, from userspace, keyctl_invalidate() and "keyctl invalidate" can be
    used by any possessor of CAP_SYS_ADMIN (typically root) to invalidate DNS and
    idmapper keys. Invalidated keys are immediately garbage collected and will be
    immediately rerequested if needed again.

    Signed-off-by: David Howells
    Tested-by: Steve Dickson

    David Howells
     

17 Jul, 2014

8 commits

  • Require all keys added to the IMA keyring be signed by an
    existing trusted key on the system trusted keyring.

    Changelog v6:
    - remove ifdef CONFIG_IMA_TRUSTED_KEYRING in C code - Dmitry
    - update Kconfig dependency and help
    - select KEYS_DEBUG_PROC_KEYS - Dmitry

    Changelog v5:
    - Move integrity_init_keyring() to init_ima() - Dmitry
    - reset keyring[id] on failure - Dmitry

    Changelog v1:
    - don't link IMA trusted keyring to user keyring

    Changelog:
    - define stub integrity_init_keyring() function (reported-by Fengguang Wu)
    - differentiate between regular and trusted keyring names.
    - replace printk with pr_info (D. Kasatkin)
    - only make the IMA keyring a trusted keyring (reported-by D. Kastatkin)
    - define stub integrity_init_keyring() definition based on
    CONFIG_INTEGRITY_SIGNATURE, not CONFIG_INTEGRITY_ASYMMETRIC_KEYS.
    (reported-by Jim Davis)

    Signed-off-by: Mimi Zohar
    Signed-off-by: Dmitry Kasatkin
    Acked-by: David Howells

    Mimi Zohar
     
  • Dot prefixed keyring names are supposed to be reserved for the
    kernel, but add_key() calls key_get_type_from_user(), which
    incorrectly verifies the 'type' field, not the 'description' field.
    This patch verifies the 'description' field isn't dot prefixed,
    when creating a new keyring, and removes the dot prefix test in
    key_get_type_from_user().

    Changelog v6:
    - whitespace and other cleanup

    Changelog v5:
    - Only prevent userspace from creating a dot prefixed keyring, not
    regular keys - Dmitry

    Reported-by: Dmitry Kasatkin
    Signed-off-by: Mimi Zohar
    Acked-by: David Howells

    Mimi Zohar
     
  • The asynchronous hash API allows initiating a hash calculation and
    then performing other tasks, while waiting for the hash calculation
    to complete.

    This patch introduces usage of double buffering for simultaneous
    hashing and reading of the next chunk of data from storage.

    Changes in v3:
    - better comments

    Signed-off-by: Dmitry Kasatkin
    Signed-off-by: Mimi Zohar

    Dmitry Kasatkin
     
  • Use of multiple-page collect buffers reduces:
    1) the number of block IO requests
    2) the number of asynchronous hash update requests

    Second is important for HW accelerated hashing, because significant
    amount of time is spent for preparation of hash update operation,
    which includes configuring acceleration HW, DMA engine, etc...
    Thus, HW accelerators are more efficient when working on large
    chunks of data.

    This patch introduces usage of multi-page collect buffers. Buffer size
    can be specified using 'ahash_bufsize' module parameter. Default buffer
    size is 4096 bytes.

    Changes in v3:
    - kernel parameter replaced with module parameter

    Signed-off-by: Dmitry Kasatkin
    Signed-off-by: Mimi Zohar

    Dmitry Kasatkin
     
  • Async hash API allows the use of HW acceleration for hash calculation.
    It may give significant performance gain and/or reduce power consumption,
    which might be very beneficial for battery powered devices.

    This patch introduces hash calculation using ahash API. ahash performance
    depends on the data size and the particular HW. Depending on the specific
    system, shash performance may be better.

    This patch defines 'ahash_minsize' module parameter, which is used to
    define the minimal file size to use with ahash. If this minimum file size
    is not set or the file is smaller than defined by the parameter, shash will
    be used.

    Changes in v3:
    - kernel parameter replaced with module parameter
    - pr_crit replaced with pr_crit_ratelimited
    - more comment changes - Mimi

    Changes in v2:
    - ima_ahash_size became as ima_ahash
    - ahash pre-allocation moved out from __init code to be able to use
    ahash crypto modules. Ahash allocated once on the first use.
    - hash calculation falls back to shash if ahash allocation/calculation fails
    - complex initialization separated from variable declaration
    - improved comments

    Signed-off-by: Dmitry Kasatkin
    Signed-off-by: Mimi Zohar

    Dmitry Kasatkin
     
  • Replace spaces in op keyword labels in log output since userspace audit tools
    can't parse orphaned keywords.

    Reported-by: Steve Grubb
    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Mimi Zohar

    Richard Guy Briggs
     
  • process_measurement() always calls ima_template_desc_current(),
    including when an IMA policy has not been defined.

    This patch delays template descriptor lookup until action is
    determined.

    Signed-off-by: Dmitry Kasatkin
    Signed-off-by: Mimi Zohar

    Dmitry Kasatkin
     
  • Before 2.6.39 inode->i_readcount was maintained by IMA. It was not atomic
    and protected using spinlock. For 2.6.39, i_readcount was converted to
    atomic and maintaining was moved VFS layer. Spinlock for some unclear
    reason was replaced by i_mutex.

    After analyzing the code, we came to conclusion that i_mutex locking is
    unnecessary, especially when an IMA policy has not been defined.

    This patch removes i_mutex locking from ima_rdwr_violation_check().

    Signed-off-by: Dmitry Kasatkin
    Signed-off-by: Mimi Zohar

    Dmitry Kasatkin