27 Sep, 2010

1 commit

  • System call entry functions sys_*() are never to be called from
    general kernel code. The fact that they aren't declared in header
    files should have been a clue. These functions also don't exist on
    Alpha since it has sys_getxpid() instead.

    Signed-off-by: Ben Hutchings
    Acked-by: Tetsuo Handa
    Signed-off-by: James Morris

    Ben Hutchings
     

10 Sep, 2010

2 commits

  • Fix a bug in keyctl_session_to_parent() whereby it tries to check the ownership
    of the parent process's session keyring whether or not the parent has a session
    keyring [CVE-2010-2960].

    This results in the following oops:

    BUG: unable to handle kernel NULL pointer dereference at 00000000000000a0
    IP: [] keyctl_session_to_parent+0x251/0x443
    ...
    Call Trace:
    [] ? keyctl_session_to_parent+0x67/0x443
    [] ? __do_fault+0x24b/0x3d0
    [] sys_keyctl+0xb4/0xb8
    [] system_call_fastpath+0x16/0x1b

    if the parent process has no session keyring.

    If the system is using pam_keyinit then it mostly protected against this as all
    processes derived from a login will have inherited the session keyring created
    by pam_keyinit during the log in procedure.

    To test this, pam_keyinit calls need to be commented out in /etc/pam.d/.

    Reported-by: Tavis Ormandy
    Signed-off-by: David Howells
    Acked-by: Tavis Ormandy
    Signed-off-by: Linus Torvalds

    David Howells
     
  • There's an protected access to the parent process's credentials in the middle
    of keyctl_session_to_parent(). This results in the following RCU warning:

    ===================================================
    [ INFO: suspicious rcu_dereference_check() usage. ]
    ---------------------------------------------------
    security/keys/keyctl.c:1291 invoked rcu_dereference_check() without protection!

    other info that might help us debug this:

    rcu_scheduler_active = 1, debug_locks = 0
    1 lock held by keyctl-session-/2137:
    #0: (tasklist_lock){.+.+..}, at: [] keyctl_session_to_parent+0x60/0x236

    stack backtrace:
    Pid: 2137, comm: keyctl-session- Not tainted 2.6.36-rc2-cachefs+ #1
    Call Trace:
    [] lockdep_rcu_dereference+0xaa/0xb3
    [] keyctl_session_to_parent+0xed/0x236
    [] sys_keyctl+0xb4/0xb6
    [] system_call_fastpath+0x16/0x1b

    The code should take the RCU read lock to make sure the parents credentials
    don't go away, even though it's holding a spinlock and has IRQ disabled.

    Signed-off-by: David Howells
    Signed-off-by: Linus Torvalds

    David Howells
     

08 Sep, 2010

5 commits

  • commit 8262bb85da allocated the inode integrity struct (iint) before any
    inodes were created. Only after IMA was initialized in late_initcall were
    the counters updated. This patch updates the counters, whether or not IMA
    has been initialized, to resolve 'imbalance' messages.

    This patch fixes the bug as reported in bugzilla: 15673. When the i915
    is builtin, the ring_buffer is initialized before IMA, causing the
    imbalance message on suspend.

    Reported-by: Thomas Meyer
    Signed-off-by: Mimi Zohar
    Tested-by: Thomas Meyer
    Tested-by: David Safford
    Cc: Stable Kernel
    Signed-off-by: James Morris

    Mimi Zohar
     
  • The locking for profile namespace removal is wrong, when removing a
    profile namespace, it needs to be removed from its parent's list.
    Lock the parent of namespace list instead of the namespace being removed.

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen
     
  • As per Dan Carpenter
    If we have a ns name without a following profile then in the original
    code it did "*ns_name = &name[1];". "name" is NULL so "*ns_name" is
    0x1. That isn't useful and could cause an oops when this function is
    called from aa_remove_profiles().

    Beyond this the assignment of the namespace name was wrong in the case
    where the profile name was provided as it was being set to &name[1]
    after name = skip_spaces(split + 1);

    Move the ns_name assignment before updating name for the split and
    also add skip_spaces, making the interface more robust.

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen
     
  • 2.6.36 introduced the abilitiy to specify the task that is having its
    rlimits set. Update mediation to ensure that confined tasks can only
    set their own group_leader as expected by current policy.

    Add TODO note about extending policy to support setting other tasks
    rlimits.

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen
     
  • The 2.6.36 kernel has refactored __d_path() so that it no longer appends
    " (deleted)" to unlinked paths. So drop the hack that was used to detect
    and remove the appended string.

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen
     

