Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Commits on Sep 18, 2012
  1. @ebiederm

    userns: Add kprojid_t and associated infrastructure in projid.h

    ebiederm committed
    Implement kprojid_t a cousin of the kuid_t and kgid_t.
    The per user namespace mapping of project id values can be set with
    A full compliment of helpers is provided: make_kprojid, from_kprojid,
    from_kprojid_munged, kporjid_has_mapping, projid_valid, projid_eq,
    projid_eq, projid_lt.
    Project identifiers are part of the generic disk quota interface,
    although it appears only xfs implements project identifiers currently.
    The xfs code allows anyone who has permission to set the project
    identifier on a file to use any project identifier so when
    setting up the user namespace project identifier mappings I do
    not require a capability.
    Cc: Dave Chinner <>
    Cc: Jan Kara <>
    Signed-off-by: "Eric W. Biederman" <>
Commits on May 19, 2012
  1. @ebiederm

    userns: Silence silly gcc warning.

    ebiederm committed
    On 32bit builds gcc says:
    kernel/user.c:30:4: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
    kernel/user.c:38:4: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
    Silence gcc by changing the constant 4294967295 to 4294967295U.
    Signed-off-by: Eric W. Biederman <>
Commits on Apr 26, 2012
  1. @ebiederm

    userns: Rework the user_namespace adding uid/gid mapping support

    ebiederm committed
    - Convert the old uid mapping functions into compatibility wrappers
    - Add a uid/gid mapping layer from user space uid and gids to kernel
      internal uids and gids that is extent based for simplicty and speed.
      * Working with number space after mapping uids/gids into their kernel
        internal version adds only mapping complexity over what we have today,
        leaving the kernel code easy to understand and test.
    - Add proc files /proc/self/uid_map /proc/self/gid_map
      These files display the mapping and allow a mapping to be added
      if a mapping does not exist.
    - Allow entering the user namespace without a uid or gid mapping.
      Since we are starting with an existing user our uids and gids
      still have global mappings so are still valid and useful they just don't
      have local mappings.  The requirement for things to work are global uid
      and gid so it is odd but perfectly fine not to have a local uid
      and gid mapping.
      Not requiring global uid and gid mappings greatly simplifies
      the logic of setting up the uid and gid mappings by allowing
      the mappings to be set after the namespace is created which makes the
      slight weirdness worth it.
    - Make the mappings in the initial user namespace to the global
      uid/gid space explicit.  Today it is an identity mapping
      but in the future we may want to twist this for debugging, similar
      to what we do with jiffies.
    - Document the memory ordering requirements of setting the uid and
      gid mappings.  We only allow the mappings to be set once
      and there are no pointers involved so the requirments are
      trivial but a little atypical.
    In this scheme for the permission checks the performance is expected to
    stay the same as the actuall machine instructions should remain the same.
    The worst case I could think of is ls -l on a large directory where
    all of the stat results need to be translated with from kuids and
    kgids to uids and gids.  So I benchmarked that case on my laptop
    with a dual core hyperthread Intel i5-2520M cpu with 3M of cpu cache.
    My benchmark consisted of going to single user mode where nothing else
    was running. On an ext4 filesystem opening 1,000,000 files and looping
    through all of the files 1000 times and calling fstat on the
    individuals files.  This was to ensure I was benchmarking stat times
    where the inodes were in the kernels cache, but the inode values were
    not in the processors cache.  My results:
    v3.4-rc1:         ~= 156ns (unmodified v3.4-rc1 with user namespace support disabled)
    v3.4-rc1-userns-: ~= 155ns (v3.4-rc1 with my user namespace patches and user namespace support disabled)
    v3.4-rc1-userns+: ~= 164ns (v3.4-rc1 with my user namespace patches and user namespace support enabled)
    All of the configurations ran in roughly 120ns when I performed tests
    that ran in the cpu cache.
    So in summary the performance impact is:
    1ns improvement in the worst case with user namespace support compiled out.
    8ns aka 5% slowdown in the worst case with user namespace support compiled in.
    Acked-by: Serge Hallyn <>
    Signed-off-by: Eric W. Biederman <>
  2. @ebiederm

    userns: Simplify the user_namespace by making userns->creator a kuid.

    ebiederm committed
    - Transform userns->creator from a user_struct reference to a simple
      kuid_t, kgid_t pair.
      In cap_capable this allows the check to see if we are the creator of
      a namespace to become the classic suser style euid permission check.
      This allows us to remove the need for a struct cred in the mapping
      functions and still be able to dispaly the user namespace creators
      uid and gid as 0.
    - Remove the now unnecessary delayed_work in free_user_ns.
      All that is left for free_user_ns to do is to call kmem_cache_free
      and put_user_ns.  Those functions can be called in any context
      so call them directly from free_user_ns removing the need for delayed work.
    Acked-by: Serge Hallyn <>
    Signed-off-by: Eric W. Biederman <>
