<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wireguard-linux/fs/cifs, branch jd/unified-crypt-queue</title>
<subtitle>WireGuard for the Linux kernel</subtitle>
<id>https://git.zx2c4.com/wireguard-linux/atom/fs/cifs?h=jd%2Funified-crypt-queue</id>
<link rel='self' href='https://git.zx2c4.com/wireguard-linux/atom/fs/cifs?h=jd%2Funified-crypt-queue'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/'/>
<updated>2020-04-10T18:32:32Z</updated>
<entry>
<title>smb3: enable swap on SMB3 mounts</title>
<updated>2020-04-10T18:32:32Z</updated>
<author>
<name>Steve French</name>
<email>stfrench@microsoft.com</email>
</author>
<published>2020-04-10T02:42:18Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=4e8aea30f7751ce7c4b158aa0c04e7744d281cc3'/>
<id>urn:sha1:4e8aea30f7751ce7c4b158aa0c04e7744d281cc3</id>
<content type='text'>
Add experimental support for allowing a swap file to be on an SMB3
mount.  There are use cases where swapping over a secure network
filesystem is preferable. In some cases there are no local
block devices large enough, and network block devices can be
hard to setup and secure.  And in some cases there are no
local block devices at all (e.g. with the recent addition of
remote boot over SMB3 mounts).

There are various enhancements that can be added later e.g.:
- doing a mandatory byte range lock over the swapfile (until
the Linux VFS is modified to notify the file system that an open
is for a swapfile, when the file can be opened "DENY_ALL" to prevent
others from opening it).
- pinning more buffers in the underlying transport to minimize memory
allocations in the TCP stack under the fs
- documenting how to create ACLs (on the server) to secure the
swapfile (or adding additional tools to cifs-utils to make it easier)

Signed-off-by: Steve French &lt;stfrench@microsoft.com&gt;
Acked-by: Pavel Shilovsky &lt;pshilov@microsoft.com&gt;
Reviewed-by: Ronnie Sahlberg &lt;lsahlber@redhat.com&gt;
</content>
</entry>
<entry>
<title>smb3: change noisy error message to FYI</title>
<updated>2020-04-09T18:28:24Z</updated>
<author>
<name>Steve French</name>
<email>stfrench@microsoft.com</email>
</author>
<published>2020-04-09T06:07:38Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=1dc94b7381bd5f71aa417487abaf3bd3d70938c4'/>
<id>urn:sha1:1dc94b7381bd5f71aa417487abaf3bd3d70938c4</id>
<content type='text'>
The noisy posix error message in readdir was supposed
to be an FYI (not enabled by default)
  CIFS VFS: XXX dev 66306, reparse 0, mode 755

Signed-off-by: Steve French &lt;stfrench@microsoft.com&gt;
Reviewed-by: Aurelien Aptel &lt;aaptel@suse.com&gt;
</content>
</entry>
<entry>
<title>smb3: smbdirect support can be configured by default</title>
<updated>2020-04-07T18:39:00Z</updated>
<author>
<name>Steve French</name>
<email>stfrench@microsoft.com</email>
</author>
<published>2020-04-07T15:23:27Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=2bcb4fd6ba9152c699d873ffa4593d5a4fe1f8d4'/>
<id>urn:sha1:2bcb4fd6ba9152c699d873ffa4593d5a4fe1f8d4</id>
<content type='text'>
smbdirect support (SMB3 over RDMA) should be enabled by
default in many configurations.

It is not experimental and is stable enough and has enough
performance benefits to recommend that it be configured by
default.  Change the  "If unsure N" to "If unsure Y" in
the description of the configuration parameter.

Acked-by: Aurelien Aptel &lt;aaptel@suse.com&gt;
Reviewed-by: Long Li &lt;longli@microsoft.com&gt;
Signed-off-by: Steve French &lt;stfrench@microsoft.com&gt;
</content>
</entry>
<entry>
<title>cifs: smbd: Do not schedule work to send immediate packet on every receive</title>
<updated>2020-04-07T17:41:16Z</updated>
<author>
<name>Long Li</name>
<email>longli@microsoft.com</email>
</author>
<published>2020-04-01T03:59:23Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=044b541c11fdb7f51e5177a32ab99aae43b285ef'/>
<id>urn:sha1:044b541c11fdb7f51e5177a32ab99aae43b285ef</id>
<content type='text'>
Immediate packets should only be sent to peer when there are new
receive credits made available. New credits show up on freeing
receive buffer, not on receiving data.

