1. 09 9月, 2013 14 次提交
    • S
      cifs: Add a variable specific to NTLMSSP for key exchange. · 5c234aa5
      Shirish Pargaonkar 提交于
      Add a variable specific to NTLMSSP authentication to determine
      whether to exchange keys during negotiation and authentication phases.
      
      Since session key for smb1 is per smb connection, once a very first
      sesion is established, there is no need for key exchange during
      subsequent session setups. As a result, smb1 session setup code sets this
      variable as false.
      
      Since session key for smb2 and smb3 is per smb connection, we need to
      exchange keys to generate session key for every sesion being established.
      As a result, smb2/3 session setup code sets this variable as true.
      Acked-by: NJeff Layton <jlayton@samba.org>
      Signed-off-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      5c234aa5
    • S
      cifs: Process post session setup code in respective dialect functions. · d4e63bd6
      Shirish Pargaonkar 提交于
      Move the post (successful) session setup code to respective dialect routines.
      
      For smb1, session key is per smb connection.
      For smb2/smb3, session key is per smb session.
      
      If client and server do not require signing, free session key for smb1/2/3.
      
      If client and server require signing
        smb1 - Copy (kmemdup) session key for the first session to connection.
               Free session key of that and subsequent sessions on this connection.
        smb2 - For every session, keep the session key and free it when the
               session is being shutdown.
        smb3 - For every session, generate the smb3 signing key using the session key
               and then free the session key.
      
      There are two unrelated line formatting changes as well.
      Reviewed-by: NJeff Layton <jlayton@samba.org>
      Signed-off-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      d4e63bd6
    • W
      CIFS: convert to use le32_add_cpu() · 31f92e9a
      Wei Yongjun 提交于
      Convert cpu_to_le32(le32_to_cpu(E1) + E2) to use le32_add_cpu().
      Signed-off-by: NWei Yongjun <yongjun_wei@trendmicro.com.cn>
      Reviewed-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      31f92e9a
    • P
      CIFS: Fix missing lease break · 933d4b36
      Pavel Shilovsky 提交于
      If a server sends a lease break to a connection that doesn't have
      opens with a lease key specified in the server response, we can't
      find an open file to send an ack. Fix this by walking through
      all connections we have.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NPavel Shilovsky <pshilovsky@samba.org>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      933d4b36
    • P
      CIFS: Fix a memory leak when a lease break comes · 1a05096d
      Pavel Shilovsky 提交于
      This happens when we receive a lease break from a server, then
      find an appropriate lease key in opened files and schedule the
      oplock_break slow work. lw pointer isn't freed in this case.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NPavel Shilovsky <pshilovsky@samba.org>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      1a05096d
    • J
      cifs: convert case-insensitive dentry ops to use new case conversion routines · ec71e0e1
      Jeff Layton 提交于
      Have the case-insensitive d_compare and d_hash routines convert each
      character in the filenames to wchar_t's and then use the new
      cifs_toupper routine to convert those into uppercase.
      
      With this scheme we should more closely emulate the case conversion that
      the servers will do.
      Reported-and-Tested-by: NJan-Marek Glogowski <glogow@fbihome.de>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      ec71e0e1
    • J
      cifs: add new case-insensitive conversion routines that are based on wchar_t's · c2ccf53d
      Jeff Layton 提交于
      The existing NLS case conversion routines do not appropriately handle
      the (now common) case where the local host is using UTF8. This is
      because nls_utf8 has no support at all for converting a utf8 string
      between cases and the NLS infrastructure in general cannot handle
      a multibyte input character.
      
      In any case, what we really need for cifs is to emulate how we expect
      the server to convert the character to upper or lowercase. Thus, even
      if we had routines that could handle utf8 case conversion, we likely
      would end up with the wrong result if the name ends up being in the
      upper planes.
      
      This patch adds a new scheme for doing unicode case conversion. The
      case conversion tables that Microsoft has published for Windows 8
      have been converted to a set of lookup tables, and a routine is
      added to convert a wchar_t from lower to uppercase using those
      tables.
      Reported-and-Tested-by: NJan-Marek Glogowski <glogow@fbihome.de>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      c2ccf53d
    • S
      cifs: Move and expand MAX_SERVER_SIZE definition · cdf1246f
      Scott Lovenberg 提交于
      MAX_SERVER_SIZE has been moved to cifs_mount.h and renamed
      CIFS_NI_MAXHOST for clarity.  It has been expanded to 1024 as the
      previous value of 16 was very short.
      Signed-off-by: NScott Lovenberg <scott.lovenberg@gmail.com>
      Reviewed-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      cdf1246f
    • S
      cifs: Move string length definitions to uapi · 8c3a2b4c
      Scott Lovenberg 提交于
      The max string length definitions for user name, domain name, password,
      and share name have been moved into their own header file in uapi so the
      mount helper can use autoconf to define them instead of keeping the
      kernel side and userland side definitions in sync manually.  The names
      have also been standardized with a "CIFS" prefix and "LEN" suffix.
      Signed-off-by: NScott Lovenberg <scott.lovenberg@gmail.com>
      Reviewed-by: NChen Gang <gang.chen@asianux.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      8c3a2b4c
    • P
      CIFS: Implement follow_link for nounix CIFS mounts · d244bf2d
      Pavel Shilovsky 提交于
      by using a query reparse ioctl request.
      Acked-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NPavel Shilovsky <pshilovsky@samba.org>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      d244bf2d
    • P
      CIFS: Implement follow_link for SMB2 · b42bf888
      Pavel Shilovsky 提交于
      that allows to access files through symlink created on a server.
      Acked-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NPavel Shilovsky <pshilovsky@samba.org>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      b42bf888
    • J
      cifs: display iocharset= option in /proc/mounts · 3ae35cde
      Jeff Layton 提交于
      ...but only if it's not the default charset.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      3ae35cde
    • J
      cifs: create a new Documentation/ directory and move docfiles into it · 30706a54
      Jeff Layton 提交于
      Currently, we have a number of documentation files that live under
      fs/cifs/. Generally, these don't get picked up by distro packagers,
      since they're in a non-standard location. Move them to a new spot
      under Documentation/ instead.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      30706a54
    • J
      cifs: ensure that srv_mutex is held when dealing with ssocket pointer · 73e216a8
      Jeff Layton 提交于
      Oleksii reported that he had seen an oops similar to this:
      
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000088
      IP: [<ffffffff814dcc13>] sock_sendmsg+0x93/0xd0
      PGD 0
      Oops: 0000 [#1] PREEMPT SMP
      Modules linked in: ipt_MASQUERADE xt_REDIRECT xt_tcpudp iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack ip_tables x_tables carl9170 ath usb_storage f2fs nfnetlink_log nfnetlink md4 cifs dns_resolver hid_generic usbhid hid af_packet uvcvideo videobuf2_vmalloc videobuf2_memops videobuf2_core videodev rfcomm btusb bnep bluetooth qmi_wwan qcserial cdc_wdm usb_wwan usbnet usbserial mii snd_hda_codec_hdmi snd_hda_codec_realtek iwldvm mac80211 coretemp intel_powerclamp kvm_intel kvm iwlwifi snd_hda_intel cfg80211 snd_hda_codec xhci_hcd e1000e ehci_pci snd_hwdep sdhci_pci snd_pcm ehci_hcd microcode psmouse sdhci thinkpad_acpi mmc_core i2c_i801 pcspkr usbcore hwmon snd_timer snd_page_alloc snd ptp rfkill pps_core soundcore evdev usb_common vboxnetflt(O) vboxdrv(O)Oops#2 Part8
       loop tun binfmt_misc fuse msr acpi_call(O) ipv6 autofs4
      CPU: 0 PID: 21612 Comm: kworker/0:1 Tainted: G        W  O 3.10.1SIGN #28
      Hardware name: LENOVO 2306CTO/2306CTO, BIOS G2ET92WW (2.52 ) 02/22/2013
      Workqueue: cifsiod cifs_echo_request [cifs]
      task: ffff8801e1f416f0 ti: ffff880148744000 task.ti: ffff880148744000
      RIP: 0010:[<ffffffff814dcc13>]  [<ffffffff814dcc13>] sock_sendmsg+0x93/0xd0
      RSP: 0000:ffff880148745b00  EFLAGS: 00010246
      RAX: 0000000000000000 RBX: ffff880148745b78 RCX: 0000000000000048
      RDX: ffff880148745c90 RSI: ffff880181864a00 RDI: ffff880148745b78
      RBP: ffff880148745c48 R08: 0000000000000048 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000000 R12: ffff880181864a00
      R13: ffff880148745c90 R14: 0000000000000048 R15: 0000000000000048
      FS:  0000000000000000(0000) GS:ffff88021e200000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000088 CR3: 000000020c42c000 CR4: 00000000001407b0
      Oops#2 Part7
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      Stack:
       ffff880148745b30 ffffffff810c4af9 0000004848745b30 ffff880181864a00
       ffffffff81ffbc40 0000000000000000 ffff880148745c90 ffffffff810a5aab
       ffff880148745bc0 ffffffff81ffbc40 ffff880148745b60 ffffffff815a9fb8
      Call Trace:
       [<ffffffff810c4af9>] ? finish_task_switch+0x49/0xe0
       [<ffffffff810a5aab>] ? lock_timer_base.isra.36+0x2b/0x50
       [<ffffffff815a9fb8>] ? _raw_spin_unlock_irqrestore+0x18/0x40
       [<ffffffff810a673f>] ? try_to_del_timer_sync+0x4f/0x70
       [<ffffffff815aa38f>] ? _raw_spin_unlock_bh+0x1f/0x30
       [<ffffffff814dcc87>] kernel_sendmsg+0x37/0x50
       [<ffffffffa081a0e0>] smb_send_kvec+0xd0/0x1d0 [cifs]
       [<ffffffffa081a263>] smb_send_rqst+0x83/0x1f0 [cifs]
       [<ffffffffa081ab6c>] cifs_call_async+0xec/0x1b0 [cifs]
       [<ffffffffa08245e0>] ? free_rsp_buf+0x40/0x40 [cifs]
      Oops#2 Part6
       [<ffffffffa082606e>] SMB2_echo+0x8e/0xb0 [cifs]
       [<ffffffffa0808789>] cifs_echo_request+0x79/0xa0 [cifs]
       [<ffffffff810b45b3>] process_one_work+0x173/0x4a0
       [<ffffffff810b52a1>] worker_thread+0x121/0x3a0
       [<ffffffff810b5180>] ? manage_workers.isra.27+0x2b0/0x2b0
       [<ffffffff810bae00>] kthread+0xc0/0xd0
       [<ffffffff810bad40>] ? kthread_create_on_node+0x120/0x120
       [<ffffffff815b199c>] ret_from_fork+0x7c/0xb0
       [<ffffffff810bad40>] ? kthread_create_on_node+0x120/0x120
      Code: 84 24 b8 00 00 00 4c 89 f1 4c 89 ea 4c 89 e6 48 89 df 4c 89 60 18 48 c7 40 28 00 00 00 00 4c 89 68 30 44 89 70 14 49 8b 44 24 28 <ff> 90 88 00 00 00 3d ef fd ff ff 74 10 48 8d 65 e0 5b 41 5c 41
       RIP  [<ffffffff814dcc13>] sock_sendmsg+0x93/0xd0
       RSP <ffff880148745b00>
      CR2: 0000000000000088
      
      The client was in the middle of trying to send a frame when the
      server->ssocket pointer got zeroed out. In most places, that we access
      that pointer, the srv_mutex is held. There's only one spot that I see
      that the server->ssocket pointer gets set and the srv_mutex isn't held.
      This patch corrects that.
      
      The upstream bug report was here:
      
          https://bugzilla.kernel.org/show_bug.cgi?id=60557
      
      Cc: <stable@vger.kernel.org>
      Reported-by: NOleksii Shevchuk <alxchk@gmail.com>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      73e216a8
  2. 04 9月, 2013 1 次提交
  3. 07 8月, 2013 1 次提交
  4. 01 8月, 2013 2 次提交
    • J
      cifs: set sb->s_d_op before calling d_make_root() · 66ffd113
      Jeff Layton 提交于
      Currently, the s_root dentry doesn't get its d_op pointer set to
      anything. This breaks lookups in the root of case-insensitive mounts
      since that relies on having d_hash and d_compare routines that know to
      treat the filename as case-insensitive.
      
      cifs.ko has been broken this way for a long time, but commit 1c929cfe
      ("switch cifs"), added a cryptic comment which is removed in the patch
      below, which makes me wonder if this was done deliberately for some
      reason. It's not clear to me why we'd want the s_root not to have d_op
      set properly.
      
      It may have something to do with d_automount or d_revalidate on the
      root, but my suspicion in looking over the code is that Al was just
      trying to preserve the existing behavior when changing this code over to
      use s_d_op.
      
      This patch changes it so that we set s_d_op before calling d_make_root
      and removes the comment. I tested mounting, accessing and unmounting
      several types of shares (including DFS referrals) and everything still
      seemed to work OK afterward. I could be missing something however, so
      please do let me know if I am.
      Reported-by: NJan-Marek Glogowski <glogow@fbihome.de>
      Cc: Al Viro <viro@ZenIV.linux.org.uk>
      Cc: Ian Kent <raven@themaw.net>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      66ffd113
    • J
      cifs: fix bad error handling in crypto code · ba482029
      Jeff Layton 提交于
      Jarod reported an Oops like when testing with fips=1:
      
      CIFS VFS: could not allocate crypto hmacmd5
      CIFS VFS: could not crypto alloc hmacmd5 rc -2
      CIFS VFS: Error -2 during NTLMSSP authentication
      CIFS VFS: Send error in SessSetup = -2
      BUG: unable to handle kernel NULL pointer dereference at 000000000000004e
      IP: [<ffffffff812b5c7a>] crypto_destroy_tfm+0x1a/0x90
      PGD 0
      Oops: 0000 [#1] SMP
      Modules linked in: md4 nls_utf8 cifs dns_resolver fscache kvm serio_raw virtio_balloon virtio_net mperf i2c_piix4 cirrus drm_kms_helper ttm drm i2c_core virtio_blk ata_generic pata_acpi
      CPU: 1 PID: 639 Comm: mount.cifs Not tainted 3.11.0-0.rc3.git0.1.fc20.x86_64 #1
      Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
      task: ffff88007bf496e0 ti: ffff88007b080000 task.ti: ffff88007b080000
      RIP: 0010:[<ffffffff812b5c7a>]  [<ffffffff812b5c7a>] crypto_destroy_tfm+0x1a/0x90
      RSP: 0018:ffff88007b081d10  EFLAGS: 00010282
      RAX: 0000000000001f1f RBX: ffff880037422000 RCX: ffff88007b081fd8
      RDX: 000000000000001f RSI: 0000000000000006 RDI: fffffffffffffffe
      RBP: ffff88007b081d30 R08: ffff880037422000 R09: ffff88007c090100
      R10: 0000000000000000 R11: 00000000fffffffe R12: fffffffffffffffe
      R13: ffff880037422000 R14: ffff880037422000 R15: 00000000fffffffe
      FS:  00007fc322f4f780(0000) GS:ffff88007fc80000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      CR2: 000000000000004e CR3: 000000007bdaa000 CR4: 00000000000006e0
      Stack:
       ffffffff81085845 ffff880037422000 ffff8800375e7400 ffff880037422000
       ffff88007b081d48 ffffffffa0176022 ffff880037422000 ffff88007b081d60
       ffffffffa015c07b ffff880037600600 ffff88007b081dc8 ffffffffa01610e1
      Call Trace:
       [<ffffffff81085845>] ? __cancel_work_timer+0x75/0xf0
       [<ffffffffa0176022>] cifs_crypto_shash_release+0x82/0xf0 [cifs]
       [<ffffffffa015c07b>] cifs_put_tcp_session+0x8b/0xe0 [cifs]
       [<ffffffffa01610e1>] cifs_mount+0x9d1/0xad0 [cifs]
       [<ffffffffa014ff50>] cifs_do_mount+0xa0/0x4d0 [cifs]
       [<ffffffff811ab6e9>] mount_fs+0x39/0x1b0
       [<ffffffff811c466f>] vfs_kern_mount+0x5f/0xf0
       [<ffffffff811c6a9e>] do_mount+0x23e/0xa20
       [<ffffffff811c66e6>] ? copy_mount_options+0x36/0x170
       [<ffffffff811c7303>] SyS_mount+0x83/0xc0
       [<ffffffff8165c8d9>] system_call_fastpath+0x16/0x1b
      Code: eb 9e 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 66 66 66 66 90 55 48 89 e5 41 55 41 54 49 89 fc 53 48 83 ec 08 48 85 ff 74 46 <48> 83 7e 48 00 48 8b 5e 50 74 4b 48 89 f7 e8 83 fc ff ff 4c 8b
      RIP  [<ffffffff812b5c7a>] crypto_destroy_tfm+0x1a/0x90
       RSP <ffff88007b081d10>
      CR2: 000000000000004e
      
      The cifs code allocates some crypto structures. If that fails, it
      returns an error, but it leaves the pointers set to their PTR_ERR
      values. Then later when it tries to clean up, it sees that those values
      are non-NULL and then passes them to the routine that frees them.
      
      Fix this by setting the pointers to NULL after collecting the error code
      in this situation.
      
      Cc: Sachin Prabhu <sprabhu@redhat.com>
      Reported-by: NJarod Wilson <jarod@redhat.com>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      ba482029
  5. 31 7月, 2013 3 次提交
  6. 12 7月, 2013 2 次提交
  7. 11 7月, 2013 9 次提交
  8. 05 7月, 2013 2 次提交
  9. 29 6月, 2013 5 次提交
    • J
      locks: protect most of the file_lock handling with i_lock · 1c8c601a
      Jeff Layton 提交于
      Having a global lock that protects all of this code is a clear
      scalability problem. Instead of doing that, move most of the code to be
      protected by the i_lock instead. The exceptions are the global lists
      that the ->fl_link sits on, and the ->fl_block list.
      
      ->fl_link is what connects these structures to the
      global lists, so we must ensure that we hold those locks when iterating
      over or updating these lists.
      
      Furthermore, sound deadlock detection requires that we hold the
      blocked_list state steady while checking for loops. We also must ensure
      that the search and update to the list are atomic.
      
      For the checking and insertion side of the blocked_list, push the
      acquisition of the global lock into __posix_lock_file and ensure that
      checking and update of the  blocked_list is done without dropping the
      lock in between.
      
      On the removal side, when waking up blocked lock waiters, take the
      global lock before walking the blocked list and dequeue the waiters from
      the global list prior to removal from the fl_block list.
      
      With this, deadlock detection should be race free while we minimize
      excessive file_lock_lock thrashing.
      
      Finally, in order to avoid a lock inversion problem when handling
      /proc/locks output we must ensure that manipulations of the fl_block
      list are also protected by the file_lock_lock.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      1c8c601a
    • J
      cifs: use posix_unblock_lock instead of locks_delete_block · 1a9e64a7
      Jeff Layton 提交于
      commit 66189be7 (CIFS: Fix VFS lock usage for oplocked files) exported
      the locks_delete_block symbol. There's already an exported helper
      function that provides this capability however, so make cifs use that
      instead and turn locks_delete_block back into a static function.
      
      Note that if fl->fl_next == NULL then this lock has already been through
      locks_delete_block(), so we should be OK to ignore an ENOENT error here
      and simply not retry the lock.
      
      Cc: Pavel Shilovsky <piastryyy@gmail.com>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Acked-by: NJ. Bruce Fields <bfields@fieldses.org>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      1a9e64a7
    • L
      Don't pass inode to ->d_hash() and ->d_compare() · da53be12
      Linus Torvalds 提交于
      Instances either don't look at it at all (the majority of cases) or
      only want it to find the superblock (which can be had as dentry->d_sb).
      A few cases that want more are actually safe with dentry->d_inode -
      the only precaution needed is the check that it hadn't been replaced with
      NULL by rmdir() or by overwriting rename(), which case should be simply
      treated as cache miss.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      da53be12
    • A
      [readdir] convert cifs · be4ccdcc
      Al Viro 提交于
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      be4ccdcc
    • D
      cifs: fill TRANS2_QUERY_FILE_INFO ByteCount fields · 7ac0febb
      David Disseldorp 提交于
      Currently the trans2 ByteCount field is incorrectly left zero in
      TRANS2_QUERY_FILE_INFO info_level=SMB_QUERY_FILE_ALL_INFO and
      info_level=SMB_QUERY_FILE_UNIX_BASIC requests. The field should properly
      reflect the FID, information_level and padding bytes carried in these
      requests.
      
      Leaving this field zero causes such requests to fail against Novell CIFS
      servers. Other SMB servers (e.g. Samba) use the parameter count fields
      for data length calculations instead, so do not suffer the same fate.
      Signed-off-by: NDavid Disseldorp <ddiss@suse.de>
      Acked-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      7ac0febb
  10. 28 6月, 2013 1 次提交