Commits on Apr 8, 2012
  1. @ebiederm

    userns: Disassociate user_struct from the user_namespace.

    ebiederm committed
    Modify alloc_uid to take a kuid and make the user hash table global.
    Stop holding a reference to the user namespace in struct user_struct.
    This simplifies the code and makes the per user accounting not
    care about which user namespace a uid happens to appear in.
    Acked-by: Serge Hallyn <>
    Signed-off-by: Eric W. Biederman <>
Commits on Apr 7, 2012
  1. @ebiederm

    userns: Deprecate and rename the user_namespace reference in the user…

    ebiederm committed
    With a user_ns reference in struct cred the only user of the user namespace
    reference in struct user_struct is to keep the uid hash table alive.
    The user_namespace reference in struct user_struct will be going away soon, and
    I have removed all of the references.  Rename the field from user_ns to _user_ns
    so that the compiler can verify nothing follows the user struct to the user
    namespace anymore.
    Acked-by: Serge Hallyn <>
    Signed-off-by: Eric W. Biederman <>
Commits on Oct 31, 2011
  1. @paulgortmaker

    kernel: Map most files to use export.h instead of module.h

    paulgortmaker committed
    The changed files were only including linux/module.h for the
    EXPORT_SYMBOL infrastructure, and nothing else.  Revector them
    onto the isolated export header for faster compile times.
    Nothing to see here but a whole lot of instances of:
      -#include <linux/module.h>
      +#include <linux/export.h>
    This commit is only changing the kernel dir; next targets
    will probably be mm, fs, the arch dirs, etc.
    Signed-off-by: Paul Gortmaker <>
Commits on Mar 24, 2011
  1. @hallyn

    userns: add a user_namespace as creator/owner of uts_namespace

    hallyn committed with
    The expected course of development for user namespaces targeted
    capabilities is laid out at
    - Make it safe for an unprivileged user to unshare namespaces.  They
      will be privileged with respect to the new namespace, but this should
      only include resources which the unprivileged user already owns.
    - Provide separate limits and accounting for userids in different
      Currently (as of 2.6.38) you can clone with the CLONE_NEWUSER flag to
      get a new user namespace if you have the CAP_SYS_ADMIN, CAP_SETUID, and
      CAP_SETGID capabilities.  What this gets you is a whole new set of
      userids, meaning that user 500 will have a different 'struct user' in
      your namespace than in other namespaces.  So any accounting information
      stored in struct user will be unique to your namespace.
      However, throughout the kernel there are checks which
      - simply check for a capability.  Since root in a child namespace
        has all capabilities, this means that a child namespace is not
      - simply compare uid1 == uid2.  Since these are the integer uids,
        uid 500 in namespace 1 will be said to be equal to uid 500 in
        namespace 2.
      As a result, the lxc implementation at does not use user
      namespaces.  This is actually helpful because it leaves us free to
      develop user namespaces in such a way that, for some time, user
      namespaces may be unuseful.
    Bugs aside, this patchset is supposed to not at all affect systems which
    are not actively using user namespaces, and only restrict what tasks in
    child user namespace can do.  They begin to limit privilege to a user
    namespace, so that root in a container cannot kill or ptrace tasks in the
    parent user namespace, and can only get world access rights to files.
    Since all files currently belong to the initila user namespace, that means
    that child user namespaces can only get world access rights to *all*
    files.  While this temporarily makes user namespaces bad for system
    containers, it starts to get useful for some sandboxing.
    I've run the '' with and without this patchset and found no
    This patch:
    copy_process() handles CLONE_NEWUSER before the rest of the namespaces.
    So in the case of clone(CLONE_NEWUSER|CLONE_NEWUTS) the new uts namespace
    will have the new user namespace as its owner.  That is what we want,
    since we want root in that new userns to be able to have privilege over
    	Feb 15: don't set uts_ns->user_ns if we didn't create
    		a new uts_ns.
    	Feb 23: Move extern init_user_ns declaration from
    		init/version.c to utsname.h.
    Signed-off-by: Serge E. Hallyn <>
    Acked-by: "Eric W. Biederman" <>
    Acked-by: Daniel Lezcano <>
    Acked-by: David Howells <>
    Cc: James Morris <>
    Signed-off-by: Andrew Morton <>
    Signed-off-by: Linus Torvalds <>
