Bug 13736 - cli_smb2_list() can fail initially on a connection due to insufficient credits
cli_smb2_list() can fail initially on a connection due to insufficient credits
Status: ASSIGNED
Product: Samba 4.1 and newer
Classification: Unclassified
Component: libsmbclient
4.9.0
All All
: P5 normal
: ---
Assigned To: Karolin Seeger
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2019-01-08 20:48 UTC by Tim Beale
Modified: 2019-01-16 20:56 UTC (History)
1 user (show)

See Also:


Attachments
git-am fix for 4.8.next, 4.9.next. (5.41 KB, patch)
2019-01-16 18:25 UTC, Jeremy Allison
timbeale: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Beale 2019-01-08 20:48:13 UTC
If cli_smb2_list() were one of the first operations performed on the SMBv2 connection, it would fail due to insufficient credits. Because the response buffer size is (potentially) so much larger (the max SMB transaction size), it requires more credits (128) compared with other SMB operations.
    
When talking to a samba DC, the connection credits seem to start off at 1, then increase by 32 for every SMB reply we receive back from the server. After cli_full_connection(), the connection has 65 credits. The cli_smb2_create_fnum() in cli_smb2_list() adds another 32 credits, but this is still less than the 128 that smb2cli_query_directory() requires.
    
This problem doesn't *normally* seem to happen for smbclient because the cli_cm_open() API it uses ends up sending more messages, and so the connection has more credits.

However, it may be worth backporting changes to improve this problem, just in case it could be seen with smbclient in certain configurations. And having a better error message if a client operation fails due to insufficient SMBv2 credits would definitely help diagnosing this problem, if it ever crops up in different circumstances.
Comment 1 Jeremy Allison 2019-01-16 18:25:22 UTC
Created attachment 14779 [details]
git-am fix for 4.8.next, 4.9.next.

Applies cleanly to 4.9.next, 4.8.next.
Comment 2 Jeremy Allison 2019-01-16 20:56:58 UTC
Re-assigning to Karolin for inclusion in 4.9.next, 4.8.next.