Fix this by avoid unnenecessary work schedules.

Signed-off-by: Long Li &lt;longli@microsoft.com&gt;
Signed-off-by: Steve French &lt;stfrench@microsoft.com&gt;
</content>
</entry>
<entry>
<title>cifs: smbd: Properly process errors on ib_post_send</title>
<updated>2020-04-07T17:41:16Z</updated>
<author>
<name>Long Li</name>
<email>longli@microsoft.com</email>
</author>
<published>2020-04-02T20:56:48Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=f1b7b862bf79dc9bf29dd59654c5d765b572411e'/>
<id>urn:sha1:f1b7b862bf79dc9bf29dd59654c5d765b572411e</id>
<content type='text'>
When processing errors from ib_post_send(), the transport state needs to be
rolled back to the condition before the error.

Refactor the old code to make it easy to roll back on IB errors, and fix this.

Signed-off-by: Long Li &lt;longli@microsoft.com&gt;
Signed-off-by: Steve French &lt;stfrench@microsoft.com&gt;
</content>
</entry>
<entry>
<title>cifs: Allocate crypto structures on the fly for calculating signatures of incoming packets</title>
<updated>2020-04-07T17:41:16Z</updated>
<author>
<name>Long Li</name>
<email>longli@microsoft.com</email>
</author>
<published>2020-03-31T23:21:43Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=eda1c54f148a86f5e64d4d1d3f62d9ea7f94c17e'/>
<id>urn:sha1:eda1c54f148a86f5e64d4d1d3f62d9ea7f94c17e</id>
<content type='text'>
CIFS uses pre-allocated crypto structures to calculate signatures for both
incoming and outgoing packets. In this way it doesn't need to allocate crypto
structures for every packet, but it requires a lock to prevent concurrent
access to crypto structures.

Remove the lock by allocating crypto structures on the fly for
incoming packets. At the same time, we can still use pre-allocated crypto
structures for outgoing packets, as they are already protected by transport
lock srv_mutex.

Signed-off-by: Long Li &lt;longli@microsoft.com&gt;
Signed-off-by: Steve French &lt;stfrench@microsoft.com&gt;
</content>
</entry>
<entry>
<title>cifs: smbd: Update receive credits before sending and deal with credits roll back on failure before sending</title>
<updated>2020-04-07T17:41:16Z</updated>
<author>
<name>Long Li</name>
<email>longli@microsoft.com</email>
</author>
<published>2020-04-02T20:42:06Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=d4e5160d1a0bf089af41c21f273a507e6ace45cd'/>
<id>urn:sha1:d4e5160d1a0bf089af41c21f273a507e6ace45cd</id>
<content type='text'>
Recevie credits should be updated before sending the packet, not
before a work is scheduled. Also, the value needs roll back if
something fails and cannot send.

Signed-off-by: Long Li &lt;longli@microsoft.com&gt;
Reported-by: kbuild test robot &lt;lkp@intel.com&gt;
Signed-off-by: Steve French &lt;stfrench@microsoft.com&gt;
</content>
</entry>
<entry>
<title>cifs: smbd: Check send queue size before posting a send</title>
<updated>2020-04-07T17:41:16Z</updated>
<author>
<name>Long Li</name>
<email>longli@microsoft.com</email>
</author>
<published>2020-03-30T18:04:07Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=3ffbe78aff93586d3e09e8af4501c563ab367c75'/>
<id>urn:sha1:3ffbe78aff93586d3e09e8af4501c563ab367c75</id>
<content type='text'>
Sometimes the remote peer may return more send credits than the send queue
depth. If all the send credits are used to post senasd, we may overflow the
send queue.

Fix this by checking the send queue size before posting a send.