Commits on Dec 29, 2010
  1. fix freeing user_struct in user cache

    Hillf Danton committed with
    When racing on adding into user cache, the new allocated from mm slab
    is freed without putting user namespace.
    Since the user namespace is already operated by getting, putting has
    to be issued.
    Signed-off-by: Hillf Danton <>
    Acked-by: Serge Hallyn <>
    Signed-off-by: Linus Torvalds <>
Commits on Oct 26, 2010
  1. @namhyung

    kernel/user.c: add lock release annotation on free_user()

    namhyung committed with
    free_user() releases uidhash_lock but was missing annotation.  Add it.
    This removes following sparse warnings:
     include/linux/spinlock.h:339:9: warning: context imbalance in 'free_user' - unexpected unlock
     kernel/user.c:120:6: warning: context imbalance in 'free_uid' - wrong count at exit
    Signed-off-by: Namhyung Kim <>
    Cc: Ingo Molnar <>
    Cc: Dhaval Giani <>
    Signed-off-by: Andrew Morton <>
    Signed-off-by: Linus Torvalds <>
Commits on May 10, 2010
  1. sched: Remove a stale comment

    Li Zefan committed with Ingo Molnar
    This comment should have been removed together with uids_mutex
    when removing user sched.
    Signed-off-by: Li Zefan <>
    Cc: Peter Zijlstra <>
    Cc: Dhaval Giani <>
    LKML-Reference: <>
    Signed-off-by: Ingo Molnar <>
