Bug 13736 - cli_smb2_list() can fail initially on a connection due to insufficient credits
Summary: cli_smb2_list() can fail initially on a connection due to insufficient credits
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: libsmbclient (show other bugs)
Version: 4.9.0
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
Depends on:
Reported: 2019-01-08 20:48 UTC by Tim Beale
Modified: 2019-02-05 14:11 UTC (History)
1 user (show)

See Also:

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

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.
Comment 3 Karolin Seeger 2019-01-31 09:55:08 UTC
(In reply to Jeremy Allison from comment #2)
Pushed to autobuild-v4-{9,8}-test.
Comment 4 Karolin Seeger 2019-02-05 14:11:56 UTC
(In reply to Karolin Seeger from comment #3)
Pushed to both branches.
Closing out bug report.