1. 29 4月, 2008 8 次提交
    • P
      IPC: consolidate all xxxctl_down() functions · a5f75e7f
      Pierre Peiffer 提交于
      semctl_down(), msgctl_down() and shmctl_down() are used to handle the same set
      of commands for each kind of IPC.  They all start to do the same job (they
      retrieve the ipc and do some permission checks) before handling the commands
      on their own.
      
      This patch proposes to consolidate this by moving these same pieces of code
      into one common function called ipcctl_pre_down().
      
      It simplifies a little these xxxctl_down() functions and increases a little
      the maintainability.
      Signed-off-by: NPierre Peiffer <pierre.peiffer@bull.net>
      Acked-by: NSerge Hallyn <serue@us.ibm.com>
      Cc: Nadia Derbey <Nadia.Derbey@bull.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a5f75e7f
    • P
      IPC: introduce ipc_update_perm() · 8f4a3809
      Pierre Peiffer 提交于
      The IPC_SET command performs the same permission setting for all IPCs.  This
      patch introduces a common ipc_update_perm() function to update these
      permissions and makes use of it for all IPCs.
      Signed-off-by: NPierre Peiffer <pierre.peiffer@bull.net>
      Acked-by: NSerge Hallyn <serue@us.ibm.com>
      Cc: Nadia Derbey <Nadia.Derbey@bull.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8f4a3809
    • P
      IPC: get rid of the use *_setbuf structure. · 016d7132
      Pierre Peiffer 提交于
      All IPCs make use of an intermetiate *_setbuf structure to handle the IPC_SET
      command.  This is not really needed and, moreover, it complicates a little bit
      the code.
      
      This patch gets rid of the use of it and uses directly the semid64_ds/
      msgid64_ds/shmid64_ds structure.
      
      In addition of removing one struture declaration, it also simplifies and
      improves a little bit the common 64-bits path.
      Signed-off-by: NPierre Peiffer <pierre.peiffer@bull.net>
      Acked-by: NSerge Hallyn <serue@us.ibm.com>
      Cc: Nadia Derbey <Nadia.Derbey@bull.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      016d7132
    • P
      IPC/message queues: introduce msgctl_down · a0d092fc
      Pierre Peiffer 提交于
      Currently, sys_msgctl is not easy to read.
      
      This patch tries to improve that by introducing the msgctl_down function to
      handle all commands requiring the rwmutex to be taken in write mode (ie
      IPC_SET and IPC_RMID for now).  It is the equivalent function of semctl_down
      for message queues.
      
      This greatly changes the readability of sys_msgctl and also harmonizes the way
      these commands are handled among all IPCs.
      Signed-off-by: NPierre Peiffer <pierre.peiffer@bull.net>
      Acked-by: NSerge Hallyn <serue@us.ibm.com>
      Cc: Nadia Derbey <Nadia.Derbey@bull.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a0d092fc
    • N
      ipc: recompute msgmni on memory add / remove · b6b337ad
      Nadia Derbey 提交于
      Introduce the registration of a callback routine that recomputes msg_ctlmni
      upon memory add / remove.
      
      A single notifier block is registered in the hotplug memory chain for all the
      ipc namespaces.
      
      Since the ipc namespaces are not linked together, they have their own
      notification chain: one notifier_block is defined per ipc namespace.
      
      Each time an ipc namespace is created (removed) it registers (unregisters) its
      notifier block in (from) the ipcns chain.  The callback routine registered in
      the memory chain invokes the ipcns notifier chain with the IPCNS_LOWMEM event.
       Each callback routine registered in the ipcns namespace, in turn, recomputes
      msgmni for the owning namespace.
      Signed-off-by: NNadia Derbey <Nadia.Derbey@bull.net>
      Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
      Cc: Matt Helsley <matthltc@us.ibm.com>
      Cc: Mingming Cao <cmm@us.ibm.com>
      Cc: Pierre Peiffer <pierre.peiffer@bull.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b6b337ad
    • N
      ipc: scale msgmni to the number of ipc namespaces · 4d89dc6a
      Nadia Derbey 提交于
      Since all the namespaces see the same amount of memory (the total one) this
      patch introduces a new variable that counts the ipc namespaces and divides
      msg_ctlmni by this counter.
      Signed-off-by: NNadia Derbey <Nadia.Derbey@bull.net>
      Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
      Cc: Matt Helsley <matthltc@us.ibm.com>
      Cc: Mingming Cao <cmm@us.ibm.com>
      Cc: Pierre Peiffer <pierre.peiffer@bull.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4d89dc6a
    • N
      ipc: scale msgmni to the amount of lowmem · f7bf3df8
      Nadia Derbey 提交于
      On large systems we'd like to allow a larger number of message queues.  In
      some cases up to 32K.  However simply setting MSGMNI to a larger value may
      cause problems for smaller systems.
      
      The first patch of this series introduces a default maximum number of message
      queue ids that scales with the amount of lowmem.
      
      Since msgmni is per namespace and there is no amount of memory dedicated to
      each namespace so far, the second patch of this series scales msgmni to the
      number of ipc namespaces too.
      
      Since msgmni depends on the amount of memory, it becomes necessary to
      recompute it upon memory add/remove.  In the 4th patch, memory hotplug
      management is added: a notifier block is registered into the memory hotplug
      notifier chain for the ipc subsystem.  Since the ipc namespaces are not linked
      together, they have their own notification chain: one notifier_block is
      defined per ipc namespace.  Each time an ipc namespace is created (removed) it
      registers (unregisters) its notifier block in (from) the ipcns chain.  The
      callback routine registered in the memory chain invokes the ipcns notifier
      chain with the IPCNS_MEMCHANGE event.  Each callback routine registered in the
      ipcns namespace, in turn, recomputes msgmni for the owning namespace.
      
      The 5th patch makes it possible to keep the memory hotplug notifier chain's
      lock for a lesser amount of time: instead of directly notifying the ipcns
      notifier chain upon memory add/remove, a work item is added to the global
      workqueue.  When activated, this work item is the one who notifies the ipcns
      notifier chain.
      
      Since msgmni depends on the number of ipc namespaces, it becomes necessary to
      recompute it upon ipc namespace creation / removal.  The 6th patch uses the
      ipc namespace notifier chain for that purpose: that chain is notified each
      time an ipc namespace is created or removed.  This makes it possible to
      recompute msgmni for all the namespaces each time one of them is created or
      removed.
      
      When msgmni is explicitely set from userspace, we should avoid recomputing it
      upon memory add/remove or ipcns creation/removal.  This is what the 7th patch
      does: it simply unregisters the ipcns callback routine as soon as msgmni has
      been changed from procfs or sysctl().
      
      Even if msgmni is set by hand, it should be possible to make it back
      automatically recomputed upon memory add/remove or ipcns creation/removal.
      This what is achieved in patch 8: if set to a negative value, msgmni is added
      back to the ipcns notifier chain, making it automatically recomputed again.
      
      This patch:
      
      Compute msg_ctlmni to make it scale with the amount of lowmem.  msg_ctlmni is
      now set to make the message queues occupy 1/32 of the available lowmem.
      
      Some cleaning has also been done for the MSGPOOL constant: the msgctl man page
      says it's not used, but it also defines it as a size in bytes (the code
      expresses it in Kbytes).
      Signed-off-by: NNadia Derbey <Nadia.Derbey@bull.net>
      Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
      Cc: Matt Helsley <matthltc@us.ibm.com>
      Cc: Mingming Cao <cmm@us.ibm.com>
      Cc: Pierre Peiffer <pierre.peiffer@bull.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f7bf3df8
    • P
      IPC: use ipc_buildid() directly from ipc_addid() · 48dea404
      Pierre Peiffer 提交于
      By continuing to consolidate a little the IPC code, each id can be built
      directly in ipc_addid() instead of having it built from each callers of
      ipc_addid()
      
      And I also remove shm_addid() in order to have, as much as possible, the
      same code for shm/sem/msg.
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: NPierre Peiffer <pierre.peiffer@bull.net>
      Cc: Nadia Derbey <Nadia.Derbey@bull.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      48dea404
  2. 09 2月, 2008 3 次提交
    • P
      IPC: consolidate sem_exit_ns(), msg_exit_ns() and shm_exit_ns() · 01b8b07a
      Pierre Peiffer 提交于
      sem_exit_ns(), msg_exit_ns() and shm_exit_ns() are all called when an
      ipc_namespace is released to free all ipcs of each type.  But in fact, they
      do the same thing: they loop around all ipcs to free them individually by
      calling a specific routine.
      
      This patch proposes to consolidate this by introducing a common function,
      free_ipcs(), that do the job.  The specific routine to call on each
      individual ipcs is passed as parameter.  For this, these ipc-specific
      'free' routines are reworked to take a generic 'struct ipc_perm' as
      parameter.
      Signed-off-by: NPierre Peiffer <pierre.peiffer@bull.net>
      Cc: Cedric Le Goater <clg@fr.ibm.com>
      Cc: Pavel Emelyanov <xemul@openvz.org>
      Cc: Nadia Derbey <Nadia.Derbey@bull.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      01b8b07a
    • P
      IPC: make struct ipc_ids static in ipc_namespace · ed2ddbf8
      Pierre Peiffer 提交于
      Each ipc_namespace contains a table of 3 pointers to struct ipc_ids (3 for
      msg, sem and shm, structure used to store all ipcs) These 'struct ipc_ids'
      are dynamically allocated for each icp_namespace as the ipc_namespace
      itself (for the init namespace, they are initialized with pointers to
      static variables instead)
      
      It is so for historical reason: in fact, before the use of idr to store the
      ipcs, the ipcs were stored in tables of variable length, depending of the
      maximum number of ipc allowed.  Now, these 'struct ipc_ids' have a fixed
      size.  As they are allocated in any cases for each new ipc_namespace, there
      is no gain of memory in having them allocated separately of the struct
      ipc_namespace.
      
      This patch proposes to make this table static in the struct ipc_namespace.
      Thus, we can allocate all in once and get rid of all the code needed to
      allocate and free these ipc_ids separately.
      Signed-off-by: NPierre Peiffer <pierre.peiffer@bull.net>
      Acked-by: NCedric Le Goater <clg@fr.ibm.com>
      Cc: Pavel Emelyanov <xemul@openvz.org>
      Cc: Nadia Derbey <Nadia.Derbey@bull.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ed2ddbf8
    • P
      namespaces: move the IPC namespace under IPC_NS option · ae5e1b22
      Pavel Emelyanov 提交于
      Currently the IPC namespace management code is spread over the ipc/*.c files.
      I moved this code into ipc/namespace.c file which is compiled out when needed.
      
      The linux/ipc_namespace.h file is used to store the prototypes of the
      functions in namespace.c and the stubs for NAMESPACES=n case.  This is done
      so, because the stub for copy_ipc_namespace requires the knowledge of the
      CLONE_NEWIPC flag, which is in sched.h.  But the linux/ipc.h file itself in
      included into many many .c files via the sys.h->sem.h sequence so adding the
      sched.h into it will make all these .c depend on sched.h which is not that
      good.  On the other hand the knowledge about the namespaces stuff is required
      in 4 .c files only.
      
      Besides, this patch compiles out some auxiliary functions from ipc/sem.c,
      msg.c and shm.c files.  It turned out that moving these functions into
      namespaces.c is not that easy because they use many other calls and macros
      from the original file.  Moving them would make this patch complicated.  On
      the other hand all these functions can be consolidated, so I will send a
      separate patch doing this a bit later.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Acked-by: NSerge Hallyn <serue@us.ibm.com>
      Cc: Cedric Le Goater <clg@fr.ibm.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Herbert Poetzl <herbert@13thfloor.at>
      Cc: Kirill Korotaev <dev@sw.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ae5e1b22
  3. 07 2月, 2008 1 次提交
    • P
      IPC: fix error check in all new xxx_lock() and xxx_exit_ns() functions · b1ed88b4
      Pierre Peiffer 提交于
      In the new implementation of the [sem|shm|msg]_lock[_check]() routines, we
      use the return value of ipc_lock() in container_of() without any check.
      But ipc_lock may return a errcode.  The use of this errcode in
      container_of() may alter this errcode, and we don't want this.
      
      And in xxx_exit_ns, the pointer return by idr_find is of type 'struct
      kern_ipc_per'...
      
      Today, the code will work as is because the member used in these
      container_of() is the first member of its container (offset == 0), the
      errcode isn't changed then.  But in the general case, we can't count on
      this assumption and this may lead later to a real bug if we don't correct
      this.
      
      Again, the proposed solution is simple and correct.  But, as pointed by
      Nadia, with this solution, the same check will be done several times (in
      all sub-callers...), what is not very funny/optimal...
      Signed-off-by: NPierre Peiffer <pierre.peiffer@bull.net>
      Cc: Nadia Derbey <Nadia.Derbey@bull.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b1ed88b4
  4. 20 10月, 2007 10 次提交
  5. 18 7月, 2007 1 次提交
  6. 17 7月, 2007 1 次提交
  7. 08 12月, 2006 1 次提交
    • S
      [PATCH] Fix the size limit of compat space msgsize · 651971cb
      suzuki 提交于
      Currently we allocate 64k space on the user stack and use it the msgbuf for
      sys_{msgrcv,msgsnd} for compat and the results are later copied in user [
      by copy_in_user].  This patch introduces helper routines for
      sys_{msgrcv,msgsnd} as below:
      
      do_msgsnd() : Accepts the mtype and user space ptr to the buffer along with
      the msqid and msgflg.
      
      do_msgrcv() : Accepts a kernel space ptr to mtype and a userspace ptr to
      the buffer.  The mtype has to be copied back the user space msgbuf by the
      caller.
      
      These changes avoid the need to allocate the msgsize on the userspace (
      thus removing the size limt ) and the overhead of an extra copy_in_user().
      Signed-off-by: NSuzuki K P <suzuki@in.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: "David S. Miller" <davem@davemloft.net>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      651971cb
  8. 05 11月, 2006 1 次提交
    • L
      Revert unintentional "volatile" changes in ipc/msg.c · 80491eb9
      Linus Torvalds 提交于
      Commit 5a06a363 ("[PATCH] ipc/msg.c:
      clean up coding style") breaks fakeroot on Alpha (variously hangs or
      oopses), according to a report by Falk Hueffner.
      
      The fact that the code seems to rely on compiler access ordering through
      the use of "volatile" is a pretty certain sign that the code has locking
      problems, and we should fix those properly and then remove the whole
      "volatile" entirely.
      
      But in the meantime, the movement of "volatile" was unintentional, and
      should be reverted.
      
      Cc: Falk Hueffner <falk@debian.org>
      Cc: Andrew Morton <akpm@osdl.org>
      Acked-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      80491eb9
  9. 04 11月, 2006 1 次提交
    • P
      [PATCH] Fix ipc entries removal · c7e12b83
      Pavel Emelianov 提交于
      Fix two issuses related to ipc_ids->entries freeing.
      
      1. When freeing ipc namespace we need to free entries allocated
         with ipc_init_ids().
      
      2. When removing old entries in grow_ary() ipc_rcu_putref()
         may be called on entries set to &ids->nullentry earlier in
         ipc_init_ids().
         This is almost impossible without namespaces, but with
         them this situation becomes possible.
      
      Found during OpenVZ testing after obvious leaks in beancounters.
      Signed-off-by: NPavel Emelianov <xemul@openvz.org>
      Cc: Kirill Korotaev <dev@openvz.org>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      c7e12b83
  10. 02 10月, 2006 1 次提交
  11. 01 8月, 2006 1 次提交
  12. 01 7月, 2006 1 次提交
  13. 20 6月, 2006 1 次提交
    • L
      [PATCH] update of IPC audit record cleanup · ac03221a
      Linda Knippers 提交于
      The following patch addresses most of the issues with the IPC_SET_PERM
      records as described in:
      https://www.redhat.com/archives/linux-audit/2006-May/msg00010.html
      and addresses the comments I received on the record field names.
      
      To summarize, I made the following changes:
      
      1. Changed sys_msgctl() and semctl_down() so that an IPC_SET_PERM
         record is emitted in the failure case as well as the success case.
         This matches the behavior in sys_shmctl().  I could simplify the
         code in sys_msgctl() and semctl_down() slightly but it would mean
         that in some error cases we could get an IPC_SET_PERM record
         without an IPC record and that seemed odd.
      
      2. No change to the IPC record type, given no feedback on the backward
         compatibility question.
      
      3. Removed the qbytes field from the IPC record.  It wasn't being
         set and when audit_ipc_obj() is called from ipcperms(), the
         information isn't available.  If we want the information in the IPC
         record, more extensive changes will be necessary.  Since it only
         applies to message queues and it isn't really permission related, it
         doesn't seem worth it.
      
      4. Removed the obj field from the IPC_SET_PERM record.  This means that
         the kern_ipc_perm argument is no longer needed.
      
      5. Removed the spaces and renamed the IPC_SET_PERM field names.  Replaced iuid and
         igid fields with ouid and ogid in the IPC record.
      
      I tested this with the lspp.22 kernel on an x86_64 box.  I believe it
      applies cleanly on the latest kernel.
      
      -- ljk
      Signed-off-by: NLinda Knippers <linda.knippers@hp.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      ac03221a
  14. 01 5月, 2006 1 次提交
    • S
      [PATCH] Rework of IPC auditing · 073115d6
      Steve Grubb 提交于
      1) The audit_ipc_perms() function has been split into two different
      functions:
              - audit_ipc_obj()
              - audit_ipc_set_perm()
      
      There's a key shift here...  The audit_ipc_obj() collects the uid, gid,
      mode, and SElinux context label of the current ipc object.  This
      audit_ipc_obj() hook is now found in several places.  Most notably, it
      is hooked in ipcperms(), which is called in various places around the
      ipc code permforming a MAC check.  Additionally there are several places
      where *checkid() is used to validate that an operation is being
      performed on a valid object while not necessarily having a nearby
      ipcperms() call.  In these locations, audit_ipc_obj() is called to
      ensure that the information is captured by the audit system.
      
      The audit_set_new_perm() function is called any time the permissions on
      the ipc object changes.  In this case, the NEW permissions are recorded
      (and note that an audit_ipc_obj() call exists just a few lines before
      each instance).
      
      2) Support for an AUDIT_IPC_SET_PERM audit message type.  This allows
      for separate auxiliary audit records for normal operations on an IPC
      object and permissions changes.  Note that the same struct
      audit_aux_data_ipcctl is used and populated, however there are separate
      audit_log_format statements based on the type of the message.  Finally,
      the AUDIT_IPC block of code in audit_free_aux() was extended to handle
      aux messages of this new type.  No more mem leaks I hope ;-)
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      073115d6
  15. 27 3月, 2006 1 次提交
  16. 25 3月, 2006 1 次提交
  17. 21 3月, 2006 1 次提交
    • D
      [PATCH] Capture selinux subject/object context information. · 8c8570fb
      Dustin Kirkland 提交于
      This patch extends existing audit records with subject/object context
      information. Audit records associated with filesystem inodes, ipc, and
      tasks now contain SELinux label information in the field "subj" if the
      item is performing the action, or in "obj" if the item is the receiver
      of an action.
      
      These labels are collected via hooks in SELinux and appended to the
      appropriate record in the audit code.
      
      This additional information is required for Common Criteria Labeled
      Security Protection Profile (LSPP).
      
      [AV: fixed kmalloc flags use]
      [folded leak fixes]
      [folded cleanup from akpm (kfree(NULL)]
      [folded audit_inode_context() leak fix]
      [folded akpm's fix for audit_ipc_perm() definition in case of !CONFIG_AUDIT]
      Signed-off-by: NDustin Kirkland <dustin.kirkland@us.ibm.com>
      Signed-off-by: NDavid Woodhouse <dwmw2@infradead.org>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      8c8570fb
  18. 15 1月, 2006 1 次提交
  19. 12 1月, 2006 1 次提交
  20. 08 9月, 2005 1 次提交
  21. 17 4月, 2005 1 次提交
    • L
      Linux-2.6.12-rc2 · 1da177e4
      Linus Torvalds 提交于
      Initial git repository build. I'm not bothering with the full history,
      even though we have it. We can create a separate "historical" git
      archive of that later if we want to, and in the meantime it's about
      3.2GB when imported into git - space that would just make the early
      git days unnecessarily complicated, when we don't have a lot of good
      infrastructure for it.
      
      Let it rip!
      1da177e4