1. 02 Aug, 2010 20 commits
    • Aneesh Kumar K.V's avatar
      fs/9p: destroy fid on failed remove · 0b1208b1
      Aneesh Kumar K.V authored
      9P spec says:
      "It is correct to consider remove to be a clunk with the
      side effect of removing the file if permissions allow. "
      
      So even if remove fails we need to destroy the fid.
      
      Without this patch an rmdir on a directory with contents leave
      the new cloned directory fid fid attached to fidlist. On umount
      we dump the fids on the fidlist
      
      ~# rmdir /mnt2/test4/
      rmdir: failed to remove `/mnt2/test4/': Directory not empty
      ~# umount /mnt2/
      ~# dmesg
      [  228.474323] Found fid 3 not clunked
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: default avatarVenkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      0b1208b1
    • Aneesh Kumar K.V's avatar
      fs/9p: Prevent parallel rename when doing fid_lookup · a534c8d1
      Aneesh Kumar K.V authored
      During fid lookup we need to make sure that the dentry->d_parent doesn't
      change so that we can safely walk the parent dentries. To ensure that
      we need to prevent cross directory rename during fid_lookup. Add a
      per superblock rename_sem rw_semaphore to prevent parallel fid lookup and
      rename.
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: default avatarVenkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      a534c8d1
    • Aneesh Kumar K.V's avatar
    • Aneesh Kumar K.V's avatar
      net/9p: Implement TXATTRCREATE 9p call · eda25e46
      Aneesh Kumar K.V authored
      TXATTRCREATE:  Prepare a fid for setting xattr value on a file system object.
      
       size[4] TXATTRCREATE tag[2] fid[4] name[s] attr_size[8] flags[4]
       size[4] RXATTRCREATE tag[2]
      
      txattrcreate gets a fid pointing to xattr. This fid can later be
      used to set the xattr value.
      
      flag value is derived from set Linux setxattr. The manpage says
      "The flags parameter can be used to refine the semantics of the operation.
      XATTR_CREATE specifies a pure create, which fails if the named attribute
      exists already. XATTR_REPLACE specifies a pure replace operation, which
      fails if the named attribute does not already exist. By default (no flags),
      the extended attribute will be created if need be, or will simply replace
      the value if the attribute exists."
      
      The actual setxattr operation happens when the fid is clunked. At that point
      the written byte count and the attr_size specified in TXATTRCREATE should be
      same otherwise an error will be returned.
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: default avatarVenkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      eda25e46
    • Aneesh Kumar K.V's avatar
      net/9p: Implement attrwalk 9p call · 0ef63f34
      Aneesh Kumar K.V authored
      TXATTRWALK: Descend a ATTR namespace
      
       size[4] TXATTRWALK tag[2] fid[4] newfid[4] name[s]
       size[4] RXATTRWALK tag[2] size[8]
      
      txattrwalk gets a fid pointing to xattr. This fid can later be
      used to read the xattr value. If name is NULL the fid returned
      can be used to get the list of extended attribute associated to
      the file system object.
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: default avatarVenkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      0ef63f34
    • M. Mohan Kumar's avatar
      9p: Implement LOPEN · ef56547e
      M. Mohan Kumar authored
      Implement 9p2000.L version of open(LOPEN) interface in 9p client.
      
      For LOPEN, no need to convert the flags to and from 9p mode to VFS mode.
      
      Synopsis:
      
          size[4] Tlopen tag[2] fid[4] mode[4]
      
          size[4] Rlopen tag[2] qid[13] iounit[4]
      
      [Fix mode bit format - jvrao@linux.vnet.ibm.com]
      Signed-off-by: default avatarM. Mohan Kumar <mohan@in.ibm.com>
      Signed-off-by: default avatarVenkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbegren <ericvh@gmail.com>
      ef56547e
    • Venkateswararao Jujjuri (JV)'s avatar
      fs/9p: This patch implements TLCREATE for 9p2000.L protocol. · 5643135a
      Venkateswararao Jujjuri (JV) authored
      SYNOPSIS
      
          size[4] Tlcreate tag[2] fid[4] name[s] flags[4] mode[4] gid[4]
      
          size[4] Rlcreate tag[2] qid[13] iounit[4]
      
      DESCRIPTION
      
      The Tlreate request asks the file server to create a new regular file with the
      name supplied, in the directory (dir) represented by fid.
      The mode argument specifies the permissions to use. New file is created with
      the uid if the fid and with supplied gid.
      
      The flags argument represent Linux access mode flags with which the caller
      is requesting to open the file with. Protocol allows all the Linux access
      modes but it is upto the server to allow/disallow any of these acess modes.
      If the server doesn't support any of the access mode, it is expected to
      return error.
      Signed-off-by: default avatarVenkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      5643135a
    • M. Mohan Kumar's avatar
      9p: Implement TMKDIR · 01a622bd
      M. Mohan Kumar authored
      Implement TMKDIR as part of 2000.L Work
      
      Synopsis
      
          size[4] Tmkdir tag[2] fid[4] name[s] mode[4] gid[4]
      
          size[4] Rmkdir tag[2] qid[13]
      
      Description
      
          mkdir asks the file server to create a directory with given name,
          mode and gid. The qid for the new directory is returned with
          the mkdir reply message.
      
      Note: 72 is selected as the opcode for TMKDIR from the reserved list.
      Signed-off-by: default avatarM. Mohan Kumar <mohan@in.ibm.com>
      Signed-off-by: default avatarVenkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      01a622bd
    • M. Mohan Kumar's avatar
      9p: Implement TMKNOD · 4b43516a
      M. Mohan Kumar authored
      Synopsis
      
          size[4] Tmknod tag[2] fid[4] name[s] mode[4] major[4] minor[4] gid[4]
      
          size[4] Rmknod tag[2] qid[13]
      
      Description
      
          mknod asks the file server to create a device node with given major and
          minor number, mode and gid. The qid for the new device node is returned
          with the mknod reply message.
      
      [sripathik@in.ibm.com: Fix error handling code]
      Signed-off-by: default avatarM. Mohan Kumar <mohan@in.ibm.com>
      Signed-off-by: default avatarVenkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      4b43516a
    • Venkateswararao Jujjuri (JV)'s avatar
      9p: Define and implement TSYMLINK for 9P2000.L · 50cc42ff
      Venkateswararao Jujjuri (JV) authored
      Create a symbolic link
      
      SYNOPSIS
      
      size[4] Tsymlink tag[2] fid[4] name[s] symtgt[s] gid[4]
      
      size[4] Rsymlink tag[2] qid[13]
      
      DESCRIPTION
      
      Create a symbolic link named 'name' pointing to 'symtgt'.
      gid represents the effective group id of the caller.
      The  permissions of a symbolic link are irrelevant hence it is omitted
      from the protocol.
      Signed-off-by: default avatarVenkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
      Reviewed-by: default avatarSripathi Kodi <sripathik@in.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      50cc42ff
    • Venkateswararao Jujjuri (JV)'s avatar
      9p: Define and implement TLINK for 9P2000.L · 652df9a7
      Venkateswararao Jujjuri (JV) authored
      This patch adds a helper function to get the dentry from inode and
      uses it in creating a Hardlink
      
      SYNOPSIS
      
      size[4] Tlink tag[2] dfid[4] oldfid[4] newpath[s]
      
      size[4] Rlink tag[2]
      
      DESCRIPTION
      
      Create a link 'newpath' in directory pointed by dfid linking to oldfid path.
      
      [sripathik@in.ibm.com : p9_client_link should not free req structure
      if p9_client_rpc has returned an error.]
      Signed-off-by: default avatarVenkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      652df9a7
    • Eric Van Hensbergen's avatar
      9p: Define and implement TLINK for 9P2000.L · 09d34ee5
      Eric Van Hensbergen authored
      This patch adds a helper function to get the dentry from inode and
      uses it in creating a Hardlink
      
      SYNOPSIS
      
      size[4] Tlink tag[2] dfid[4] oldfid[4] newpath[s]
      
      size[4] Rlink tag[2]
      
      DESCRIPTION
      
      Create a link 'newpath' in directory pointed by dfid linking to oldfid path.
      
      [sripathik@in.ibm.com : p9_client_link should not free req structure
      if p9_client_rpc has returned an error.]
      Signed-off-by: default avatarVenkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      09d34ee5
    • Sripathi Kodi's avatar
      9p: Implement client side of setattr for 9P2000.L protocol. · 87d7845a
      Sripathi Kodi authored
          SYNOPSIS
      
            size[4] Tsetattr tag[2] attr[n]
      
            size[4] Rsetattr tag[2]
      
          DESCRIPTION
      
            The setattr command changes some of the file status information.
            attr resembles the iattr structure used in Linux kernel. It
            specifies which status parameter is to be changed and to what
            value. It is laid out as follows:
      
               valid[4]
                  specifies which status information is to be changed. Possible
                  values are:
                  ATTR_MODE       (1 << 0)
                  ATTR_UID        (1 << 1)
                  ATTR_GID        (1 << 2)
                  ATTR_SIZE       (1 << 3)
                  ATTR_ATIME      (1 << 4)
                  ATTR_MTIME      (1 << 5)
                  ATTR_ATIME_SET  (1 << 7)
                  ATTR_MTIME_SET  (1 << 8)
      
                  The last two bits represent whether the time information
                  is being sent by the client's user space. In the absense
                  of these bits the server always uses server's time.
      
               mode[4]
                  File permission bits
      
               uid[4]
                  Owner id of file
      
               gid[4]
                  Group id of the file
      
               size[8]
                  File size
      
               atime_sec[8]
                  Time of last file access, seconds
      
               atime_nsec[8]
                  Time of last file access, nanoseconds
      
               mtime_sec[8]
                  Time of last file modification, seconds
      
               mtime_nsec[8]
                  Time of last file modification, nanoseconds
      
      Explanation of the patches:
      --------------------------
      
      *) The kernel just copies relevent contents of iattr structure to
         p9_iattr_dotl structure and passes it down to the client. The
         only check it has is calling inode_change_ok()
      *) The p9_iattr_dotl structure does not have ctime and ia_file
         parameters because I don't think these are needed in our case.
         The client user space can request updating just ctime by calling
         chown(fd, -1, -1). This is handled on server side without a need
         for putting ctime on the wire.
      *) The server currently supports changing mode, time, ownership and
         size of the file.
      *) 9P RFC says "Either all the changes in wstat request happen, or
         none of them does: if the request succeeds, all changes were made;
         if it fails, none were."
         I have not done anything to implement this specifically because I
         don't see a reason.
      Signed-off-by: default avatarSripathi Kodi <sripathik@in.ibm.com>
      Signed-off-by: default avatarVenkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      87d7845a
    • Sripathi Kodi's avatar
      9p: getattr client implementation for 9P2000.L protocol. · f0853122
      Sripathi Kodi authored
              SYNOPSIS
      
                    size[4] Tgetattr tag[2] fid[4] request_mask[8]
      
                    size[4] Rgetattr tag[2] lstat[n]
      
                 DESCRIPTION
      
                    The getattr transaction inquires about the file identified by fid.
                    request_mask is a bit mask that specifies which fields of the
                    stat structure is the client interested in.
      
                    The reply will contain a machine-independent directory entry,
                    laid out as follows:
      
                       st_result_mask[8]
                          Bit mask that indicates which fields in the stat structure
                          have been populated by the server
      
                       qid.type[1]
                          the type of the file (directory, etc.), represented as a bit
                          vector corresponding to the high 8 bits of the file's mode
                          word.
      
                       qid.vers[4]
                          version number for given path
      
                       qid.path[8]
                          the file server's unique identification for the file
      
                       st_mode[4]
                          Permission and flags
      
                       st_uid[4]
                          User id of owner
      
                       st_gid[4]
                          Group ID of owner
      
                       st_nlink[8]
                          Number of hard links
      
                       st_rdev[8]
                          Device ID (if special file)
      
                       st_size[8]
                          Size, in bytes
      
                       st_blksize[8]
                          Block size for file system IO
      
                       st_blocks[8]
                          Number of file system blocks allocated
      
                       st_atime_sec[8]
                          Time of last access, seconds
      
                       st_atime_nsec[8]
                          Time of last access, nanoseconds
      
                       st_mtime_sec[8]
                          Time of last modification, seconds
      
                       st_mtime_nsec[8]
                          Time of last modification, nanoseconds
      
                       st_ctime_sec[8]
                          Time of last status change, seconds
      
                       st_ctime_nsec[8]
                          Time of last status change, nanoseconds
      
                       st_btime_sec[8]
                          Time of creation (birth) of file, seconds
      
                       st_btime_nsec[8]
                          Time of creation (birth) of file, nanoseconds
      
                       st_gen[8]
                          Inode generation
      
                       st_data_version[8]
                          Data version number
      
                    request_mask and result_mask bit masks contain the following bits
                       #define P9_STATS_MODE          0x00000001ULL
                       #define P9_STATS_NLINK         0x00000002ULL
                       #define P9_STATS_UID           0x00000004ULL
                       #define P9_STATS_GID           0x00000008ULL
                       #define P9_STATS_RDEV          0x00000010ULL
                       #define P9_STATS_ATIME         0x00000020ULL
                       #define P9_STATS_MTIME         0x00000040ULL
                       #define P9_STATS_CTIME         0x00000080ULL
                       #define P9_STATS_INO           0x00000100ULL
                       #define P9_STATS_SIZE          0x00000200ULL
                       #define P9_STATS_BLOCKS        0x00000400ULL
      
                       #define P9_STATS_BTIME         0x00000800ULL
                       #define P9_STATS_GEN           0x00001000ULL
                       #define P9_STATS_DATA_VERSION  0x00002000ULL
      
                       #define P9_STATS_BASIC         0x000007ffULL
                       #define P9_STATS_ALL           0x00003fffULL
      
              This patch implements the client side of getattr implementation for
              9P2000.L. It introduces a new structure p9_stat_dotl for getting
              Linux stat information along with QID. The data layout is similar to
              stat structure in Linux user space with the following major
              differences:
      
              inode (st_ino) is not part of data. Instead qid is.
      
              device (st_dev) is not part of data because this doesn't make sense
              on the client.
      
              All time variables are 64 bit wide on the wire. The kernel seems to use
              32 bit variables for these variables. However, some of the architectures
              have used 64 bit variables and glibc exposes 64 bit variables to user
              space on some architectures. Hence to be on the safer side we have made
              these 64 bit in the protocol. Refer to the comments in
              include/asm-generic/stat.h
      
              There are some additional fields: st_btime_sec, st_btime_nsec, st_gen,
              st_data_version apart from the bitmask, st_result_mask. The bit mask
              is filled by the server to indicate which stat fields have been
              populated by the server. Currently there is no clean way for the
              server to obtain these additional fields, so it sends back just the
              basic fields.
      Signed-off-by: default avatarSripathi Kodi <sripathik@in.ibm.com>
      Signed-off-by: default avatarEric Van Hensbegren <ericvh@gmail.com>
      f0853122
    • Aneesh Kumar K.V's avatar
      fs/9p: Pass the correct user credentials during attach · 9ffaf63e
      Aneesh Kumar K.V authored
      We need to make sure we pass the right uid value
      during attach. dotl is similar to dotu in this regard.
      Without this mapped security model on dotl doesn't work
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      9ffaf63e
    • Aneesh Kumar K.V's avatar
      net/9p: Handle the server returned error properly · 69d4b443
      Aneesh Kumar K.V authored
      We need to get the negative errno value in the kernel
      even for dotl.
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      69d4b443
    • Sripathi Kodi's avatar
      9p: readdir implementation for 9p2000.L · 7751bdb3
      Sripathi Kodi authored
      This patch implements the kernel part of readdir() implementation for 9p2000.L
      
          Change from V3: Instead of inode, server now sends qids for each dirent
      
          SYNOPSIS
      
          size[4] Treaddir tag[2] fid[4] offset[8] count[4]
          size[4] Rreaddir tag[2] count[4] data[count]
      
          DESCRIPTION
      
          The readdir request asks the server to read the directory specified by 'fid'
          at an offset specified by 'offset' and return as many dirent structures as
          possible that fit into count bytes. Each dirent structure is laid out as
          follows.
      
                  qid.type[1]
                    the type of the file (directory, etc.), represented as a bit
                    vector corresponding to the high 8 bits of the file's mode
                    word.
      
                  qid.vers[4]
                    version number for given path
      
                  qid.path[8]
                    the file server's unique identification for the file
      
                  offset[8]
                    offset into the next dirent.
      
                  type[1]
                    type of this directory entry.
      
                  name[256]
                    name of this directory entry.
      
          This patch adds v9fs_dir_readdir_dotl() as the readdir() call for 9p2000.L.
          This function sends P9_TREADDIR command to the server. In response the server
          sends a buffer filled with dirent structures. This is different from the
          existing v9fs_dir_readdir() call which receives stat structures from the server.
          This results in significant speedup of readdir() on large directories.
          For example, doing 'ls >/dev/null' on a directory with 10000 files on my
          laptop takes 1.088 seconds with the existing code, but only takes 0.339 seconds
          with the new readdir.
      Signed-off-by: default avatarSripathi Kodi <sripathik@in.ibm.com>
      Reviewed-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      7751bdb3
    • M. Mohan Kumar's avatar
      9p: Make use of iounit for read/write · 97e8442b
      M. Mohan Kumar authored
      Change the v9fs_file_readn function to limit the maximum transfer size
      based on the iounit or msize.
      
      Also remove the redundant check for limiting the transfer size in
      v9fs_file_write. This check is done by p9_client_write.
      Signed-off-by: default avatarM. Mohan Kumar <mohan@in.ibm.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      97e8442b
    • Dan Carpenter's avatar
      9p: strlen() doesn't count the terminator · cff6b8a9
      Dan Carpenter authored
      This is an off by one bug because strlen() doesn't count the NULL
      terminator.  We strcpy() addr into a fixed length array of size
      UNIX_PATH_MAX later on.
      
      The addr variable is the name of the device being mounted.
      Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      cff6b8a9
    • Fang Wenqi's avatar
      virtio_9p.h needs <linux/types.h> · b126468e
      Fang Wenqi authored
      Found with makes headers_check:
      include/linux/virtio_9p.h:15: found __[us]{8,16,32,64} type without #include <linux/types.h>
      Signed-off-by: default avatarFang Wenqi <antonf@turbolinux.com.cn>
      Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
      b126468e
  2. 01 Aug, 2010 2 commits
  3. 31 Jul, 2010 5 commits
  4. 30 Jul, 2010 8 commits
  5. 29 Jul, 2010 5 commits
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git390.marist.edu/pub/scm/linux-2.6 · a2dccdb2
      Linus Torvalds authored
      * 'for-linus' of git://git390.marist.edu/pub/scm/linux-2.6:
        [S390] etr: fix clock synchronization race
        [S390] Fix IRQ tracing in case of PER
      a2dccdb2
    • Linus Torvalds's avatar
    • Linus Torvalds's avatar
      Merge branch 'fix/hda' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6 · e271e872
      Linus Torvalds authored
      * 'fix/hda' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6:
        ALSA: hda - Add a PC-beep workaround for ASUS P5-V
        ALSA: hda - Assume PC-beep as default for Realtek
        ALSA: hda - Don't register beep input device when no beep is available
        ALSA: hda - Fix pin-detection of Nvidia HDMI
      e271e872
    • David Howells's avatar
      CRED: Fix __task_cred()'s lockdep check and banner comment · 8f92054e
      David Howells authored
      Fix __task_cred()'s lockdep check by removing the following validation
      condition:
      
      	lockdep_tasklist_lock_is_held()
      
      as commit_creds() does not take the tasklist_lock, and nor do most of the
      functions that call it, so this check is pointless and it can prevent
      detection of the RCU lock not being held if the tasklist_lock is held.
      
      Instead, add the following validation condition:
      
      	task->exit_state >= 0
      
      to permit the access if the target task is dead and therefore unable to change
      its own credentials.
      
      Fix __task_cred()'s comment to:
      
       (1) discard the bit that says that the caller must prevent the target task
           from being deleted.  That shouldn't need saying.
      
       (2) Add a comment indicating the result of __task_cred() should not be passed
           directly to get_cred(), but rather than get_task_cred() should be used
           instead.
      
      Also put a note into the documentation to enforce this point there too.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8f92054e
    • David Howells's avatar
      CRED: Fix get_task_cred() and task_state() to not resurrect dead credentials · de09a977
      David Howells authored
      It's possible for get_task_cred() as it currently stands to 'corrupt' a set of
      credentials by incrementing their usage count after their replacement by the
      task being accessed.
      
      What happens is that get_task_cred() can race with commit_creds():
      
      	TASK_1			TASK_2			RCU_CLEANER
      	-->get_task_cred(TASK_2)
      	rcu_read_lock()
      	__cred = __task_cred(TASK_2)
      				-->commit_creds()
      				old_cred = TASK_2->real_cred
      				TASK_2->real_cred = ...
      				put_cred(old_cred)
      				  call_rcu(old_cred)
      		[__cred->usage == 0]
      	get_cred(__cred)
      		[__cred->usage == 1]
      	rcu_read_unlock()
      							-->put_cred_rcu()
      							[__cred->usage == 1]
      							panic()
      
      However, since a tasks credentials are generally not changed very often, we can
      reasonably make use of a loop involving reading the creds pointer and using
      atomic_inc_not_zero() to attempt to increment it if it hasn't already hit zero.
      
      If successful, we can safely return the credentials in the knowledge that, even
      if the task we're accessing has released them, they haven't gone to the RCU
      cleanup code.
      
      We then change task_state() in procfs to use get_task_cred() rather than
      calling get_cred() on the result of __task_cred(), as that suffers from the
      same problem.
      
      Without this change, a BUG_ON in __put_cred() or in put_cred_rcu() can be
      tripped when it is noticed that the usage count is not zero as it ought to be,
      for example:
      
      kernel BUG at kernel/cred.c:168!
      invalid opcode: 0000 [#1] SMP
      last sysfs file: /sys/kernel/mm/ksm/run
      CPU 0
      Pid: 2436, comm: master Not tainted 2.6.33.3-85.fc13.x86_64 #1 0HR330/OptiPlex
      745
      RIP: 0010:[<ffffffff81069881>]  [<ffffffff81069881>] __put_cred+0xc/0x45
      RSP: 0018:ffff88019e7e9eb8  EFLAGS: 00010202
      RAX: 0000000000000001 RBX: ffff880161514480 RCX: 00000000ffffffff
      RDX: 00000000ffffffff RSI: ffff880140c690c0 RDI: ffff880140c690c0
      RBP: ffff88019e7e9eb8 R08: 00000000000000d0 R09: 0000000000000000
      R10: 0000000000000001 R11: 0000000000000040 R12: ffff880140c690c0
      R13: ffff88019e77aea0 R14: 00007fff336b0a5c R15: 0000000000000001
      FS:  00007f12f50d97c0(0000) GS:ffff880007400000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f8f461bc000 CR3: 00000001b26ce000 CR4: 00000000000006f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      Process master (pid: 2436, threadinfo ffff88019e7e8000, task ffff88019e77aea0)
      Stack:
       ffff88019e7e9ec8 ffffffff810698cd ffff88019e7e9ef8 ffffffff81069b45
      <0> ffff880161514180 ffff880161514480 ffff880161514180 0000000000000000
      <0> ffff88019e7e9f28 ffffffff8106aace 0000000000000001 0000000000000246
      Call Trace:
       [<ffffffff810698cd>] put_cred+0x13/0x15
       [<ffffffff81069b45>] commit_creds+0x16b/0x175
       [<ffffffff8106aace>] set_current_groups+0x47/0x4e
       [<ffffffff8106ac89>] sys_setgroups+0xf6/0x105
       [<ffffffff81009b02>] system_call_fastpath+0x16/0x1b
      Code: 48 8d 71 ff e8 7e 4e 15 00 85 c0 78 0b 8b 75 ec 48 89 df e8 ef 4a 15 00
      48 83 c4 18 5b c9 c3 55 8b 07 8b 07 48 89 e5 85 c0 74 04 <0f> 0b eb fe 65 48 8b
      04 25 00 cc 00 00 48 3b b8 58 04 00 00 75
      RIP  [<ffffffff81069881>] __put_cred+0xc/0x45
       RSP <ffff88019e7e9eb8>
      ---[ end trace df391256a100ebdd ]---
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      de09a977