Bug 14161 - cli_qpathinfo2()/cli_qpathinfo3() are returning bogus inode numbers for SMB1 - actually is returning the EA size field from the server.
Summary: cli_qpathinfo2()/cli_qpathinfo3() are returning bogus inode numbers for SMB1 ...
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: libsmbclient (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-17 00:06 UTC by Jeremy Allison
Modified: 2019-11-05 09:39 UTC (History)
2 users (show)

See Also:


Attachments
git-am fix for 4.11.next, 4.10.next. (5.12 KB, patch)
2019-10-18 22:31 UTC, Jeremy Allison
asn: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Allison 2019-10-17 00:06:11 UTC
See discussion in:

https://gitlab.com/samba-team/samba/merge_requests/302

(added here for context):

Currently for old SMB1 servers, if we call smbc_stat() on an SMB1 server, under the covers it calls SMBC_getatr() -> cli_qpathinfo2() which calls an info level of SMB_QUERY_FILE_ALL_INFO. This info level doesn't return the file_id, but we have a bug in which cli_qpathinfo2() returns the data at offset 64 in the blob returned as the ino number. In actual fact this data is set by the server to be the EA size.

As most Windows servers don't have EA's set on files (and Samba servers filter out our own internal EA's that we use for DOS attributes and ACLs and don't count them for sizing purposes), this means the EA size is usually zero - so we end up returning an ino of zero from cli_qpathinfo2(), which means SMBC_getatr() returns an ino of zero, which means SMBC_stat_ctx() returns an ino of zero, which means the setup_stat() function generates ino using the generate_inode() function (which uses str_checksum(name)) - which means the ino values returned for SMB1 are at least consistent.

Phew. That took a long time to track down.

I'm going to log a bug to remove the ino return from cli_qpathinfo2() though and make sure it always returns zero instead of the EA size field, that's clearly incorrect.

Long story is - Puran's patch to add readdirplus2() should actually work as-is for both SMB1 servers (always returns generated ino, so long as EA size is zero) and for SMB2 servers (returns server correct ino).
Comment 1 Jeremy Allison 2019-10-17 00:17:36 UTC
Note that for SMB2, cli_pathinfo2() ->
Comment 2 Jeremy Allison 2019-10-17 00:18:36 UTC
Note that for SMB2, cli_pathinfo2() and cli_pathinfo3() both call cli_smb2_qpathinfo2(), which *does* correctly return server inode numbers.
Comment 3 Jeremy Allison 2019-10-18 22:31:44 UTC
Created attachment 15557 [details]
git-am fix for 4.11.next, 4.10.next.

Cherry-picked from master. Applies cleanly to 4.11.next, 4.10.next.
Comment 4 Andreas Schneider 2019-10-24 13:04:32 UTC
Karolin, could you please apply the patch to the relevant branches? Thanks!
Comment 5 Karolin Seeger 2019-11-05 09:39:02 UTC
(In reply to Andreas Schneider from comment #4)
Pushed to v4-{11,10}-test.
Closing out bug report.

Thanks!