Commits on Apr 2, 2010
  1. sched: Remove remaining USER_SCHED code

    Li Zefan committed with Ingo Molnar
    This is left over from commit 7c94143 ("sched: Remove USER_SCHED"")
    Signed-off-by: Li Zefan <>
    Acked-by: Dhaval Giani <>
    Signed-off-by: Peter Zijlstra <>
    Cc: David Howells <>
    LKML-Reference: <>
    Signed-off-by: Ingo Molnar <>
Commits on Mar 16, 2010
  1. @error27

    sched: Remove some dead code

    error27 committed with Ingo Molnar
    This was left over from "7c9414385e sched: Remove USER_SCHED"
    Signed-off-by: Dan Carpenter <>
    Acked-by: Dhaval Giani <>
    Cc: Kay Sievers <>
    Cc: Greg Kroah-Hartman <>
    LKML-Reference: <20100315082148.GD18181@bicker>
    Signed-off-by: Ingo Molnar <>
Commits on Jan 21, 2010
  1. @giani

    sched: Remove USER_SCHED

    giani committed with Ingo Molnar
    Remove the USER_SCHED feature. It has been scheduled to be removed in
    2.6.34 as per
    Signed-off-by: Dhaval Giani <>
    Signed-off-by: Peter Zijlstra <>
    LKML-Reference: <1263990378.24844.3.camel@localhost>
    Signed-off-by: Ingo Molnar <>
Commits on Nov 2, 2009
  1. uids: Prevent tear down race

    Thomas Gleixner committed
    Ingo triggered the following warning:
    WARNING: at lib/debugobjects.c:255 debug_print_object+0x42/0x50()
    Hardware name: System Product Name
    ODEBUG: init active object type: timer_list
    Modules linked in:
    Pid: 2619, comm: dmesg Tainted: G        W  2.6.32-rc5-tip+ #5298
    Call Trace:
     [<81035443>] warn_slowpath_common+0x6a/0x81
     [<8120e483>] ? debug_print_object+0x42/0x50
     [<81035498>] warn_slowpath_fmt+0x29/0x2c
     [<8120e483>] debug_print_object+0x42/0x50
     [<8120ec2a>] __debug_object_init+0x279/0x2d7
     [<8120ecb3>] debug_object_init+0x13/0x18
     [<810409d2>] init_timer_key+0x17/0x6f
     [<81041526>] free_uid+0x50/0x6c
     [<8104ed2d>] put_cred_rcu+0x61/0x72
     [<81067fac>] rcu_do_batch+0x70/0x121
    debugobjects warns about an enqueued timer being initialized. If
    CONFIG_USER_SCHED=y the user management code uses delayed work to
    remove the user from the hash table and tear down the sysfs objects.
    free_uid is called from RCU and initializes/schedules delayed work if
    the usage count of the user_struct is 0. The init/schedule happens
    outside of the uidhash_lock protected region which allows a concurrent
    caller of find_user() to reference the about to be destroyed
    user_struct w/o preventing the work from being scheduled. If the next
    free_uid call happens before the work timer expired then the active
    timer is initialized and the work scheduled again.
    The race was introduced in commit 5cb350b (sched: group scheduling,
    sysfs tunables) and made more prominent by commit 3959214 (sched:
    delayed cleanup of user_struct)
    Move the init/schedule_delayed_work inside of the uidhash_lock
    protected region to prevent the race.
    Signed-off-by: Thomas Gleixner <>
    Acked-by: Dhaval Giani <>
    Cc: Paul E. McKenney <>
    Cc: Kay Sievers <>
Commits on Jun 16, 2009
  1. @kaysievers @gregkh

    sched: delayed cleanup of user_struct

    kaysievers committed with gregkh
    During bootup performance tracing we see repeated occurrences of
    /sys/kernel/uid/* events for the same uid, leading to a,
    in this case, rather pointless userspace processing for the
    same uid over and over.
    This is usually caused by tools which change their uid to "nobody",
    to run without privileges to read data supplied by untrusted users.
    This change delays the execution of the (already existing) scheduled
    work, to cleanup the uid after one second, so the allocated and announced
    uid can possibly be re-used by another process.
    This is the current behavior, where almost every invocation of a
    binary, which changes the uid, creates two events:
      $ read START < /sys/kernel/uevent_seqnum; \
      for i in `seq 100`; do su --shell=/bin/true bin; done; \
      read END < /sys/kernel/uevent_seqnum; \
      echo $(($END - $START))
    With the delayed cleanup, we get only two events, and userspace finishes
    a bit faster too:
      $ read START < /sys/kernel/uevent_seqnum; \
      for i in `seq 100`; do su --shell=/bin/true bin; done; \
      read END < /sys/kernel/uevent_seqnum; \
      echo $(($END - $START))
    Acked-by: Dhaval Giani <>
    Signed-off-by: Kay Sievers <>
    Signed-off-by: Greg Kroah-Hartman <>
Commits on Mar 23, 2009
  1. Merge branch 'master' into next

    James Morris committed
Commits on Mar 10, 2009
  1. kernel/user.c: fix a memory leak when freeing up non-init usernamespa…

    Dhaval Giani committed with
    …ces users
    We were returning early in the sysfs directory cleanup function if the
    user belonged to a non init usernamespace.  Due to this a lot of the
    cleanup was not done and we were left with a leak.  Fix the leak.
    Reported-by: Serge Hallyn <>
    Signed-off-by: Dhaval Giani <>
    Acked-by: Serge Hallyn <>
    Tested-by: Serge Hallyn <>
    Signed-off-by: Andrew Morton <>
    Signed-off-by: Linus Torvalds <>
Commits on Feb 27, 2009
  1. sched: don't allow setuid to succeed if the user does not have rt ban…

    Dhaval Giani committed with Ingo Molnar
    Impact: fix hung task with certain (non-default) rt-limit settings
    Corey Hickey reported that on using setuid to change the uid of a
    rt process, the process would be unkillable and not be running.
    This is because there was no rt runtime for that user group. Add
    in a check to see if a user can attach an rt task to its task group.
    On failure, return EINVAL, which is also returned in
    Reported-by: Corey Hickey <>
    Signed-off-by: Dhaval Giani <>
    Acked-by: Peter Zijlstra <>
    Signed-off-by: Ingo Molnar <>
  2. keys: distinguish per-uid keys in different namespaces

    Serge E. Hallyn committed with James Morris
    per-uid keys were looked by uid only.  Use the user namespace
    to distinguish the same uid in different namespaces.
    This does not address key_permission.  So a task can for instance
    try to join a keyring owned by the same uid in another namespace.
    That will be handled by a separate patch.
    Signed-off-by: Serge E. Hallyn <>
    Acked-by: David Howells <>
    Signed-off-by: James Morris <>
Commits on Feb 13, 2009
  1. User namespaces: Only put the userns when we unhash the uid

    Serge E. Hallyn committed with
    uids in namespaces other than init don't get a sysfs entry.
    For those in the init namespace, while we're waiting to remove
    the sysfs entry for the uid the uid is still hashed, and
    alloc_uid() may re-grab that uid without getting a new
    reference to the user_ns, which we've already put in free_user
    before scheduling remove_user_sysfs_dir().
    Reported-and-tested-by: KOSAKI Motohiro <>
    Signed-off-by: Serge E. Hallyn <>
    Acked-by: David Howells <>
    Tested-by: Ingo Molnar <>
    Signed-off-by: Linus Torvalds <>
Commits on Dec 28, 2008
  1. Merge branch 'sched-core-for-linus' of git://…

    * 'sched-core-for-linus' of git:// (31 commits)
      sched: fix warning in fs/proc/base.c
      schedstat: consolidate per-task cpu runtime stats
      sched: use RCU variant of list traversal in for_each_leaf_rt_rq()
      sched, cpuacct: export percpu cpuacct cgroup stats
      sched, cpuacct: refactoring cpuusage_read / cpuusage_write
      sched: optimize update_curr()
      sched: fix wakeup preemption clock
      sched: add missing arch_update_cpu_topology() call
      sched: let arch_update_cpu_topology indicate if topology changed
      sched: idle_balance() does not call load_balance_newidle()
      sched: fix sd_parent_degenerate on non-numa smp machine
      sched: add uid information to sched_debug for CONFIG_USER_SCHED
      sched: move double_unlock_balance() higher
      sched: update comment for move_task_off_dead_cpu
      sched: fix inconsistency when redistribute per-cpu tg->cfs_rq shares
      sched/rt: removed unneeded defintion
      sched: add hierarchical accounting to cpu accounting controller
      sched: include group statistics in /proc/sched_debug
      sched: clean up SCHED_CPUMASK_ALLOC
Commits on Dec 8, 2008
  1. user namespaces: document CFS behavior

    Serge E. Hallyn committed with James Morris
    Documented the currently bogus state of support for CFS user groups with
    user namespaces.  In particular, all users in a user namespace should be
    children of the user which created the user namespace.  This is yet to
    be implemented.
    Signed-off-by: Serge E. Hallyn <>
    Acked-by: Dhaval Giani <>
    Signed-off-by: Serge E. Hallyn <>
    Signed-off-by: James Morris <>
Commits on Dec 7, 2008
  1. user namespaces: let user_ns be cloned with fairsched

    Serge E. Hallyn committed with James Morris
    (These two patches are in the next-unacked branch of
    If they get some ACKs, then I hope to feed this into security-next.
    After these two, I think we're ready to tackle userns+capabilities)
    Fairsched creates a per-uid directory under /sys/kernel/uids/.
    So when you clone(CLONE_NEWUSER), it tries to create
    /sys/kernel/uids/0, which already exists, and you get back
    This was supposed to be fixed by sysfs tagging, but that
    was postponed (ok, rejected until sysfs locking is fixed).
    So, just as with network namespaces, we just don't create
    those directories for user namespaces other than the init.
    Signed-off-by: Serge E. Hallyn <>
    Signed-off-by: James Morris <>
Commits on Dec 1, 2008
  1. sched: add uid information to sched_debug for CONFIG_USER_SCHED

    Arun R Bharadwaj committed with Ingo Molnar
    Impact: extend information in /proc/sched_debug
    This patch adds uid information in sched_debug for CONFIG_USER_SCHED
    Signed-off-by: Arun R Bharadwaj <>
    Acked-by: Peter Zijlstra <>
    Signed-off-by: Ingo Molnar <>
Commits on Nov 24, 2008
  1. User namespaces: use the current_user_ns() macro

    Serge Hallyn committed
    Fix up the last current_user()->user_ns instance to use
    Signed-off-by: Serge E. Hallyn <>
  2. User namespaces: set of cleanups (v2)

    Serge Hallyn committed
    The user_ns is moved from nsproxy to user_struct, so that a struct
    cred by itself is sufficient to determine access (which it otherwise
    would not be).  Corresponding ecryptfs fixes (by David Howells) are
    here as well.
    Fix refcounting.  The following rules now apply:
            1. The task pins the user struct.
            2. The user struct pins its user namespace.
            3. The user namespace pins the struct user which created it.
    User namespaces are cloned during copy_creds().  Unsharing a new user_ns
    is no longer possible.  (We could re-add that, but it'll cause code
    duplication and doesn't seem useful if PAM doesn't need to clone user
    When a user namespace is created, its first user (uid 0) gets empty
    keyrings and a clean group_info.
    This incorporates a previous patch by David Howells.  Here
    is his original patch description:
    >I suggest adding the attached incremental patch.  It makes the following
    > (1) Provides a current_user_ns() macro to wrap accesses to current's user
    >     namespace.
    > (2) Fixes eCryptFS.
    > (3) Renames create_new_userns() to create_user_ns() to be more consistent
    >     with the other associated functions and because the 'new' in the name is
    >     superfluous.
    > (4) Moves the argument and permission checks made for CLONE_NEWUSER to the
    >     beginning of do_fork() so that they're done prior to making any attempts
    >     at allocation.
    > (5) Calls create_user_ns() after prepare_creds(), and gives it the new creds
    >     to fill in rather than have it return the new root user.  I don't imagine
    >     the new root user being used for anything other than filling in a cred
    >     struct.
    >     This also permits me to get rid of a get_uid() and a free_uid(), as the
    >     reference the creds were holding on the old user_struct can just be
    >     transferred to the new namespace's creator pointer.
    > (6) Makes create_user_ns() reset the UIDs and GIDs of the creds under
    >     preparation rather than doing it in copy_creds().
    >Signed-off-by: David Howells <>
    	Oct 20: integrate dhowells comments
    		1. leave thread_keyring alone
    		2. use current_user_ns() in set_user()
    Signed-off-by: Serge Hallyn <>
Commits on Nov 13, 2008
  1. CRED: Inaugurate COW credentials

    David Howells committed with James Morris
    Inaugurate copy-on-write credentials management.  This uses RCU to manage the
    credentials pointer in the task_struct with respect to accesses by other tasks.
    A process may only modify its own credentials, and so does not need locking to
    access or modify its own credentials.
    A mutex (cred_replace_mutex) is added to the task_struct to control the effect
    of PTRACE_ATTACHED on credential calculations, particularly with respect to
    With this patch, the contents of an active credentials struct may not be
    changed directly; rather a new set of credentials must be prepared, modified
    and committed using something like the following sequence of events:
    	struct cred *new = prepare_creds();
    	int ret = blah(new);
    	if (ret < 0) {
    		return ret;
    	return commit_creds(new);
    There are some exceptions to this rule: the keyrings pointed to by the active
    credentials may be instantiated - keyrings violate the COW rule as managing
    COW keyrings is tricky, given that it is possible for a task to directly alter
    the keys in a keyring in use by another task.
    To help enforce this, various pointers to sets of credentials, such as those in
    the task_struct, are declared const.  The purpose of this is compile-time
    discouragement of altering credentials through those pointers.  Once a set of
    credentials has been made public through one of these pointers, it may not be
    modified, except under special circumstances:
      (1) Its reference count may incremented and decremented.
      (2) The keyrings to which it points may be modified, but not replaced.
    The only safe way to modify anything else is to create a replacement and commit
    using the functions described in Documentation/credentials.txt (which will be
    added by a later patch).
    This patch and the preceding patches have been tested with the LTP SELinux
    This patch makes several logical sets of alteration:
     (1) execve().
         This now prepares and commits credentials in various places in the
         security code rather than altering the current creds directly.
     (2) Temporary credential overrides.
         do_coredump() and sys_faccessat() now prepare their own credentials and
         temporarily override the ones currently on the acting thread, whilst
         preventing interference from other threads by holding cred_replace_mutex
         on the thread being dumped.
         This will be replaced in a future patch by something that hands down the
         credentials directly to the functions being called, rather than altering
         the task's objective credentials.
     (3) LSM interface.
         A number of functions have been changed, added or removed:
         (*) security_capset_check(), ->capset_check()
         (*) security_capset_set(), ->capset_set()
         	 Removed in favour of security_capset().
         (*) security_capset(), ->capset()
         	 New.  This is passed a pointer to the new creds, a pointer to the old
         	 creds and the proposed capability sets.  It should fill in the new
         	 creds or return an error.  All pointers, barring the pointer to the
         	 new creds, are now const.
         (*) security_bprm_apply_creds(), ->bprm_apply_creds()
         	 Changed; now returns a value, which will cause the process to be
         	 killed if it's an error.
         (*) security_task_alloc(), ->task_alloc_security()
         	 Removed in favour of security_prepare_creds().
         (*) security_cred_free(), ->cred_free()
         	 New.  Free security data attached to cred->security.
         (*) security_prepare_creds(), ->cred_prepare()
         	 New. Duplicate any security data attached to cred->security.
         (*) security_commit_creds(), ->cred_commit()
         	 New. Apply any security effects for the upcoming installation of new
         	 security by commit_creds().
         (*) security_task_post_setuid(), ->task_post_setuid()
         	 Removed in favour of security_task_fix_setuid().
         (*) security_task_fix_setuid(), ->task_fix_setuid()
         	 Fix up the proposed new credentials for setuid().  This is used by
         	 cap_set_fix_setuid() to implicitly adjust capabilities in line with
         	 setuid() changes.  Changes are made to the new credentials, rather
         	 than the task itself as in security_task_post_setuid().
         (*) security_task_reparent_to_init(), ->task_reparent_to_init()
         	 Removed.  Instead the task being reparented to init is referred
         	 directly to init's credentials.
    	 NOTE!  This results in the loss of some state: SELinux's osid no
    	 longer records the sid of the thread that forked it.
         (*) security_key_alloc(), ->key_alloc()
         (*) security_key_permission(), ->key_permission()
         	 Changed.  These now take cred pointers rather than task pointers to
         	 refer to the security context.
     (4) sys_capset().
         This has been simplified and uses less locking.  The LSM functions it
         calls have been merged.
     (5) reparent_to_kthreadd().
         This gives the current thread the same credentials as init by simply using
         commit_thread() to point that way.
     (6) __sigqueue_alloc() and switch_uid()
         __sigqueue_alloc() can't stop the target task from changing its creds
         beneath it, so this function gets a reference to the currently applicable
         user_struct which it then passes into the sigqueue struct it returns if
         switch_uid() is now called from commit_creds(), and possibly should be
         folded into that.  commit_creds() should take care of protecting
     (7) [sg]et[ug]id() and co and [sg]et_current_groups.
         The set functions now all use prepare_creds(), commit_creds() and
         abort_creds() to build and check a new set of credentials before applying
         security_task_set[ug]id() is called inside the prepared section.  This
         guarantees that nothing else will affect the creds until we've finished.
         The calling of set_dumpable() has been moved into commit_creds().
         Much of the functionality of set_user() has been moved into
         The get functions all simply access the data directly.
     (8) security_task_prctl() and cap_task_prctl().
         security_task_prctl() has been modified to return -ENOSYS if it doesn't
         want to handle a function, or otherwise return the return value directly
         rather than through an argument.
         Additionally, cap_task_prctl() now prepares a new set of credentials, even
         if it doesn't end up using it.
     (9) Keyrings.
         A number of changes have been made to the keyrings code:
         (a) switch_uid_keyring(), copy_keys(), exit_keys() and suid_keys() have
         	 all been dropped and built in to the credentials functions directly.
         	 They may want separating out again later.
         (b) key_alloc() and search_process_keyrings() now take a cred pointer
         	 rather than a task pointer to specify the security context.
         (c) copy_creds() gives a new thread within the same thread group a new
         	 thread keyring if its parent had one, otherwise it discards the thread
         (d) The authorisation key now points directly to the credentials to extend
         	 the search into rather pointing to the task that carries them.
         (e) Installing thread, process or session keyrings causes a new set of
         	 credentials to be created, even though it's not strictly necessary for
         	 process or session keyrings (they're shared).
    (10) Usermode helper.
         The usermode helper code now carries a cred struct pointer in its
         subprocess_info struct instead of a new session keyring pointer.  This set
         of credentials is derived from init_cred and installed on the new process
         after it has been cloned.
         call_usermodehelper_setup() allocates the new credentials and
         call_usermodehelper_freeinfo() discards them if they haven't been used.  A
         special cred function (prepare_usermodeinfo_creds()) is provided
         specifically for call_usermodehelper_setup() to call.
         call_usermodehelper_setkeys() adjusts the credentials to sport the
         supplied keyring as the new session keyring.
    (11) SELinux.
         SELinux has a number of changes, in addition to those to support the LSM
         interface changes mentioned above:
         (a) selinux_setprocattr() no longer does its check for whether the
         	 current ptracer can access processes with the new SID inside the lock
         	 that covers getting the ptracer's SID.  Whilst this lock ensures that
         	 the check is done with the ptracer pinned, the result is only valid
         	 until the lock is released, so there's no point doing it inside the
    (12) is_single_threaded().
         This function has been extracted from selinux_setprocattr() and put into
         a file of its own in the lib/ directory as join_session_keyring() now
         wants to use it too.
         The code in SELinux just checked to see whether a task shared mm_structs
         with other tasks (CLONE_VM), but that isn't good enough.  We really want
         to know if they're part of the same thread group (CLONE_THREAD).
    (13) nfsd.
         The NFS server daemon now has to use the COW credentials to set the
         credentials it is going to use.  It really needs to pass the credentials
         down to the functions it calls, but it can't do that until other patches
         in this series have been applied.
    Signed-off-by: David Howells <>
    Acked-by: James Morris <>
    Signed-off-by: James Morris <>
  2. CRED: Separate task security context from task_struct

    David Howells committed with James Morris
    Separate the task security context from task_struct.  At this point, the
    security data is temporarily embedded in the task_struct with two pointers
    pointing to it.
    Note that the Alpha arch is altered as it refers to (E)UID and (E)GID in
    entry.S via asm-offsets.
    With comment fixes Signed-off-by: Marc Dionne <>
    Signed-off-by: David Howells <>
    Acked-by: James Morris <>
    Acked-by: Serge Hallyn <>
    Signed-off-by: James Morris <>
Commits on Aug 19, 2008
  1. sched: rt-bandwidth for user grouping interface

    Peter Zijlstra committed with Ingo Molnar
    rt_runtime is a signed value
    Signed-off-by: Peter Zijlstra <>
    Signed-off-by: Ingo Molnar <>
Commits on Apr 30, 2008
  1. alloc_uid: cleanup

    Andrew Morton committed with
    Use kmem_cache_zalloc(), remove large amounts of initialisation code and
    Note: this assumes that memset(*atomic_t, 0) correctly initialises the
    atomic_t.  This is true for all present archtiectures and if it becomes false
    for a future architecture then we'll need to make large changes all over the
    place anyway.
    Acked-by: David Howells <>
    Signed-off-by: Andrew Morton <>
    Signed-off-by: Linus Torvalds <>
Commits on Apr 29, 2008
  1. keys: don't generate user and user session keyrings unless they're ac…

    David Howells committed with
    Don't generate the per-UID user and user session keyrings unless they're
    explicitly accessed.  This solves a problem during a login process whereby
    set*uid() is called before the SELinux PAM module, resulting in the per-UID
    keyrings having the wrong security labels.
    This also cures the problem of multiple per-UID keyrings sometimes appearing
    due to PAM modules (including pam_keyinit) setuiding and causing user_structs
    to come into and go out of existence whilst the session keyring pins the user
    keyring.  This is achieved by first searching for extant per-UID keyrings
    before inventing new ones.
    The serial bound argument is also dropped from find_keyring_by_name() as it's
    not currently made use of (setting it to 0 disables the feature).
    Signed-off-by: David Howells <>
    Cc: <>
    Cc: <>
    Cc: <>
    Cc: Stephen Smalley <>
    Cc: James Morris <>
    Cc: Chris Wright <>
    Signed-off-by: Andrew Morton <>
    Signed-off-by: Linus Torvalds <>
Commits on Apr 19, 2008
  1. sched: fix the task_group hierarchy for UID grouping

    Peter Zijlstra committed with Ingo Molnar
    UID grouping doesn't actually have a task_group representing the root of
    the task_group tree. Add one.
    Signed-off-by: Peter Zijlstra <>
    Signed-off-by: Ingo Molnar <>
  2. sched: allow the group scheduler to have multiple levels

    Dhaval Giani committed with Ingo Molnar
    This patch makes the group scheduler multi hierarchy aware.
    [ rt-parts and assorted fixes]
    Signed-off-by: Dhaval Giani <>
    Signed-off-by: Peter Zijlstra <>
    Signed-off-by: Ingo Molnar <>
  3. sched: rt-group: synchonised bandwidth period

    Peter Zijlstra committed with Ingo Molnar
    Various SMP balancing algorithms require that the bandwidth period
    run in sync.
    Possible improvements are moving the rt_bandwidth thing into root_domain
    and keeping a span per rt_bandwidth which marks throttled cpus.
    Signed-off-by: Peter Zijlstra <>
    Signed-off-by: Ingo Molnar <>
Something went wrong with that request. Please try again.