1. 08 8月, 2018 1 次提交
  2. 06 7月, 2018 1 次提交
    • L
      cifs: Fix use after free of a mid_q_entry · 696e420b
      Lars Persson 提交于
      With protocol version 2.0 mounts we have seen crashes with corrupt mid
      entries. Either the server->pending_mid_q list becomes corrupt with a
      cyclic reference in one element or a mid object fetched by the
      demultiplexer thread becomes overwritten during use.
      
      Code review identified a race between the demultiplexer thread and the
      request issuing thread. The demultiplexer thread seems to be written
      with the assumption that it is the sole user of the mid object until
      it calls the mid callback which either wakes the issuer task or
      deletes the mid.
      
      This assumption is not true because the issuer task can be woken up
      earlier by a signal. If the demultiplexer thread has proceeded as far
      as setting the mid_state to MID_RESPONSE_RECEIVED then the issuer
      thread will happily end up calling cifs_delete_mid while the
      demultiplexer thread still is using the mid object.
      
      Inserting a delay in the cifs demultiplexer thread widens the race
      window and makes reproduction of the race very easy:
      
      		if (server->large_buf)
      			buf = server->bigbuf;
      
      +		usleep_range(500, 4000);
      
      		server->lstrp = jiffies;
      
      To resolve this I think the proper solution involves putting a
      reference count on the mid object. This patch makes sure that the
      demultiplexer thread holds a reference until it has finished
      processing the transaction.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NLars Persson <larper@axis.com>
      Acked-by: NPaulo Alcantara <palcantara@suse.de>
      Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      696e420b
  3. 15 6月, 2018 2 次提交
  4. 07 6月, 2018 2 次提交
  5. 03 6月, 2018 2 次提交
  6. 01 6月, 2018 2 次提交
  7. 31 5月, 2018 2 次提交
    • S
      smb3: allow "posix" mount option to enable new SMB311 protocol extensions · b326614e
      Steve French 提交于
      If "posix" (or synonym "unix" for backward compatibility) specified on mount,
      and server advertises support for SMB3.11 POSIX negotiate context, then
      enable the new posix extensions on the tcon.  This can be viewed by
      looking for "posix" in the mount options displayed by /proc/mounts
      for that mount (ie if posix extensions allowed by server and the
      experimental POSIX extensions also requested on the mount by specifying
      "posix" at mount time).
      
      Also add check to warn user if conflicting unix/nounix or posix/noposix specified
      on mount.
      Signed-off-by: NSteve French <smfrench@gmail.com>
      b326614e
    • S
      cifs: allow disabling less secure legacy dialects · f92a720e
      Steve French 提交于
      To improve security it may be helpful to have additional ways to restrict the
      ability to override the default dialects (SMB2.1, SMB3 and SMB3.02) on mount
      with old dialects (CIFS/SMB1 and SMB2) since vers=1.0 (CIFS/SMB1) and vers=2.0
      are weaker and less secure.
      
      Add a module parameter "disable_legacy_dialects"
      (/sys/module/cifs/parameters/disable_legacy_dialects) which can be set to
      1 (or equivalently Y) to forbid use of vers=1.0 or vers=2.0 on mount.
      
      Also cleans up a few build warnings about globals for various module parms.
      Signed-off-by: NSteve French <smfrench@gmail.com>
      f92a720e
  8. 28 5月, 2018 2 次提交
    • S
      cifs: fix build break when CONFIG_CIFS_DEBUG2 enabled · 71992e62
      Steve French 提交于
      Previous patches "cifs: update calc_size to take a server argument"
      and
        "cifs: add server argument to the dump_detail method"
      were broken if CONFIG_CIFS_DEBUG2 enabled
      Signed-off-by: NSteve French <smfrench@gmail.com>
      CC: Ronnie Sahlberg <lsahlber@redhat.com>
      71992e62
    • S
      smb3: fix redundant opens on root · 3d4ef9a1
      Steve French 提交于
      In SMB2/SMB3 unlike in cifs we unnecessarily open the root of the share
      over and over again in various places during mount and path revalidation
      and also in statfs.  This patch cuts redundant traffic (opens and closes)
      by simply keeping the directory handle for the root around (and reopening
      it as needed on reconnect), so query calls don't require three round
      trips to copmlete - just one, and eases load on network, client and
      server (on mount alone, cuts network traffic by more than a third).
      
      Also add a new cifs mount parm "nohandlecache" to allow users whose
      servers might have resource constraints (eg in case they have a server
      with so many users connecting to it that this extra handle per mount
      could possibly be a resource concern).
      Signed-off-by: NSteve French <smfrench@gmail.com>
      Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
      3d4ef9a1
  9. 10 5月, 2018 1 次提交
  10. 24 4月, 2018 1 次提交
  11. 13 4月, 2018 2 次提交
  12. 03 4月, 2018 1 次提交
  13. 02 4月, 2018 1 次提交
  14. 27 1月, 2018 3 次提交
  15. 25 1月, 2018 7 次提交
  16. 21 9月, 2017 1 次提交
    • S
      cifs: release auth_key.response for reconnect. · f5c4ba81
      Shu Wang 提交于
      There is a race that cause cifs reconnect in cifs_mount,
      - cifs_mount
        - cifs_get_tcp_session
          - [ start thread cifs_demultiplex_thread
            - cifs_read_from_socket: -ECONNABORTED
              - DELAY_WORK smb2_reconnect_server ]
        - cifs_setup_session
        - [ smb2_reconnect_server ]
      
      auth_key.response was allocated in cifs_setup_session, and
      will release when the session destoried. So when session re-
      connect, auth_key.response should be check and released.
      
      Tested with my system:
      CIFS VFS: Free previous auth_key.response = ffff8800320bbf80
      
      A simple auth_key.response allocation call trace:
      - cifs_setup_session
      - SMB2_sess_setup
      - SMB2_sess_auth_rawntlmssp_authenticate
      - build_ntlmssp_auth_blob
      - setup_ntlmv2_rsp
      Signed-off-by: NShu Wang <shuwang@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      CC: Stable <stable@vger.kernel.org>
      Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
      f5c4ba81
  17. 18 9月, 2017 1 次提交
    • S
      SMB3: Add support for multidialect negotiate (SMB2.1 and later) · 9764c02f
      Steve French 提交于
      With the need to discourage use of less secure dialect, SMB1 (CIFS),
      we temporarily upgraded the dialect to SMB3 in 4.13, but since there
      are various servers which only support SMB2.1 (2.1 is more secure
      than CIFS/SMB1) but not optimal for a default dialect - add support
      for multidialect negotiation.  cifs.ko will now request SMB2.1
      or later (ie SMB2.1 or SMB3.0, SMB3.02) and the server will
      pick the latest most secure one it can support.
      
      In addition since we are sending multidialect negotiate, add
      support for secure negotiate to validate that a man in the
      middle didn't downgrade us.
      Signed-off-by: NSteve French <smfrench@gmail.com>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      CC: Stable <stable@vger.kernel.org> # 4.13+
      9764c02f
  18. 05 9月, 2017 1 次提交
    • S
      cifs: Check for timeout on Negotiate stage · 76e75270
      Samuel Cabrero 提交于
      Some servers seem to accept connections while booting but never send
      the SMBNegotiate response neither close the connection, causing all
      processes accessing the share hang on uninterruptible sleep state.
      
      This happens when the cifs_demultiplex_thread detects the server is
      unresponsive so releases the socket and start trying to reconnect.
      At some point, the faulty server will accept the socket and the TCP
      status will be set to NeedNegotiate. The first issued command accessing
      the share will start the negotiation (pid 5828 below), but the response
      will never arrive so other commands will be blocked waiting on the mutex
      (pid 55352).
      
      This patch checks for unresponsive servers also on the negotiate stage
      releasing the socket and reconnecting if the response is not received
      and checking again the tcp state when the mutex is acquired.
      
      PID: 55352  TASK: ffff880fd6cc02c0  CPU: 0   COMMAND: "ls"
       #0 [ffff880fd9add9f0] schedule at ffffffff81467eb9
       #1 [ffff880fd9addb38] __mutex_lock_slowpath at ffffffff81468fe0
       #2 [ffff880fd9addba8] mutex_lock at ffffffff81468b1a
       #3 [ffff880fd9addbc0] cifs_reconnect_tcon at ffffffffa042f905 [cifs]
       #4 [ffff880fd9addc60] smb_init at ffffffffa042faeb [cifs]
       #5 [ffff880fd9addca0] CIFSSMBQPathInfo at ffffffffa04360b5 [cifs]
       ....
      
      Which is waiting a mutex owned by:
      
      PID: 5828   TASK: ffff880fcc55e400  CPU: 0   COMMAND: "xxxx"
       #0 [ffff880fbfdc19b8] schedule at ffffffff81467eb9
       #1 [ffff880fbfdc1b00] wait_for_response at ffffffffa044f96d [cifs]
       #2 [ffff880fbfdc1b60] SendReceive at ffffffffa04505ce [cifs]
       #3 [ffff880fbfdc1bb0] CIFSSMBNegotiate at ffffffffa0438d79 [cifs]
       #4 [ffff880fbfdc1c50] cifs_negotiate_protocol at ffffffffa043b383 [cifs]
       #5 [ffff880fbfdc1c80] cifs_reconnect_tcon at ffffffffa042f911 [cifs]
       #6 [ffff880fbfdc1d20] smb_init at ffffffffa042faeb [cifs]
       #7 [ffff880fbfdc1d60] CIFSSMBQFSInfo at ffffffffa0434eb0 [cifs]
       ....
      Signed-off-by: NSamuel Cabrero <scabrero@suse.de>
      Reviewed-by: NAurélien Aptel <aaptel@suse.de>
      Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      76e75270
  19. 01 9月, 2017 1 次提交
  20. 09 7月, 2017 3 次提交
    • S
      [SMB3] Improve security, move default dialect to SMB3 from old CIFS · eef914a9
      Steve French 提交于
      Due to recent publicity about security vulnerabilities in the
      much older CIFS dialect, move the default dialect to the
      widely accepted (and quite secure) SMB3.0 dialect from the
      old default of the CIFS dialect.
      
      We do not want to be encouraging use of less secure dialects,
      and both Microsoft and CERT now strongly recommend not using the
      older CIFS dialect (SMB Security Best Practices
      "recommends disabling SMBv1").
      
      SMB3 is both secure and widely available: in Windows 8 and later,
      Samba and Macs.
      
      Users can still choose to explicitly mount with the less secure
      dialect (for old servers) by choosing "vers=1.0" on the cifs
      mount
      Signed-off-by: NSteve French <smfrench@gmail.com>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      eef914a9
    • S
      [SMB3] Remove ifdef since SMB3 (and later) now STRONGLY preferred · 2a38e120
      Steve French 提交于
      Remove the CONFIG_CIFS_SMB2 ifdef and Kconfig option since they
      must always be on now.
      
      For various security reasons, SMB3 and later are STRONGLY preferred
      over CIFS and older dialects, and SMB3 (and later) will now be
      the default dialects so we do not want to allow them to be
      ifdeffed out.
      
      In the longer term, we may be able to make older CIFS support
      disableable in Kconfig with a new set of #ifdef, but we always
      want SMB3 and later support enabled.
      Signed-off-by: NSteven French <smfrench@gmail.com>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      2a38e120
    • P
      CIFS: Reconnect expired SMB sessions · 511c54a2
      Pavel Shilovsky 提交于
      According to the MS-SMB2 spec (3.2.5.1.6) once the client receives
      STATUS_NETWORK_SESSION_EXPIRED error code from a server it should
      reconnect the current SMB session. Currently the client doesn't do
      that. This can result in subsequent client requests failing by
      the server. The patch adds an additional logic to the demultiplex
      thread to identify expired sessions and reconnect them.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NPavel Shilovsky <pshilov@microsoft.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      511c54a2
  21. 03 5月, 2017 1 次提交
  22. 28 4月, 2017 1 次提交
  23. 21 4月, 2017 1 次提交