19 Aug, 2010

1 commit

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
    fs: brlock vfsmount_lock
    fs: scale files_lock
    lglock: introduce special lglock and brlock spin locks
    tty: fix fu_list abuse
    fs: cleanup files_lock locking
    fs: remove extra lookup in __lookup_hash
    fs: fs_struct rwlock to spinlock
    apparmor: use task path helpers
    fs: dentry allocation consolidation
    fs: fix do_lookup false negative
    mbcache: Limit the maximum number of cache entries
    hostfs ->follow_link() braino
    hostfs: dumb (and usually harmless) tpyo - strncpy instead of strlcpy
    remove SWRITE* I/O types
    kill BH_Ordered flag
    vfs: update ctime when changing the file's permission by setfacl
    cramfs: only unlock new inodes
    fix reiserfs_evict_inode end_writeback second call

    Linus Torvalds
     

18 Aug, 2010

5 commits

  • tty: fix fu_list abuse

    tty code abuses fu_list, which causes a bug in remount,ro handling.

    If a tty device node is opened on a filesystem, then the last link to the inode
    removed, the filesystem will be allowed to be remounted readonly. This is
    because fs_may_remount_ro does not find the 0 link tty inode on the file sb
    list (because the tty code incorrectly removed it to use for its own purpose).
    This can result in a filesystem with errors after it is marked "clean".

    Taking idea from Christoph's initial patch, allocate a tty private struct
    at file->private_data and put our required list fields in there, linking
    file and tty. This makes tty nodes behave the same way as other device nodes
    and avoid meddling with the vfs, and avoids this bug.

    The error handling is not trivial in the tty code, so for this bugfix, I take
    the simple approach of using __GFP_NOFAIL and don't worry about memory errors.
    This is not a problem because our allocator doesn't fail small allocs as a rule
    anyway. So proper error handling is left as an exercise for tty hackers.

    [ Arguably filesystem's device inode would ideally be divorced from the
    driver's pseudo inode when it is opened, but in practice it's not clear whether
    that will ever be worth implementing. ]

    Cc: linux-kernel@vger.kernel.org
    Cc: Christoph Hellwig
    Cc: Alan Cox
    Cc: Greg Kroah-Hartman
    Signed-off-by: Nick Piggin
    Signed-off-by: Al Viro

    Nick Piggin
     
  • fs: cleanup files_lock locking

    Lock tty_files with a new spinlock, tty_files_lock; provide helpers to
    manipulate the per-sb files list; unexport the files_lock spinlock.

    Cc: linux-kernel@vger.kernel.org
    Cc: Christoph Hellwig
    Cc: Alan Cox
    Acked-by: Andi Kleen
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: Nick Piggin
    Signed-off-by: Al Viro

    Nick Piggin
     
  • apparmor: use task path helpers

    Signed-off-by: Nick Piggin
    Signed-off-by: Al Viro

    Nick Piggin
     
  • …s/security-testing-2.6

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6:
    AppArmor: fix task_setrlimit prototype

    Linus Torvalds
     
  • Make do_execve() take a const filename pointer so that kernel_execve() compiles
    correctly on ARM:

    arch/arm/kernel/sys_arm.c:88: warning: passing argument 1 of 'do_execve' discards qualifiers from pointer target type

    This also requires the argv and envp arguments to be consted twice, once for
    the pointer array and once for the strings the array points to. This is
    because do_execve() passes a pointer to the filename (now const) to
    copy_strings_kernel(). A simpler alternative would be to cast the filename
    pointer in do_execve() when it's passed to copy_strings_kernel().

    do_execve() may not change any of the strings it is passed as part of the argv
    or envp lists as they are some of them in .rodata, so marking these strings as
    const should be fine.

    Further kernel_execve() and sys_execve() need to be changed to match.

    This has been test built on x86_64, frv, arm and mips.

    Signed-off-by: David Howells
    Tested-by: Ralf Baechle
    Acked-by: Russell King
    Signed-off-by: Linus Torvalds

    David Howells
     

17 Aug, 2010

