1. 17 Feb, 2022 1 commit
    • Eric W. Biederman's avatar
      ucounts: Base set_cred_ucounts changes on the real user · a55d0729
      Eric W. Biederman authored
      Michal Koutný <mkoutny@suse.com> wrote:
      > Tasks are associated to multiple users at once. Historically and as per
      > setrlimit(2) RLIMIT_NPROC is enforce based on real user ID.
      >
      > The commit 21d1c5e3 ("Reimplement RLIMIT_NPROC on top of ucounts")
      > made the accounting structure "indexed" by euid and hence potentially
      > account tasks differently.
      >
      > The effective user ID may be different e.g. for setuid programs but
      > those are exec'd into already existing task (i.e. below limit), so
      > different accounting is moot.
      >
      > Some special setresuid(2) users may notice the difference, justifying
      > this fix.
      
      I looked at cred->ucount and it is only used for rlimit operations
      that were previously stored in cred->user.  Making the fact
      cred->ucount can refer to a different user from cred->user a bug,
      affecting all uses of cred->ulimit not just RLIMIT_NPROC.
      
      Fix set_cred_ucounts to always use the real uid not the effective uid.
      
      Further simplify set_cred_ucounts by noticing that set_cred_ucounts
      somehow retained a draft version of the check to see if alloc_ucounts
      was needed that checks the new->user and new->user_ns against the
      current_real_cred().  Remove that draft version of the check.
      
      All that matters for setting the cred->ucounts are the user_ns and uid
      fields in the cred.
      
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20220207121800.5079-4-mkoutny@suse.com
      Link: https://lkml.kernel.org/r/20220216155832.680775-3-ebiederm@xmission.com
      
      Reported-by: default avatarMichal Koutný <mkoutny@suse.com>
      Reviewed-by: default avatarMichal Koutný <mkoutny@suse.com>
      Fixes: 21d1c5e3
      
       ("Reimplement RLIMIT_NPROC on top of ucounts")
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      a55d0729
  2. 20 Oct, 2021 2 commits
    • Eric W. Biederman's avatar
      ucounts: In set_cred_ucounts assume new->ucounts is non-NULL · 99c31f9f
      Eric W. Biederman authored
      Any cred that is destined for use by commit_creds must have a non-NULL
      cred->ucounts field.  Only curing credential construction is a NULL
      cred->ucounts valid.  Only abort_creds, put_cred, and put_cred_rcu
      needs to deal with a cred with a NULL ucount.  As set_cred_ucounts is
      non of those case don't confuse people by handling something that can
      not happen.
      
      Link: https://lkml.kernel.org/r/871r4irzds.fsf_-_@disp2133
      
      Tested-by: default avatarYu Zhao <yuzhao@google.com>
      Reviewed-by: default avatarAlexey Gladkov <legion@kernel.org>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      99c31f9f
    • Eric W. Biederman's avatar
      ucounts: Move get_ucounts from cred_alloc_blank to key_change_session_keyring · 5ebcbe34
      Eric W. Biederman authored
      Setting cred->ucounts in cred_alloc_blank does not make sense.  The
      uid and user_ns are deliberately not set in cred_alloc_blank but
      instead the setting is delayed until key_change_session_keyring.
      
      So move dealing with ucounts into key_change_session_keyring as well.
      
      Unfortunately that movement of get_ucounts adds a new failure mode to
      key_change_session_keyring.  I do not see anything stopping the parent
      process from calling setuid and changing the relevant part of it's
      cred while keyctl_session_to_parent is running making it fundamentally
      necessary to call get_ucounts in key_change_session_keyring.  Which
      means that the new failure mode cannot be avoided.
      
      A failure of key_change_session_keyring results in a single threaded
      parent keeping it's existing credentials.  Which results in the parent
      process not being able to access the session keyring and whichever
      keys are in the new keyring.
      
      Further get_ucounts is only expected to fail if the number of bits in
      the refernece count for the structure is too few.
      
      Since the code has no other way to report the failure of get_ucounts
      and because such failures are not expected to be common add a WARN_ONCE
      to report this problem to userspace.
      
      Between the WARN_ONCE and the parent process not having access to
      the keys in the new session keyring I expect any failure of get_ucounts
      will be noticed and reported and we can find another way to handle this
      condition.  (Possibly by just making ucounts->count an atomic_long_t).
      
      Cc: stable@vger.kernel.org
      Fixes: 905ae01c ("Add a reference to ucounts for each cred")
      Link: https://lkml.kernel.org/r/7k0ias0uf.fsf_-_@disp2133
      
      Tested-by: default avatarYu Zhao <yuzhao@google.com>
      Reviewed-by: default avatarAlexey Gladkov <legion@kernel.org>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      5ebcbe34
  3. 19 Oct, 2021 2 commits
  4. 23 Aug, 2021 1 commit
    • Alexey Gladkov's avatar
      ucounts: Increase ucounts reference counter before the security hook · bbb6d0f3
      Alexey Gladkov authored
      We need to increment the ucounts reference counter befor security_prepare_creds()
      because this function may fail and abort_creds() will try to decrement
      this reference.
      
      [   96.465056][ T8641] FAULT_INJECTION: forcing a failure.
      [   96.465056][ T8641] name fail_page_alloc, interval 1, probability 0, space 0, times 0
      [   96.478453][ T8641] CPU: 1 PID: 8641 Comm: syz-executor668 Not tainted 5.14.0-rc6-syzkaller #0
      [   96.487215][ T8641] Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      [   96.497254][ T8641] Call Trace:
      [   96.500517][ T8641]  dump_stack_lvl+0x1d3/0x29f
      [   96.505758][ T8641]  ? show_regs_print_info+0x12/0x12
      [   96.510944][ T8641]  ? log_buf_vmcoreinfo_setup+0x498/0x498
      [   96.516652][ T8641]  should_fail+0x384/0x4b0
      [   96.521141][ T8641]  prepare_alloc_pages+0x1d1/0x5a0
      [   96.526236][ T8641]  __alloc_pages+0x14d/0x5f0
      [   96.530808][ T8641]  ? __rmqueue_pcplist+0x2030/0x2030
      [   96.536073][ T8641]  ? lockdep_hardirqs_on_prepare+0x3e2/0x750
      [   96.542056][ T8641]  ? alloc_pages+0x3f3/0x500
      [   96.546635][ T8641]  allocate_slab+0xf1/0x540
      [   96.551120][ T8641]  ___slab_alloc+0x1cf/0x350
      [   96.555689][ T8641]  ? kzalloc+0x1d/0x30
      [   96.559740][ T8641]  __kmalloc+0x2e7/0x390
      [   96.563980][ T8641]  ? kzalloc+0x1d/0x30
      [   96.568029][ T8641]  kzalloc+0x1d/0x30
      [   96.571903][ T8641]  security_prepare_creds+0x46/0x220
      [   96.577174][ T8641]  prepare_creds+0x411/0x640
      [   96.581747][ T8641]  __sys_setfsuid+0xe2/0x3a0
      [   96.586333][ T8641]  do_syscall_64+0x3d/0xb0
      [   96.590739][ T8641]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      [   96.596611][ T8641] RIP: 0033:0x445a69
      [   96.600483][ T8641] Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
      [   96.620152][ T8641] RSP: 002b:00007f1054173318 EFLAGS: 00000246 ORIG_RAX: 000000000000007a
      [   96.628543][ T8641] RAX: ffffffffffffffda RBX: 00000000004ca4c8 RCX: 0000000000445a69
      [   96.636600][ T8641] RDX: 0000000000000010 RSI: 00007f10541732f0 RDI: 0000000000000000
      [   96.644550][ T8641] RBP: 00000000004ca4c0 R08: 0000000000000001 R09: 0000000000000000
      [   96.652500][ T8641] R10: 0000000000000000 R11: 0000000000000246 R12: 00000000004ca4cc
      [   96.660631][ T8641] R13: 00007fffffe0b62f R14: 00007f1054173400 R15: 0000000000022000
      
      Fixes: 905ae01c
      
       ("Add a reference to ucounts for each cred")
      Reported-by: syzbot+01985d7909f9468f013c@syzkaller.appspotmail.com
      Signed-off-by: default avatarAlexey Gladkov <legion@kernel.org>
      Link: https://lkml.kernel.org/r/97433b1742c3331f02ad92de5a4f07d673c90613.1629735352.git.legion@kernel.org
      
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      bbb6d0f3
  5. 28 May, 2021 1 commit
  6. 07 May, 2021 1 commit
  7. 30 Apr, 2021 2 commits
    • Alexey Gladkov's avatar
      Reimplement RLIMIT_NPROC on top of ucounts · 21d1c5e3
      Alexey Gladkov authored
      
      The rlimit counter is tied to uid in the user_namespace. This allows
      rlimit values to be specified in userns even if they are already
      globally exceeded by the user. However, the value of the previous
      user_namespaces cannot be exceeded.
      
      To illustrate the impact of rlimits, let's say there is a program that
      does not fork. Some service-A wants to run this program as user X in
      multiple containers. Since the program never fork the service wants to
      set RLIMIT_NPROC=1.
      
      service-A
       \- program (uid=1000, container1, rlimit_nproc=1)
       \- program (uid=1000, container2, rlimit_nproc=1)
      
      The service-A sets RLIMIT_NPROC=1 and runs the program in container1.
      When the service-A tries to run a program with RLIMIT_NPROC=1 in
      container2 it fails since user X already has one running process.
      
      We cannot use existing inc_ucounts / dec_ucounts because they do not
      allow us to exceed the maximum for the counter. Some rlimits can be
      overlimited by root or if the user has the appropriate capability.
      
      Changelog
      
      v11:
      * Change inc_rlimit_ucounts() which now returns top value of ucounts.
      * Drop inc_rlimit_ucounts_and_test() because the return code of
        inc_rlimit_ucounts() can be checked.
      Signed-off-by: default avatarAlexey Gladkov <legion@kernel.org>
      Link: https://lkml.kernel.org/r/c5286a8aa16d2d698c222f7532f3d735c82bc6bc.1619094428.git.legion@kernel.org
      
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      21d1c5e3
    • Alexey Gladkov's avatar
      Add a reference to ucounts for each cred · 905ae01c
      Alexey Gladkov authored
      
      For RLIMIT_NPROC and some other rlimits the user_struct that holds the
      global limit is kept alive for the lifetime of a process by keeping it
      in struct cred. Adding a pointer to ucounts in the struct cred will
      allow to track RLIMIT_NPROC not only for user in the system, but for
      user in the user_namespace.
      
      Updating ucounts may require memory allocation which may fail. So, we
      cannot change cred.ucounts in the commit_creds() because this function
      cannot fail and it should always return 0. For this reason, we modify
      cred.ucounts before calling the commit_creds().
      
      Changelog
      
      v6:
      * Fix null-ptr-deref in is_ucounts_overlimit() detected by trinity. This
        error was caused by the fact that cred_alloc_blank() left the ucounts
        pointer empty.
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Signed-off-by: default avatarAlexey Gladkov <legion@kernel.org>
      Link: https://lkml.kernel.org/r/b37aaef28d8b9b0d757e07ba6dd27281bbe39259.1619094428.git.legion@kernel.org
      
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      905ae01c
  8. 20 May, 2020 1 commit
  9. 25 Mar, 2020 1 commit
  10. 14 Jan, 2020 1 commit
    • David Howells's avatar
      keys: Fix request_key() cache · 8379bb84
      David Howells authored
      When the key cached by request_key() and co.  is cleaned up on exit(),
      the code looks in the wrong task_struct, and so clears the wrong cache.
      This leads to anomalies in key refcounting when doing, say, a kernel
      build on an afs volume, that then trigger kasan to report a
      use-after-free when the key is viewed in /proc/keys.
      
      Fix this by making exit_creds() look in the passed-in task_struct rather
      than in current (the task_struct cleanup code is deferred by RCU and
      potentially run in another task).
      
      Fixes: 7743c48e
      
       ("keys: Cache result of request_key*() temporarily in task_struct")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8379bb84
  11. 04 Jan, 2020 1 commit
  12. 24 Jul, 2019 1 commit
    • Linus Torvalds's avatar
      access: avoid the RCU grace period for the temporary subjective credentials · d7852fbd
      Linus Torvalds authored
      
      It turns out that 'access()' (and 'faccessat()') can cause a lot of RCU
      work because it installs a temporary credential that gets allocated and
      freed for each system call.
      
      The allocation and freeing overhead is mostly benign, but because
      credentials can be accessed under the RCU read lock, the freeing
      involves a RCU grace period.
      
      Which is not a huge deal normally, but if you have a lot of access()
      calls, this causes a fair amount of seconday damage: instead of having a
      nice alloc/free patterns that hits in hot per-CPU slab caches, you have
      all those delayed free's, and on big machines with hundreds of cores,
      the RCU overhead can end up being enormous.
      
      But it turns out that all of this is entirely unnecessary.  Exactly
      because access() only installs the credential as the thread-local
      subjective credential, the temporary cred pointer doesn't actually need
      to be RCU free'd at all.  Once we're done using it, we can just free it
      synchronously and avoid all the RCU overhead.
      
      So add a 'non_rcu' flag to 'struct cred', which can be set by users that
      know they only use it in non-RCU context (there are other potential
      users for this).  We can make it a union with the rcu freeing list head
      that we need for the RCU case, so this doesn't need any extra storage.
      
      Note that this also makes 'get_current_cred()' clear the new non_rcu
      flag, in case we have filesystems that take a long-term reference to the
      cred and then expect the RCU delayed freeing afterwards.  It's not
      entirely clear that this is required, but it makes for clear semantics:
      the subjective cred remains non-RCU as long as you only access it
      synchronously using the thread-local accessors, but you _can_ use it as
      a generic cred if you want to.
      
      It is possible that we should just remove the whole RCU markings for
      ->cred entirely.  Only ->real_cred is really supposed to be accessed
      through RCU, and the long-term cred copies that nfs uses might want to
      explicitly re-enable RCU freeing if required, rather than have
      get_current_cred() do it implicitly.
      
      But this is a "minimal semantic changes" change for the immediate
      problem.
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarPaul E. McKenney <paulmck@linux.ibm.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Jan Glauber <jglauber@marvell.com>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Jayachandran Chandrasekharan Nair <jnair@marvell.com>
      Cc: Greg KH <greg@kroah.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Miklos Szeredi <miklos@szeredi.hu>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d7852fbd
  13. 19 Jun, 2019 1 commit
    • David Howells's avatar
      keys: Cache result of request_key*() temporarily in task_struct · 7743c48e
      David Howells authored
      
      If a filesystem uses keys to hold authentication tokens, then it needs a
      token for each VFS operation that might perform an authentication check -
      either by passing it to the server, or using to perform a check based on
      authentication data cached locally.
      
      For open files this isn't a problem, since the key should be cached in the
      file struct since it represents the subject performing operations on that
      file descriptor.
      
      During pathwalk, however, there isn't anywhere to cache the key, except
      perhaps in the nameidata struct - but that isn't exposed to the
      filesystems.  Further, a pathwalk can incur a lot of operations, calling
      one or more of the following, for instance:
      
      	->lookup()
      	->permission()
      	->d_revalidate()
      	->d_automount()
      	->get_acl()
      	->getxattr()
      
      on each dentry/inode it encounters - and each one may need to call
      request_key().  And then, at the end of pathwalk, it will call the actual
      operation:
      
      	->mkdir()
      	->mknod()
      	->getattr()
      	->open()
      	...
      
      which may need to go and get the token again.
      
      However, it is very likely that all of the operations on a single
      dentry/inode - and quite possibly a sequence of them - will all want to use
      the same authentication token, which suggests that caching it would be a
      good idea.
      
      To this end:
      
       (1) Make it so that a positive result of request_key() and co. that didn't
           require upcalling to userspace is cached temporarily in task_struct.
      
       (2) The cache is 1 deep, so a new result displaces the old one.
      
       (3) The key is released by exit and by notify-resume.
      
       (4) The cache is cleared in a newly forked process.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      7743c48e
  14. 11 Jun, 2019 1 commit
  15. 24 May, 2019 1 commit
  16. 22 May, 2019 1 commit
  17. 08 Jan, 2019 1 commit
  18. 19 Dec, 2018 3 commits
  19. 18 May, 2017 1 commit
  20. 02 Mar, 2017 1 commit
  21. 30 Jun, 2016 1 commit
  22. 15 Jan, 2016 1 commit
    • Vladimir Davydov's avatar
      kmemcg: account certain kmem allocations to memcg · 5d097056
      Vladimir Davydov authored
      
      Mark those kmem allocations that are known to be easily triggered from
      userspace as __GFP_ACCOUNT/SLAB_ACCOUNT, which makes them accounted to
      memcg.  For the list, see below:
      
       - threadinfo
       - task_struct
       - task_delay_info
       - pid
       - cred
       - mm_struct
       - vm_area_struct and vm_region (nommu)
       - anon_vma and anon_vma_chain
       - signal_struct
       - sighand_struct
       - fs_struct
       - files_struct
       - fdtable and fdtable->full_fds_bits
       - dentry and external_name
       - inode for all filesystems. This is the most tedious part, because
         most filesystems overwrite the alloc_inode method.
      
      The list is far from complete, so feel free to add more objects.
      Nevertheless, it should be close to "account everything" approach and
      keep most workloads within bounds.  Malevolent users will be able to
      breach the limit, but this was possible even with the former "account
      everything" approach (simply because it did not account everything in
      fact).
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: default avatarVladimir Davydov <vdavydov@virtuozzo.com>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Greg Thelen <gthelen@google.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5d097056
  23. 10 Sep, 2015 1 commit
    • Joe Perches's avatar
      kernel/cred.c: remove unnecessary kdebug atomic reads · 52aa8536
      Joe Perches authored
      Commit e0e81739
      
       ("CRED: Add some configurable debugging [try #6]")
      added the kdebug mechanism to this file back in 2009.
      
      The kdebug macro calls no_printk which always evaluates arguments.
      
      Most of the kdebug uses have an unnecessary call of
      	atomic_read(&cred->usage)
      
      Make the kdebug macro do nothing by defining it with
      	do { if (0) no_printk(...); } while (0)
      when not enabled.
      
      $ size kernel/cred.o* (defconfig x86-64)
         text	   data	    bss	    dec	    hex	filename
         2748	    336	      8	   3092	    c14	kernel/cred.o.new
         2788	    336	      8	   3132	    c3c	kernel/cred.o.old
      
      Miscellanea:
      o Neaten the #define kdebug macros while there
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: James Morris <jmorris@namei.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      52aa8536
  24. 15 Apr, 2015 1 commit
    • Iulia Manda's avatar
      kernel: conditionally support non-root users, groups and capabilities · 2813893f
      Iulia Manda authored
      
      There are a lot of embedded systems that run most or all of their
      functionality in init, running as root:root.  For these systems,
      supporting multiple users is not necessary.
      
      This patch adds a new symbol, CONFIG_MULTIUSER, that makes support for
      non-root users, non-root groups, and capabilities optional.  It is enabled
      under CONFIG_EXPERT menu.
      
      When this symbol is not defined, UID and GID are zero in any possible case
      and processes always have all capabilities.
      
      The following syscalls are compiled out: setuid, setregid, setgid,
      setreuid, setresuid, getresuid, setresgid, getresgid, setgroups,
      getgroups, setfsuid, setfsgid, capget, capset.
      
      Also, groups.c is compiled out completely.
      
      In kernel/capability.c, capable function was moved in order to avoid
      adding two ifdef blocks.
      
      This change saves about 25 KB on a defconfig build.  The most minimal
      kernels have total text sizes in the high hundreds of kB rather than
      low MB.  (The 25k goes down a bit with allnoconfig, but not that much.
      
      The kernel was booted in Qemu.  All the common functionalities work.
      Adding users/groups is not possible, failing with -ENOSYS.
      
      Bloat-o-meter output:
      add/remove: 7/87 grow/shrink: 19/397 up/down: 1675/-26325 (-24650)
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: default avatarIulia Manda <iulia.manda21@gmail.com>
      Reviewed-by: default avatarJosh Triplett <josh@joshtriplett.org>
      Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Tested-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Reviewed-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2813893f
  25. 15 Dec, 2012 1 commit
  26. 02 Oct, 2012 1 commit
    • David Howells's avatar
      KEYS: Make the session and process keyrings per-thread · 3a50597d
      David Howells authored
      Make the session keyring per-thread rather than per-process, but still
      inherited from the parent thread to solve a problem with PAM and gdm.
      
      The problem is that join_session_keyring() will reject attempts to change the
      session keyring of a multithreaded program but gdm is now multithreaded before
      it gets to the point of starting PAM and running pam_keyinit to create the
      session keyring.  See:
      
      	https://bugs.freedesktop.org/show_bug.cgi?id=49211
      
      
      
      The reason that join_session_keyring() will only change the session keyring
      under a single-threaded environment is that it's hard to alter the other
      thread's credentials to effect the change in a multi-threaded program.  The
      problems are such as:
      
       (1) How to prevent two threads both running join_session_keyring() from
           racing.
      
       (2) Another thread's credentials may not be modified directly by this process.
      
       (3) The number of threads is uncertain whilst we're not holding the
           appropriate spinlock, making preallocation slightly tricky.
      
       (4) We could use TIF_NOTIFY_RESUME and key_replace_session_keyring() to get
           another thread to replace its keyring, but that means preallocating for
           each thread.
      
      A reasonable way around this is to make the session keyring per-thread rather
      than per-process and just document that if you want a common session keyring,
      you must get it before you spawn any threads - which is the current situation
      anyway.
      
      Whilst we're at it, we can the process keyring behave in the same way.  This
      means we can clean up some of the ickyness in the creds code.
      
      Basically, after this patch, the session, process and thread keyrings are about
      inheritance rules only and not about sharing changes of keyring.
      Reported-by: default avatarMantas M. <grawity@gmail.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Tested-by: default avatarRay Strode <rstrode@redhat.com>
      3a50597d
  27. 24 Aug, 2012 1 commit
  28. 24 May, 2012 1 commit
  29. 03 May, 2012 1 commit
  30. 11 Apr, 2012 1 commit
  31. 07 Apr, 2012 1 commit
  32. 13 Feb, 2012 1 commit
  33. 31 Oct, 2011 1 commit
    • Paul Gortmaker's avatar
      kernel: Map most files to use export.h instead of module.h · 9984de1a
      Paul Gortmaker authored
      
      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: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      9984de1a
  34. 23 Aug, 2011 1 commit
  35. 22 Aug, 2011 1 commit
    • David Howells's avatar
      CRED: Fix prepare_kernel_cred() to provide a new thread_group_cred struct · 012146d0
      David Howells authored
      Fix prepare_kernel_cred() to provide a new, separate thread_group_cred struct
      otherwise when using request_key() ____call_usermodehelper() calls
      umh_keys_init() with the new creds pointing to init_tgcred, which
      umh_keys_init() then blithely alters.
      
      The problem can be demonstrated by:
      
      	# keyctl request2 user a debug:a @s
      	249681132
      	# grep req /proc/keys
      	079906a5 I--Q--     1 perm 1f3f0000     0     0 keyring   _req.249681132: 1/4
      	38ef1626 IR----     1 expd 0b010000     0     0 .request_ key:ee1d4ec pid:4371 ci:1
      
      The keyring _req.XXXX should have gone away, but something (init_tgcred) is
      pinning it.
      
      That key actually requested can then be removed and a new one created:
      
      	# keyctl unlink 249681132
      	1 links removed
      	[root@andromeda ~]# grep req /proc/keys
      	116cecac IR----     1 expd 0b010000     0     0 .request_ key:eeb4911 pid:4379 ci:1
      	36d1cbf8 I--Q--     1 perm 1f3f0000     0     0 keyring   _req.250300689: 1/4
      
      which causes the old _req keyring to go away and a new one to take its place.
      
      This is a consequence of the changes in:
      
      	commit 87966996
      	Author: David Howells <dhowells@redhat.com>
      	Date:   Fri Jun 17 11:25:59 2011 +0100
      	KEYS/DNS: Fix ____call_usermodehelper() to not lose the session keyring
      
      and:
      
      	commit 17f60a7d
      
      
      	Author: Eric Paris <eparis@redhat.com>
      	Date:   Fri Apr 1 17:07:50 2011 -0400
      	capabilites: allow the application of capability limits to usermode helpers
      
      After this patch is applied, the _req keyring and the .request_key key are
      cleaned up.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Eric Paris <eparis@redhat.com>
      Signed-off-by: default avatarJames Morris <jmorris@namei.org>
      012146d0