1. 11 2月, 2011 1 次提交
    • J
      cifs: don't always drop malformed replies on the floor (try #3) · 71823baf
      Jeff Layton 提交于
      Slight revision to this patch...use min_t() instead of conditional
      assignment. Also, remove the FIXME comment and replace it with the
      explanation that Steve gave earlier.
      
      After receiving a packet, we currently check the header. If it's no
      good, then we toss it out and continue the loop, leaving the caller
      waiting on that response.
      
      In cases where the packet has length inconsistencies, but the MID is
      valid, this leads to unneeded delays. That's especially problematic now
      that the client waits indefinitely for responses.
      
      Instead, don't immediately discard the packet if checkSMB fails. Try to
      find a matching mid_q_entry, mark it as having a malformed response and
      issue the callback.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      71823baf
  2. 09 2月, 2011 1 次提交
  3. 24 1月, 2011 1 次提交
    • R
      Make CIFS mount work in a container. · f1d0c998
      Rob Landley 提交于
      Teach cifs about network namespaces, so mounting uses adresses/routing
      visible from the container rather than from init context.
      
      A container is a chroot on steroids that changes more than just the root
      filesystem the new processes see.  One thing containers can isolate is
      "network namespaces", meaning each container can have its own set of
      ethernet interfaces, each with its own own IP address and routing to the
      outside world.  And if you open a socket in _userspace_ from processes
      within such a container, this works fine.
      
      But sockets opened from within the kernel still use a single global
      networking context in a lot of places, meaning the new socket's address
      and routing are correct for PID 1 on the host, but are _not_ what
      userspace processes in the container get to use.
      
      So when you mount a network filesystem from within in a container, the
      mount code in the CIFS driver uses the host's networking context and not
      the container's networking context, so it gets the wrong address, uses
      the wrong routing, and may even try to go out an interface that the
      container can't even access...  Bad stuff.
      
      This patch copies the mount process's network context into the CIFS
      structure that stores the rest of the server information for that mount
      point, and changes the socket open code to use the saved network context
      instead of the global network context.  I.E. "when you attempt to use
      these addresses, do so relative to THIS set of network interfaces and
      routing rules, not the old global context from back before we supported
      containers".
      
      The big long HOWTO sets up a test environment on the assumption you've
      never used ocntainers before.  It basically says:
      
      1) configure and build a new kernel that has container support
      2) build a new root filesystem that includes the userspace container
      control package (LXC)
      3) package/run them under KVM (so you don't have to mess up your host
      system in order to play with containers).
      4) set up some containers under the KVM system
      5) set up contradictory routing in the KVM system and the container so
      that the host and the container see different things for the same address
      6) try to mount a CIFS share from both contexts so you can both force it
      to work and force it to fail.
      
      For a long drawn out test reproduction sequence, see:
      
        http://landley.livejournal.com/47024.html
        http://landley.livejournal.com/47205.html
        http://landley.livejournal.com/47476.htmlSigned-off-by: NRob Landley <rlandley@parallels.com>
      Reviewed-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      f1d0c998
  4. 21 1月, 2011 6 次提交
  5. 10 1月, 2011 2 次提交
  6. 07 1月, 2011 1 次提交
  7. 07 12月, 2010 1 次提交
  8. 03 12月, 2010 1 次提交
    • S
      cifs: add attribute cache timeout (actimeo) tunable · 6d20e840
      Suresh Jayaraman 提交于
      Currently, the attribute cache timeout for CIFS is hardcoded to 1 second. This
      means that the client might have to issue a QPATHINFO/QFILEINFO call every 1
      second to verify if something has changes, which seems too expensive. On the
      other hand, if the timeout is hardcoded to a higher value, workloads that
      expect strict cache coherency might see unexpected results.
      
      Making attribute cache timeout as a tunable will allow us to make a tradeoff
      between performance and cache metadata correctness depending on the
      application/workload needs.
      
      Add 'actimeo' tunable that can be used to tune the attribute cache timeout.
      The default timeout is set to 1 second. Also, display actimeo option value in
      /proc/mounts.
      
      It appears to me that 'actimeo' and the proposed (but not yet merged)
      'strictcache' option cannot coexist, so care must be taken that we reset the
      other option if one of them is set.
      
      Changes since last post:
         - fix option parsing and handle possible values correcly
      Reviewed-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSuresh Jayaraman <sjayaraman@suse.de>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      6d20e840
  9. 03 11月, 2010 1 次提交
    • J
      cifs: convert tlink_tree to a rbtree · b647c35f
      Jeff Layton 提交于
      Radix trees are ideal when you want to track a bunch of pointers and
      can't embed a tracking structure within the target of those pointers.
      The tradeoff is an increase in memory, particularly if the tree is
      sparse.
      
      In CIFS, we use the tlink_tree to track tcon_link structs. A tcon_link
      can never be in more than one tlink_tree, so there's no impediment to
      using a rb_tree here instead of a radix tree.
      
      Convert the new multiuser mount code to use a rb_tree instead. This
      should reduce the memory required to manage the tlink_tree.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      b647c35f
  10. 29 10月, 2010 2 次提交
    • S
      cifs: Cleanup and thus reduce smb session structure and fields used during authentication · d3686d54
      Shirish Pargaonkar 提交于
      Removed following fields from smb session structure
       cryptkey, ntlmv2_hash, tilen, tiblob
      and ntlmssp_auth structure is allocated dynamically only if the auth mech
      in NTLMSSP.
      
      response field within a session_key structure is used to initially store the
      target info (either plucked from type 2 challenge packet in case of NTLMSSP
      or fabricated in case of NTLMv2 without extended security) and then to store
      Message Authentication Key (mak) (session key + client response).
      
      Server challenge or cryptkey needed during a NTLMSSP authentication
      is now part of ntlmssp_auth structure which gets allocated and freed
      once authenticaiton process is done.
      Signed-off-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      d3686d54
    • S
      NTLM auth and sign - Use appropriate server challenge · d3ba50b1
      Shirish Pargaonkar 提交于
      Need to have cryptkey or server challenge in smb connection
      (struct TCP_Server_Info) for ntlm and ntlmv2 auth types for which
      cryptkey (Encryption Key) is supplied just once in Negotiate Protocol
      response during an smb connection setup for all the smb sessions over
      that smb connection.
      
      For ntlmssp, cryptkey or server challenge is provided for every
      smb session in type 2 packet of ntlmssp negotiation, the cryptkey
      provided during Negotiation Protocol response before smb connection
      does not count.
      
      Rename cryptKey to cryptkey and related changes.
      Signed-off-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      d3ba50b1
  11. 27 10月, 2010 3 次提交
    • S
      NTLM auth and sign - minor error corrections and cleanup · f7c5445a
      Shirish Pargaonkar 提交于
      Minor cleanup - Fix spelling mistake, make meaningful (goto) label
      
      In function setup_ntlmv2_rsp(), do not return 0 and leak memory,
      let the tiblob get freed.
      
      For function find_domain_name(), pass already available nls table pointer
      instead of loading and unloading the table again in this function.
      
      For ntlmv2, the case sensitive password length is the length of the
      response, so subtract session key length (16 bytes) from the .len.
      Signed-off-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      f7c5445a
    • S
      NTLM auth and sign - Define crypto hash functions and create and send keys needed for key exchange · d2b91521
      Shirish Pargaonkar 提交于
      Mark dependency on crypto modules in Kconfig.
      
      Defining per structures sdesc and cifs_secmech which are used to store
      crypto hash functions and contexts.  They are stored per smb connection
      and used for all auth mechs to genereate hash values and signatures.
      
      Allocate crypto hashing functions, security descriptiors, and respective
      contexts when a smb/tcp connection is established.
      Release them when a tcp/smb connection is taken down.
      
      md5 and hmac-md5 are two crypto hashing functions that are used
      throught the life of an smb/tcp connection by various functions that
      calcualte signagure and ntlmv2 hash, HMAC etc.
      
      structure ntlmssp_auth is defined as per smb connection.
      
      ntlmssp_auth holds ciphertext which is genereated by rc4/arc4 encryption of
      secondary key, a nonce using ntlmv2 session key and sent in the session key
      field of the type 3 message sent by the client during ntlmssp
      negotiation/exchange
      
      A key is exchanged with the server if client indicates so in flags in
      type 1 messsage and server agrees in flag in type 2 message of ntlmssp
      negotiation.  If both client and agree, a key sent by client in
      type 3 message of ntlmssp negotiation in the session key field.
      The key is a ciphertext generated off of secondary key, a nonce, using
      ntlmv2 hash via rc4/arc4.
      
      Signing works for ntlmssp in this patch. The sequence number within
      the server structure needs to be zero until session is established
      i.e. till type 3 packet of ntlmssp exchange of a to be very first
      smb session on that smb connection is sent.
      Acked-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      d2b91521
    • S
      NTLM auth and sign - Allocate session key/client response dynamically · 21e73393
      Shirish Pargaonkar 提交于
      Start calculating auth response within a session.  Move/Add pertinet
      data structures like session key, server challenge and ntlmv2_hash in
      a session structure.  We should do the calculations within a session
      before copying session key and response over to server data
      structures because a session setup can fail.
      
      Only after a very first smb session succeeds, it copy/make its
      session key, session key of smb connection.  This key stays with
      the smb connection throughout its life.
      sequence_number within server is set to 0x2.
      
      The authentication Message Authentication Key (mak) which consists
      of session key followed by client response within structure session_key
      is now dynamic.  Every authentication type allocates the key + response
      sized memory within its session structure and later either assigns or
      frees it once the client response is sent and if session's session key
      becomes connetion's session key.
      
      ntlm/ntlmi authentication functions are rearranged.  A function
      named setup_ntlm_resp(), similar to setup_ntlmv2_resp(), replaces
      function cifs_calculate_session_key().
      
      size of CIFS_SESS_KEY_SIZE is changed to 16, to reflect the byte size
      of the key it holds.
      Reviewed-by: NJeff Layton <jlayton@samba.org>
      Signed-off-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      21e73393
  12. 25 10月, 2010 4 次提交
  13. 22 10月, 2010 1 次提交
  14. 21 10月, 2010 1 次提交
    • S
      cifs: convert cifs_tcp_ses_lock from a rwlock to a spinlock · 3f9bcca7
      Suresh Jayaraman 提交于
      cifs_tcp_ses_lock is a rwlock with protects the cifs_tcp_ses_list,
      server->smb_ses_list and the ses->tcon_list. It also protects a few
      ref counters in server, ses and tcon. In most cases the critical section
      doesn't seem to be large, in a few cases where it is slightly large, there
      seem to be really no benefit from concurrent access. I briefly considered RCU
      mechanism but it appears to me that there is no real need.
      
      Replace it with a spinlock and get rid of the last rwlock in the cifs code.
      Signed-off-by: NSuresh Jayaraman <sjayaraman@suse.de>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      3f9bcca7
  15. 18 10月, 2010 4 次提交
  16. 15 10月, 2010 1 次提交
  17. 13 10月, 2010 2 次提交
    • J
      cifs: don't use vfsmount to pin superblock for oplock breaks · d7c86ff8
      Jeff Layton 提交于
      Filesystems aren't really supposed to do anything with a vfsmount. It's
      considered a layering violation since vfsmounts are entirely managed at
      the VFS layer.
      
      CIFS currently keeps an active reference to a vfsmount in order to
      prevent the superblock vanishing before an oplock break has completed.
      What we really want to do instead is to keep sb->s_active high until the
      oplock break has completed. This patch borrows the scheme that NFS uses
      for handling sillyrenames.
      
      An atomic_t is added to the cifs_sb_info. When it transitions from 0 to
      1, an extra reference to the superblock is taken (by bumping the
      s_active value). When it transitions from 1 to 0, that reference is
      dropped and a the superblock teardown may proceed if there are no more
      references to it.
      
      Also, the vfsmount pointer is removed from cifsFileInfo and from
      cifs_new_fileinfo, and some bogus forward declarations are removed from
      cifsfs.h.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Reviewed-by: NSuresh Jayaraman <sjayaraman@suse.de>
      Acked-by: NDave Kleikamp <shaggy@linux.vnet.ibm.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      d7c86ff8
    • J
      cifs: keep dentry reference in cifsFileInfo instead of inode reference · a5e18bc3
      Jeff Layton 提交于
      cifsFileInfo is a bit problematic. It contains a reference back to the
      struct file itself. This makes it difficult for a cifsFileInfo to exist
      without a corresponding struct file.
      
      It would be better instead of the cifsFileInfo just held info pertaining
      to the open file on the server instead without any back refrences to the
      struct file. This would allow it to exist after the filp to which it was
      originally attached was closed.
      
      Much of the use of the file pointer in this struct is to get at the
      dentry.  Begin divorcing the cifsFileInfo from the struct file by
      keeping a reference to the dentry. Since the dentry will have a
      reference to the inode, we can eliminate the "pInode" field too and
      convert the igrab/iput to dget/dput.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Reviewed-by: NSuresh Jayaraman <sjayaraman@suse.de>
      Acked-by: NDave Kleikamp <shaggy@linux.vnet.ibm.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      a5e18bc3
  18. 08 10月, 2010 2 次提交
    • S
      [CIFS] Various small checkpatch cleanups · 13cd4b7f
      Steve French 提交于
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      13cd4b7f
    • J
      cifs: add routines to build sessions and tcons on the fly · 9d002df4
      Jeff Layton 提交于
      This patch is rather large, but it's a bit difficult to do piecemeal...
      
      For non-multiuser mounts, everything will basically work as it does
      today. A call to cifs_sb_tlink will return the "master" tcon link.
      
      Turn the tcon pointer in the cifs_sb into a radix tree that uses the
      fsuid of the process as a key. The value is a new "tcon_link" struct
      that contains info about a tcon that's under construction.
      
      When a new process needs a tcon, it'll call cifs_sb_tcon. That will
      then look up the tcon_link in the radix tree. If it exists and is
      valid, it's returned.
      
      If it doesn't exist, then we stuff a new tcon_link into the tree and
      mark it as pending and then go and try to build the session/tcon.
      If that works, the tcon pointer in the tcon_link is updated and the
      pending flag is cleared.
      
      If the construction fails, then we set the tcon pointer to an ERR_PTR
      and clear the pending flag.
      
      If the radix tree is searched and the tcon_link is marked pending
      then we go to sleep and wait for the pending flag to be cleared.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      9d002df4
  19. 07 10月, 2010 2 次提交
  20. 30 9月, 2010 3 次提交