1 commit

  • After rlimits tree was merged we get the following errors:
    security/apparmor/lsm.c:663:2: warning: initialization from incompatible pointer type

    It is because AppArmor was merged in the meantime, but uses the old
    prototype. So fix it by adding struct task_struct as a first parameter
    of apparmor_task_setrlimit.

    NOTE that this is ONLY a compilation warning fix (and crashes caused
    by that). It needs proper handling in AppArmor depending on who is the
    'task'.

    Signed-off-by: Jiri Slaby
    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    Jiri Slaby
     

13 Aug, 2010

2 commits

  • * 'params' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus: (22 commits)
    param: don't deref arg in __same_type() checks
    param: update drivers/acpi/debug.c to new scheme
    param: use module_param in drivers/message/fusion/mptbase.c
    ide: use module_param_named rather than module_param_call
    param: update drivers/char/ipmi/ipmi_watchdog.c to new scheme
    param: lock if_sdio's lbs_helper_name and lbs_fw_name against sysfs changes.
    param: lock myri10ge_fw_name against sysfs changes.
    param: simple locking for sysfs-writable charp parameters
    param: remove unnecessary writable charp
    param: add kerneldoc to moduleparam.h
    param: locking for kernel parameters
    param: make param sections const.
    param: use free hook for charp (fix leak of charp parameters)
    param: add a free hook to kernel_param_ops.
    param: silence .init.text references from param ops
    Add param ops struct for hvc_iucv driver.
    nfs: update for module_param_named API change
    AppArmor: update for module_param_named API change
    param: use ops in struct kernel_param, rather than get and set fns directly
    param: move the EXPORT_SYMBOL to after the definitions.
    ...

    Linus Torvalds
     
  • Add a dummy printk function for the maintenance of unused printks through gcc
    format checking, and also so that side-effect checking is maintained too.

    Signed-off-by: David Howells
    Signed-off-by: Linus Torvalds

    David Howells
     

11 Aug, 2010

3 commits

  • Fixes these build errors:
    security/apparmor/lsm.c:701: error: 'param_ops_aabool' undeclared here (not in a function)
    security/apparmor/lsm.c:721: error: 'param_ops_aalockpolicy' undeclared here (not in a function)
    security/apparmor/lsm.c:729: error: 'param_ops_aauint' undeclared here (not in a function)

    Signed-off-by: Stephen Rothwell
    Signed-off-by: John Johansen
    Signed-off-by: Rusty Russell

    Stephen Rothwell
     
  • * 'writable_limits' of git://decibel.fi.muni.cz/~xslaby/linux:
    unistd: add __NR_prlimit64 syscall numbers
    rlimits: implement prlimit64 syscall
    rlimits: switch more rlimit syscalls to do_prlimit
    rlimits: redo do_setrlimit to more generic do_prlimit
    rlimits: add rlimit64 structure
    rlimits: do security check under task_lock
    rlimits: allow setrlimit to non-current tasks
    rlimits: split sys_setrlimit
    rlimits: selinux, do rlimits changes under task_lock
    rlimits: make sure ->rlim_max never grows in sys_setrlimit
    rlimits: add task_struct to update_rlimit_cpu
    rlimits: security, add task_struct to setrlimit

    Fix up various system call number conflicts. We not only added fanotify
    system calls in the meantime, but asm-generic/unistd.h added a wait4
    along with a range of reserved per-architecture system calls.

    Linus Torvalds
     
  • * 'for-linus' of git://git.infradead.org/users/eparis/notify: (132 commits)
    fanotify: use both marks when possible
    fsnotify: pass both the vfsmount mark and inode mark
    fsnotify: walk the inode and vfsmount lists simultaneously
    fsnotify: rework ignored mark flushing
    fsnotify: remove global fsnotify groups lists
    fsnotify: remove group->mask
    fsnotify: remove the global masks
    fsnotify: cleanup should_send_event
    fanotify: use the mark in handler functions
    audit: use the mark in handler functions
    dnotify: use the mark in handler functions
    inotify: use the mark in handler functions
    fsnotify: send fsnotify_mark to groups in event handling functions
    fsnotify: Exchange list heads instead of moving elements
    fsnotify: srcu to protect read side of inode and vfsmount locks
    fsnotify: use an explicit flag to indicate fsnotify_destroy_mark has been called
    fsnotify: use _rcu functions for mark list traversal
    fsnotify: place marks on object in order of group memory address
    vfs/fsnotify: fsnotify_close can delay the final work in fput
    fsnotify: store struct file not struct path
    ...

    Fix up trivial delete/modify conflict in fs/notify/inotify/inotify.c.

    Linus Torvalds
     

