1. 04 12月, 2009 1 次提交
    • J
      cifs: NULL out tcon, pSesInfo, and srvTcp pointers when chasing DFS referrals · a2934c7b
      Jeff Layton 提交于
      The scenario is this:
      
      The kernel gets EREMOTE and starts chasing a DFS referral at mount time.
      The tcon reference is put, which puts the session reference too, but
      neither pointer is zeroed out.
      
      The mount gets retried (goto try_mount_again) with new mount info.
      Session setup fails fails and rc ends up being non-zero. The code then
      falls through to the end and tries to put the previously freed tcon
      pointer again.  Oops at: cifs_put_smb_ses+0x14/0xd0
      
      Fix this by moving the initialization of the rc variable and the tcon,
      pSesInfo and srvTcp pointers below the try_mount_again label. Also, add
      a FreeXid() before the goto to prevent xid "leaks".
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Reported-by: NGustavo Carvalho Homem <gustavo@angulosolido.pt>
      CC: stable <stable@kernel.org>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      a2934c7b
  2. 07 11月, 2009 1 次提交
    • J
      cifs: don't use CIFSGetSrvInodeNumber in is_path_accessible · f475f677
      Jeff Layton 提交于
      Because it's lighter weight, CIFS tries to use CIFSGetSrvInodeNumber to
      verify the accessibility of the root inode and then falls back to doing a
      full QPathInfo if that fails with -EOPNOTSUPP. I have at least a report
      of a server that returns NT_STATUS_INTERNAL_ERROR rather than something
      that translates to EOPNOTSUPP.
      
      Rather than trying to be clever with that call, just have
      is_path_accessible do a normal QPathInfo. That call is widely
      supported and it shouldn't increase the overhead significantly.
      
      Cc: Stable <stable@kernel.org>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      f475f677
  3. 07 10月, 2009 1 次提交
    • S
      [CIFS] Fixing to avoid invalid kfree() in cifs_get_tcp_session() · 8347a5cd
      Steve French 提交于
      trivial bug in fs/cifs/connect.c .
      The bug is caused by fail of extract_hostname()
      when mounting cifs file system.
      
      This is the situation when I noticed this bug.
      
      % sudo mount -t cifs //192.168.10.208 mountpoint -o options...
      
      Then my kernel says,
      
      [ 1461.807776] ------------[ cut here ]------------
      [ 1461.807781] kernel BUG at mm/slab.c:521!
      [ 1461.807784] invalid opcode: 0000 [#2] PREEMPT SMP
      [ 1461.807790] last sysfs file:
      /sys/devices/pci0000:00/0000:00:1e.0/0000:09:02.0/resource
      [ 1461.807793] CPU 0
      [ 1461.807796] Modules linked in: nls_iso8859_1 usbhid sbp2 uhci_hcd
      ehci_hcd i2c_i801 ohci1394 ieee1394 psmouse serio_raw pcspkr sky2 usbcore
      evdev
      [ 1461.807816] Pid: 3446, comm: mount Tainted: G      D 2.6.32-rc2-vanilla
      [ 1461.807820] RIP: 0010:[<ffffffff810b888e>]  [<ffffffff810b888e>]
      kfree+0x63/0x156
      [ 1461.807829] RSP: 0018:ffff8800b4f7fbb8  EFLAGS: 00010046
      [ 1461.807832] RAX: ffffea00033fff98 RBX: ffff8800afbae7e2 RCX:
      0000000000000000
      [ 1461.807836] RDX: ffffea0000000000 RSI: 000000000000005c RDI:
      ffffffffffffffea
      [ 1461.807839] RBP: ffff8800b4f7fbf8 R08: 0000000000000001 R09:
      0000000000000000
      [ 1461.807842] R10: 0000000000000000 R11: ffff8800b4f7fbf8 R12:
      00000000ffffffea
      [ 1461.807845] R13: ffff8800afb23000 R14: ffff8800b4f87bc0 R15:
      ffffffffffffffea
      [ 1461.807849] FS:  00007f52b6f187c0(0000) GS:ffff880007600000(0000)
      knlGS:0000000000000000
      [ 1461.807852] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      [ 1461.807855] CR2: 0000000000613000 CR3: 00000000af8f9000 CR4:
      00000000000006f0
      [ 1461.807858] DR0: 0000000000000000 DR1: 0000000000000000 DR2:
      0000000000000000
      [ 1461.807861] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7:
      0000000000000400
      [ 1461.807865] Process mount (pid: 3446, threadinfo ffff8800b4f7e000, task
      ffff8800950e4380)
      [ 1461.807867] Stack:
      [ 1461.807869]  0000000000000202 0000000000000282 ffff8800b4f7fbf8
      ffff8800afbae7e2
      [ 1461.807876] <0> 00000000ffffffea ffff8800afb23000 ffff8800b4f87bc0
      ffff8800b4f7fc28
      [ 1461.807884] <0> ffff8800b4f7fcd8 ffffffff81159f6d ffffffff81147bc2
      ffffffff816bfb48
      [ 1461.807892] Call Trace:
      [ 1461.807899]  [<ffffffff81159f6d>] cifs_get_tcp_session+0x440/0x44b
      [ 1461.807904]  [<ffffffff81147bc2>] ? find_nls+0x1c/0xe9
      [ 1461.807909]  [<ffffffff8115b889>] cifs_mount+0x16bc/0x2167
      [ 1461.807917]  [<ffffffff814455bd>] ? _spin_unlock+0x30/0x4b
      [ 1461.807923]  [<ffffffff81150da9>] cifs_get_sb+0xa5/0x1a8
      [ 1461.807928]  [<ffffffff810c1b94>] vfs_kern_mount+0x56/0xc9
      [ 1461.807933]  [<ffffffff810c1c64>] do_kern_mount+0x47/0xe7
      [ 1461.807938]  [<ffffffff810d8632>] do_mount+0x712/0x775
      [ 1461.807943]  [<ffffffff810d671f>] ? copy_mount_options+0xcf/0x132
      [ 1461.807948]  [<ffffffff810d8714>] sys_mount+0x7f/0xbf
      [ 1461.807953]  [<ffffffff8144509a>] ? lockdep_sys_exit_thunk+0x35/0x67
      [ 1461.807960]  [<ffffffff81011cc2>] system_call_fastpath+0x16/0x1b
      [ 1461.807963] Code: 00 00 00 00 ea ff ff 48 c1 e8 0c 48 6b c0 68 48 01 d0
      66 83 38 00 79 04 48 8b 40 10 66 83 38 00 79 04 48 8b 40 10 80 38 00 78 04
      <0f> 0b eb fe 4c 8b 70 58 4c 89 ff 41 8b 76 4c e8 b8 49 fb ff e8
      [ 1461.808022] RIP  [<ffffffff810b888e>] kfree+0x63/0x156
      [ 1461.808027]  RSP <ffff8800b4f7fbb8>
      [ 1461.808031] ---[ end trace ffe26fcdc72c0ce4 ]---
      
      The reason of this bug is that the error handling code of
      cifs_get_tcp_session()
      calls kfree() when corresponding kmalloc() failed.
      (The kmalloc() is called by extract_hostname().)
      Signed-off-by: NHitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
      CC: Stable <stable@kernel.org>
      Reviewed-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      8347a5cd
  4. 25 9月, 2009 1 次提交
    • J
      cifs: convert oplock breaks to use slow_work facility (try #4) · 3bc303c2
      Jeff Layton 提交于
      This is the fourth respin of the patch to convert oplock breaks to
      use the slow_work facility.
      
      A customer of ours was testing a backport of one of the earlier
      patchsets, and hit a "Busy inodes after umount..." problem. An oplock
      break job had raced with a umount, and the superblock got torn down and
      its memory reused. When the oplock break job tried to dereference the
      inode->i_sb, the kernel oopsed.
      
      This patchset has the oplock break job hold an inode and vfsmount
      reference until the oplock break completes.  With this, there should be
      no need to take a tcon reference (the vfsmount implicitly holds one
      already).
      
      Currently, when an oplock break comes in there's a chance that the
      oplock break job won't occur if the allocation of the oplock_q_entry
      fails. There are also some rather nasty races in the allocation and
      handling these structs.
      
      Rather than allocating oplock queue entries when an oplock break comes
      in, add a few extra fields to the cifsFileInfo struct. Get rid of the
      dedicated cifs_oplock_thread as well and queue the oplock break job to
      the slow_work thread pool.
      
      This approach also has the advantage that the oplock break jobs can
      potentially run in parallel rather than be serialized like they are
      today.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      3bc303c2
  5. 02 9月, 2009 2 次提交
    • S
      [CIFS] Fix checkpatch warnings · ca43e3be
      Steve French 提交于
      Also update version number to 1.61
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      ca43e3be
    • S
      PATCH] cifs: fix broken mounts when a SSH tunnel is used (try #4) · bdb97adc
      Suresh Jayaraman 提交于
      One more try..
      
      It seems there is a regression that got introduced while Jeff fixed
      all the mount/umount races. While attempting to find whether a tcp
      session is already existing, we were not checking whether the "port"
      used are the same. When a second mount is attempted with a different
      "port=" option, it is being ignored. Because of this the cifs mounts
      that uses a SSH tunnel appears to be broken.
      
      Steps to reproduce:
      
      1. create 2 shares
      # SSH Tunnel a SMB session
      2. ssh -f -L 6111:127.0.0.1:445 root@localhost "sleep 86400"
      3. ssh -f -L 6222:127.0.0.1:445 root@localhost "sleep 86400"
      4. tcpdump -i lo 6111 &
      5. mkdir -p /mnt/mnt1
      6. mkdir -p /mnt/mnt2
      7. mount.cifs //localhost/a /mnt/mnt1 -o username=guest,ip=127.0.0.1,port=6111
      #(shows tcpdump activity on port 6111)
      8. mount.cifs //localhost/b /mnt/mnt2 -o username=guest,ip=127.0.0.1,port=6222
      #(shows tcpdump activity only on port 6111 and not on 6222
      
      Fix by adding a check to compare the port _only_ if the user tries to
      override the tcp port with "port=" option, before deciding that an
      existing tcp session is found. Also, clean up a bit by replacing
      if-else if by a switch statment while at it as suggested by Jeff.
      Reviewed-by: NJeff Layton <jlayton@redhat.com>
      Reviewed-by: NShirish Pargaonkar <shirishp@us.ibm.com>
      Signed-off-by: NSuresh Jayaraman <sjayaraman@suse.de>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      bdb97adc
  6. 02 8月, 2009 1 次提交
  7. 28 7月, 2009 1 次提交
  8. 23 7月, 2009 1 次提交
    • J
      cifs: fix sb->s_maxbytes so that it casts properly to a signed value · 03aa3a49
      Jeff Layton 提交于
      This off-by-one bug causes sendfile() to not work properly. When a task
      calls sendfile() on a file on a CIFS filesystem, the syscall returns -1
      and sets errno to EOVERFLOW.
      
      do_sendfile uses s_maxbytes to verify the returned offset of the file.
      The problem there is that this value is cast to a signed value (loff_t).
      When this is done on the s_maxbytes value that cifs uses, it becomes
      negative and the comparisons against it fail.
      
      Even though s_maxbytes is an unsigned value, it seems that it's not OK
      to set it in such a way that it'll end up negative when it's cast to a
      signed value. These casts happen in other codepaths besides sendfile
      too, but the VFS is a little hard to follow in this area and I can't
      be sure if there are other bugs that this will fix.
      
      It's not clear to me why s_maxbytes isn't just declared as loff_t in the
      first place, but either way we still need to fix these values to make
      sendfile work properly. This is also an opportunity to replace the magic
      bit-shift values here with the standard #defines for this.
      
      This fixes the reproducer program I have that does a sendfile and
      will probably also fix the situation where apache is serving from a
      CIFS share.
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      03aa3a49
  9. 21 7月, 2009 1 次提交
  10. 26 6月, 2009 1 次提交
  11. 25 6月, 2009 3 次提交
  12. 13 6月, 2009 1 次提交
  13. 11 6月, 2009 1 次提交
  14. 10 6月, 2009 1 次提交
  15. 07 6月, 2009 1 次提交
    • J
      cifs: make overriding of ownership conditional on new mount options · 4ae1507f
      Jeff Layton 提交于
      We have a bit of a problem with the uid= option. The basic issue is that
      it means too many things and has too many side-effects.
      
      It's possible to allow an unprivileged user to mount a filesystem if the
      user owns the mountpoint, /bin/mount is setuid root, and the mount is
      set up in /etc/fstab with the "user" option.
      
      When doing this though, /bin/mount automatically adds the "uid=" and
      "gid=" options to the share. This is fortunate since the correct uid=
      option is needed in order to tell the upcall what user's credcache to
      use when generating the SPNEGO blob.
      
      On a mount without unix extensions this is fine -- you generally will
      want the files to be owned by the "owner" of the mount. The problem
      comes in on a mount with unix extensions. With those enabled, the
      uid/gid options cause the ownership of files to be overriden even though
      the server is sending along the ownership info.
      
      This means that it's not possible to have a mount by an unprivileged
      user that shows the server's file ownership info. The result is also
      inode permissions that have no reflection at all on the server. You
      simply cannot separate ownership from the mode in this fashion.
      
      This behavior also makes MultiuserMount option less usable. Once you
      pass in the uid= option for a mount, then you can't use unix ownership
      info and allow someone to share the mount.
      
      While I'm not thrilled with it, the only solution I can see is to stop
      making uid=/gid= force the overriding of ownership on mounts, and to add
      new mount options that turn this behavior on.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      4ae1507f
  16. 02 6月, 2009 1 次提交
  17. 28 5月, 2009 1 次提交
  18. 27 5月, 2009 1 次提交
    • J
      cifs: tighten up default file_mode/dir_mode · f55ed1a8
      Jeff Layton 提交于
      The current default file mode is 02767 and dir mode is 0777. This is
      extremely "loose". Given that CIFS is a single-user protocol, these
      permissions allow anyone to use the mount -- in effect, giving anyone on
      the machine access to the credentials used to mount the share.
      
      Change this by making the default permissions restrict write access to
      the default owner of the mount. Give read and execute permissions to
      everyone else. These are the same permissions that VFAT mounts get by
      default so there is some precedent here.
      
      Note that this patch also removes the mandatory locking flags from the
      default file_mode. After having looked at how these flags are used by
      the kernel, I don't think that keeping them as the default offers any
      real benefit. That flag combination makes it so that the kernel enforces
      mandatory locking.
      
      Since the server is going to do that for us anyway, I don't think we
      want the client to enforce this by default on applications that just
      want advisory locks. Anyone that does want this behavior can always
      enable it by setting the file_mode appropriately.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      f55ed1a8
  19. 06 5月, 2009 1 次提交
  20. 02 5月, 2009 1 次提交
  21. 01 5月, 2009 6 次提交
  22. 30 4月, 2009 1 次提交
  23. 17 4月, 2009 7 次提交
  24. 18 3月, 2009 1 次提交
  25. 12 3月, 2009 2 次提交
    • S
      [CIFS] fix build error · 4717bed6
      Steve French 提交于
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      4717bed6
    • S
      [CIFS] Add new nostrictsync cifs mount option to avoid slow SMB flush · be652445
      Steve French 提交于
      If this mount option is set, when an application does an
      fsync call then the cifs client does not send an SMB Flush
      to the server (to force the server to write all dirty data
      for this file immediately to disk), although cifs still sends
      all dirty (cached) file data to the server and waits for the
      server to respond to the write write.  Since SMB Flush can be
      very slow, and some servers may be reliable enough (to risk
      delaying slightly flushing the data to disk on the server),
      turning on this option may be useful to improve performance for
      applications that fsync too much, at a small risk of server
      crash.  If this mount option is not set, by default cifs will
      send an SMB flush request (and wait for a response) on every
      fsync call.
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      be652445