Signed-off-by: Long Li &lt;longli@microsoft.com&gt;
Signed-off-by: Steve French &lt;stfrench@microsoft.com&gt;
</content>
</entry>
<entry>
<title>cifs: smbd: Merge code to track pending packets</title>
<updated>2020-04-07T17:41:16Z</updated>
<author>
<name>Long Li</name>
<email>longli@microsoft.com</email>
</author>
<published>2020-03-30T18:04:06Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=072a14ec6386829314ca96c725175ac1631360da'/>
<id>urn:sha1:072a14ec6386829314ca96c725175ac1631360da</id>
<content type='text'>
As an optimization, SMBD tries to track two types of packets: packets with
payload and without payload. There is no obvious benefit or performance gain
to separately track two types of packets.

Just treat them as pending packets and merge the tracking code.

Signed-off-by: Long Li &lt;longli@microsoft.com&gt;
Signed-off-by: Steve French &lt;stfrench@microsoft.com&gt;
</content>
</entry>
<entry>
<title>cifs: ignore cached share root handle closing errors</title>
<updated>2020-04-07T17:40:40Z</updated>
<author>
<name>Aurelien Aptel</name>
<email>aaptel@suse.com</email>
</author>
<published>2020-04-07T09:49:55Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=e79b0332ae06b4895dcecddf4bbc5d3917e9383c'/>
<id>urn:sha1:e79b0332ae06b4895dcecddf4bbc5d3917e9383c</id>
<content type='text'>
Fix tcon use-after-free and NULL ptr deref.

Customer system crashes with the following kernel log:

[462233.169868] CIFS VFS: Cancelling wait for mid 4894753 cmd: 14       =&gt; a QUERY DIR
[462233.228045] CIFS VFS: cifs_put_smb_ses: Session Logoff failure rc=-4
[462233.305922] CIFS VFS: cifs_put_smb_ses: Session Logoff failure rc=-4
[462233.306205] CIFS VFS: cifs_put_smb_ses: Session Logoff failure rc=-4
[462233.347060] CIFS VFS: cifs_put_smb_ses: Session Logoff failure rc=-4
[462233.347107] CIFS VFS: Close unmatched open
[462233.347113] BUG: unable to handle kernel NULL pointer dereference at 0000000000000038
...
    [exception RIP: cifs_put_tcon+0xa0] (this is doing tcon-&gt;ses-&gt;server)
 #6 [...] smb2_cancelled_close_fid at ... [cifs]
 #7 [...] process_one_work at ...
 #8 [...] worker_thread at ...
 #9 [...] kthread at ...

The most likely explanation we have is:

* When we put the last reference of a tcon (refcount=0), we close the
  cached share root handle.
* If closing a handle is interrupted, SMB2_close() will
  queue a SMB2_close() in a work thread.
* The queued object keeps a tcon ref so we bump the tcon
  refcount, jumping from 0 to 1.
* We reach the end of cifs_put_tcon(), we free the tcon object despite
  it now having a refcount of 1.
* The queued work now runs, but the tcon, ses &amp; server was freed in
  the meantime resulting in a crash.

THREAD 1
========
cifs_put_tcon                 =&gt; tcon refcount reach 0
  SMB2_tdis
   close_shroot_lease
    close_shroot_lease_locked =&gt; if cached root has lease &amp;&amp; refcount = 0
     smb2_close_cached_fid    =&gt; if cached root valid
      SMB2_close              =&gt; retry close in a thread if interrupted
       smb2_handle_cancelled_close
        __smb2_handle_cancelled_close    =&gt; !! tcon refcount bump 0 =&gt; 1 !!
         INIT_WORK(&amp;cancelled-&gt;work, smb2_cancelled_close_fid);
         queue_work(cifsiod_wq, &amp;cancelled-&gt;work) =&gt; queue work
 tconInfoFree(tcon);    ==&gt; freed!
 cifs_put_smb_ses(ses); ==&gt; freed!

THREAD 2 (workqueue)
========
smb2_cancelled_close_fid
  SMB2_close(0, cancelled-&gt;tcon, ...); =&gt; use-after-free of tcon
  cifs_put_tcon(cancelled-&gt;tcon);      =&gt; tcon refcount reach 0 second time
  *CRASH*

Fixes: d9191319358d ("CIFS: Close cached root handle only if it has a lease")
Signed-off-by: Aurelien Aptel &lt;aaptel@suse.com&gt;
Signed-off-by: Steve French &lt;stfrench@microsoft.com&gt;
Reviewed-by: Pavel Shilovsky &lt;pshilov@microsoft.com&gt;
</content>
</entry>
</feed>