08 Aug, 2010

1 commit


07 Aug, 2010

2 commits

  • Fix build error caused by a stale security/selinux/av_permissions.h in the $(src)
    directory which will override a more recent version in $(obj) that is it
    appears to strike only when building with a separate object directory.

    Signed-off-by: Ralf Baechle
    Acked-by: Eric Paris
    Signed-off-by: James Morris

    Ralf Baechle
     
  • request_key() should return -ENOKEY if the key it constructs has been
    negatively instantiated.

    Without this, request_key() can return an unusable key to its caller,
    and if the caller then does key_validate() that won't catch the problem.

    Signed-off-by: David Howells
    Signed-off-by: Linus Torvalds

    David Howells
     

05 Aug, 2010

2 commits

  • SECURITY_APPARMOR should depend on NET since AUDIT needs
    (depends on) NET.

    Fixes 70-80 errors that occur when CONFIG_NET is not enabled,
    but APPARMOR selects AUDIT without qualification. E.g.:

    audit.c:(.text+0x33361): undefined reference to `netlink_unicast'
    (.text+0x333df): undefined reference to `netlink_unicast'
    audit.c:(.text+0x3341d): undefined reference to `skb_queue_tail'
    audit.c:(.text+0x33424): undefined reference to `kfree_skb'
    audit.c:(.text+0x334cb): undefined reference to `kfree_skb'
    audit.c:(.text+0x33597): undefined reference to `skb_put'
    audit.c:(.text+0x3369b): undefined reference to `__alloc_skb'
    audit.c:(.text+0x336d7): undefined reference to `kfree_skb'
    (.text+0x3374c): undefined reference to `__alloc_skb'
    auditfilter.c:(.text+0x35305): undefined reference to `skb_queue_tail'
    lsm_audit.c:(.text+0x2873): undefined reference to `init_net'
    lsm_audit.c:(.text+0x2878): undefined reference to `dev_get_by_index'

    Signed-off-by: Randy Dunlap
    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    Randy Dunlap
     
  • * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (48 commits)
    Documentation: update broken web addresses.
    fix comment typo "choosed" -> "chosen"
    hostap:hostap_hw.c Fix typo in comment
    Fix spelling contorller -> controller in comments
    Kconfig.debug: FAIL_IO_TIMEOUT: typo Faul -> Fault
    fs/Kconfig: Fix typo Userpace -> Userspace
    Removing dead MACH_U300_BS26
    drivers/infiniband: Remove unnecessary casts of private_data
    fs/ocfs2: Remove unnecessary casts of private_data
    libfc: use ARRAY_SIZE
    scsi: bfa: use ARRAY_SIZE
    drm: i915: use ARRAY_SIZE
    drm: drm_edid: use ARRAY_SIZE
    synclink: use ARRAY_SIZE
    block: cciss: use ARRAY_SIZE
    comment typo fixes: charater => character
    fix comment typos concerning "challenge"
    arm: plat-spear: fix typo in kerneldoc
    reiserfs: typo comment fix
    update email address
    ...

    Linus Torvalds
     

04 Aug, 2010

1 commit


02 Aug, 2010

