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

22 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
     
  • AppArmor contexts attach profiles and state to tasks, files, etc. when
    a direct profile reference is not sufficient.

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

    John Johansen
     
  • Update lsm_audit for AppArmor specific data, and add the core routines for
    AppArmor uses for auditing.

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

    John Johansen
     
  • Miscellaneous functions and defines needed by AppArmor, including
    the base path resolution routines.

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

    John Johansen
     
  • Signed-off-by: Tetsuo Handa
    Signed-off-by: James Morris

    Tetsuo Handa
     
  • Commit d74725b9 "TOMOYO: Use callback for updating entries." broke
    tomoyo_domain_quota_is_ok() by counting deleted entries. It needs to
    count non-deleted entries.

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

    Tetsuo Handa
     
  • execmod "could" show up on non regular files and non chr files. The current
    implementation would actually make these checks against non-existant bits
    since the code assumes the execmod permission is same for all file types.
    To make this line up for chr files we had to define execute_no_trans and
    entrypoint permissions. These permissions are unreachable and only existed
    to to make FILE__EXECMOD and CHR_FILE__EXECMOD the same. This patch drops
    those needless perms as well.

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

    Eric Paris
     
  • kernel can dynamically remap perms. Drop the open lookup table and put open
    in the common file perms.

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

    Eric Paris
     
  • Currently there are a number of applications (nautilus being the main one) which
    calls access() on files in order to determine how they should be displayed. It
    is normal and expected that nautilus will want to see if files are executable
    or if they are really read/write-able. access() should return the real
    permission. SELinux policy checks are done in access() and can result in lots
    of AVC denials as policy denies RWX on files which DAC allows. Currently
    SELinux must dontaudit actual attempts to read/write/execute a file in
    order to silence these messages (and not flood the logs.) But dontaudit rules
    like that can hide real attacks. This patch addes a new common file
    permission audit_access. This permission is special in that it is meaningless
    and should never show up in an allow rule. Instead the only place this
    permission has meaning is in a dontaudit rule like so:

    dontaudit nautilus_t sbin_t:file audit_access

    With such a rule if nautilus just checks access() we will still get denied and
    thus userspace will still get the correct answer but we will not log the denial.
    If nautilus attempted to actually perform one of the forbidden actions
    (rather than just querying access(2) about it) we would still log a denial.
    This type of dontaudit rule should be used sparingly, as it could be a
    method for an attacker to probe the system permissions without detection.

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

    Eric Paris