14 commits

  • Fix build warnings for non-const use of get_task_cred.

    Signed-off-by: James Morris

    James Morris
     
  • Current selinux policy can have over 3000 types. The type_attr_map in
    policy is an array sized by the number of types times sizeof(struct ebitmap)
    (12 on x86_64). Basic math tells us the array is going to be of length
    3000 x 12 = 36,000 bytes. The largest 'safe' allocation on a long running
    system is 16k. Most of the time a 32k allocation will work. But on long
    running systems a 64k allocation (what we need) can fail quite regularly.
    In order to deal with this I am converting the type_attr_map to use
    flex_arrays. Let the library code deal with breaking this into PAGE_SIZE
    pieces.

    -v2
    rework some of the if(!obj) BUG() to be BUG_ON(!obj)
    drop flex_array_put() calls and just use a _get() object directly

    -v3
    make apply to James' tree (drop the policydb_write changes)

    Signed-off-by: Eric Paris
    Acked-by: Stephen D. Smalley
    Signed-off-by: James Morris

    Eric Paris
     
  • Kconfig and Makefiles to enable configuration and building of AppArmor.

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen
     
  • Commit c9e69318 "TOMOYO: Allow wildcard for execute permission." changed execute
    permission and domainname to accept wildcards. But tomoyo_find_next_domain()
    was using pathname passed to execve() rather than pathname specified by the
    execute permission. As a result, processes were not able to transit to domains
    which contain wildcards in their domainnames.

    This patch passes pathname specified by the execute permission back to
    tomoyo_find_next_domain() so that processes can transit to domains which
    contain wildcards in their domainnames.

    Signed-off-by: Tetsuo Handa
    Signed-off-by: James Morris

    Tetsuo Handa
     
  • Remove extraneous path_truncate arguments from the AppArmor hook,
    as they've been removed from the LSM API.

    Signed-off-by: James Morris

    James Morris
     
  • The basic routines and defines for AppArmor policy. AppArmor policy
    is defined by a few basic components.
    profiles - the basic unit of confinement contain all the information
    to enforce policy on a task

    Profiles tend to be named after an executable that they
    will attach to but this is not required.
    namespaces - a container for a set of profiles that will be used
    during attachment and transitions between profiles.
    sids - which provide a unique id for each profile

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen
     
  • AppArmor policy is loaded in a platform independent flattened binary
    stream. Verify and unpack the data converting it to the internal
    format needed for enforcement.

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen
     
  • ipc:
    AppArmor ipc is currently limited to mediation done by file mediation
    and basic ptrace tests. Improved mediation is a wip.

    rlimits:
    AppArmor provides basic abilities to set and control rlimits at
    a per profile level. Only resources specified in a profile are controled
    or set. AppArmor rules set the hard limit to a value
    Signed-off-by: James Morris

    John Johansen
     
  • AppArmor hooks to interface with the LSM, module parameters and module
    initialization.

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen
     
  • Kconfig and Makefiles to enable configuration and building of AppArmor.

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen
     
  • AppArmor routines for controling domain transitions, which can occur at
    exec or through self directed change_profile/change_hat calls.

    Unconfined tasks are checked at exec against the profiles in the confining
    profile namespace to determine if a profile should be attached to the task.

    Confined tasks execs are controlled by the profile which provides rules
    determining which execs are allowed and if so which profiles should be
    transitioned to.

    Self directed domain transitions allow a task to request transition
    to a given profile. If the transition is allowed then the profile will
    be applied, either immeditately or at exec time depending on the request.
    Immeditate self directed transitions have several security limitations
    but have uses in setting up stub transition profiles and other limited
    cases.

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen
     
  • AppArmor does files enforcement via pathname matching. Matching is done
    at file open using a dfa match engine. Permission is against the final
    file object not parent directories, ie. the traversal of directories
    as part of the file match is implicitly allowed. In the case of nonexistant
    files (creation) permissions are checked against the target file not the
    directory. eg. In case of creating the file /dir/new, permissions are
    checked against the match /dir/new not against /dir/.

    The permissions for matches are currently stored in the dfa accept table,
    but this will change to allow for dfa reuse and also to allow for sharing
    of wider accept states.

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen
     
  • The /proc//attr/* interface is used for process introspection and
    commands. While the apparmorfs interface is used for global introspection
    and loading and removing policy.

    The interface currently only contains the files necessary for loading
    policy, and will be extended in the future to include sysfs style
    single per file introspection inteface.

    The old AppArmor 2.4 interface files have been removed into a compatibility
    patch, that distros can use to maintain backwards compatibility.

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen
     
  • A basic dfa matching engine based off the dfa engine in the Dragon
    Book. It uses simple row comb compression with a check field.

    This allows AppArmor to do pattern matching in linear time, and also
    avoids stack issues that an nfa based engine may have. The dfa
    engine uses a byte based comparison, with all values being valid.
    Any potential character encoding are handled user side when the dfa
    tables are created. By convention AppArmor uses \0 to separate two
    dependent path matches since \0 is not a valid path character
    (this is done in the link permission check).

    The dfa tables are generated in user space and are verified at load
    time to be internally consistent.

    There are several future improvements planned for the dfa engine:
    * The dfa engine may be converted to a hybrid nfa-dfa engine, with
    a fixed size limited stack. This would allow for size time
    tradeoffs, by inserting limited nfa states to help control
    state explosion that can occur with dfas.
    * The dfa engine may pickup the ability to do limited dynamic
    variable matching, instead of fixing all variables at policy
    load time.

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen