Bug 11114 - Wrong return code on bad oplock break request
Summary: Wrong return code on bad oplock break request
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.2.0rc4
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-24 18:05 UTC by Steve French
Modified: 2015-02-25 22:03 UTC (History)
1 user (show)

See Also:


Attachments
wireshark trace to Samba 4.2-rc4 of the problem (test s743) (5.46 KB, application/x-pcapng)
2015-02-24 18:07 UTC, Steve French
no flags Details
wireshark trace of same test working to Windows 8.1 server (tes s743) (8.31 KB, application/octet-stream)
2015-02-24 18:10 UTC, Steve French
no flags Details
wireshark trace to Samba 4.2-rc4 of the problem (oplock test s0) (6.51 KB, application/x-pcapng)
2015-02-24 18:23 UTC, Steve French
no flags Details
wireshark trace of same test working to Windows 8.1 server (oplock test s0) (8.22 KB, application/octet-stream)
2015-02-24 18:26 UTC, Steve French
no flags Details
wireshark trace to Samba 4.2-rc4 of the problem (oplock test s276) (6.53 KB, application/x-pcapng)
2015-02-24 18:31 UTC, Steve French
no flags Details
wireshark trace of same test working to Windows 8.1 server (oplock test s276) (9.68 KB, application/octet-stream)
2015-02-24 18:35 UTC, Steve French
no flags Details
wireshark trace to Samba 4.2-rc4 of the problem (oplock test s344) (6.51 KB, application/x-pcapng)
2015-02-24 18:43 UTC, Steve French
no flags Details
wireshark trace of same test working to Windows 8.1 server (oplock test s344) (10.41 KB, application/octet-stream)
2015-02-24 18:50 UTC, Steve French
no flags Details
wireshark trace to Samba 4.2-rc4 of the problem (oplock test s385) (6.51 KB, application/x-pcapng)
2015-02-24 20:56 UTC, Steve French
no flags Details
wireshark trace of same test working to Windows 8.1 server (oplock test s385) (11.43 KB, application/octet-stream)
2015-02-24 20:59 UTC, Steve French
no flags Details
wireshark trace to Samba 4.2-rc4 of the problem (oplock test s409) (6.53 KB, application/x-pcapng)
2015-02-24 21:05 UTC, Steve French
no flags Details
wireshark trace of same test working to Windows 8.1 server (oplock test s409) (11.69 KB, application/octet-stream)
2015-02-24 21:10 UTC, Steve French
no flags Details
wireshark trace to Samba 4.2-rc4 of the problem (oplock test s977) (6.53 KB, application/x-pcapng)
2015-02-25 01:16 UTC, Steve French
no flags Details
wireshark trace of same test working to Windows 8.1 server (oplock test s977) (9.95 KB, application/octet-stream)
2015-02-25 01:20 UTC, Steve French
no flags Details
trivial patch to correct rc mapping - fixes three of the test cases (276, 743, 977) (617 bytes, patch)
2015-02-25 06:23 UTC, Steve French
no flags Details
trivial patch to correct rc mapping - fixes the 15 oplock test cases (1.07 KB, patch)
2015-02-25 08:08 UTC, Steve French
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steve French 2015-02-24 18:05:31 UTC
The Microsoft OplockOnShareWithoutForceLevel2OrSOFSTestCaseS743 test case shows a problem with Samba returning the wrong return code on an SMB2 oplock break (INVALID_PARAMETER should be returned instead of INVALID_OPLOCK_PROTOCOL). Also see attached trace to Windows 8.1

The test log below explains it:

2015-02-24 11:56:38.850 [Comment] executing step 'call OplockBreakAcknowledgementRequest(VolatilePortionFound,PersistentMatchesDurableFileId,OPLOCK_LEVEL_LEASE)'
2015-02-24 11:56:38.907 [Comment] reaching state 'S778'
2015-02-24 11:56:38.907 [Comment] checking step 'return OplockBreakAcknowledgementRequest'
2015-02-24 11:56:38.917 [Comment] reaching state 'S779'
2015-02-24 11:56:38.924 [CheckFailed] Assert.IsTrue failed. expected matching event, found 'event OplockBreakResponse(STATUS_INVALID_OPLOCK_PROTOCOL,OPLOCK_LEVEL_NONE,OPLOCK_LEVEL_II)'. Diagnosis:
  1. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_PARAMETER,oplockLevel1,OPLOCK_LEVEL_BATCH)'
    assert  failed: expected 'STATUS_INVALID_PARAMETER', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S779)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If the OplockLevel in the acknowledgment is SMB2_OPLOCK_LEVEL_LEASE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_PARAMETER."
  2. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_PARAMETER,oplockLevel1,OPLOCK_LEVEL_II)'
    assert  failed: expected 'STATUS_INVALID_PARAMETER', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S779)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If the OplockLevel in the acknowledgment is SMB2_OPLOCK_LEVEL_LEASE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_PARAMETER."

2015-02-24 11:56:38.954 [Comment]    at Microsoft.SpecExplorer.Runtime.Testing.DefaultTestManager.ExpectEvent(TimeSpan timeOut, Boolean failIfNone, ExpectedEvent[] expected)

2015-02-24 11:56:39.049 [TestFailed] Microsoft.Protocols.TestSuites.FileSharing.SMB2Model.TestSuite.OplockOnShareWithoutForceLevel2OrSOFSTestCase.OplockOnShareWithoutForceLevel2OrSOFSTestCaseS743
Comment 1 Steve French 2015-02-24 18:07:10 UTC
Created attachment 10770 [details]
wireshark trace to Samba 4.2-rc4 of the problem (test s743)
Comment 2 Steve French 2015-02-24 18:10:07 UTC
Created attachment 10771 [details]
wireshark trace of same test working to Windows 8.1 server (tes s743)
Comment 3 Steve French 2015-02-24 18:21:12 UTC
A second related bug is shown with Oplock test 0 (OplockOnShareWithoutForceLevel2OrSOFSTestCaseS0) in which INVALID_OPLOCK_PROTOCOL instead of INVALID_DEVICE_STATE is returned.  See log below and the other two attached wireshark traces.

2015-02-24 12:16:25.510 [Comment] executing step 'call OplockBreakAcknowledgementRequest(VolatilePortionFound,PersistentMatchesDurableFileId,OPLOCK_LEVEL_NONE)'
2015-02-24 12:16:25.562 [Comment] reaching state 'S11'
2015-02-24 12:16:25.562 [Comment] checking step 'return OplockBreakAcknowledgementRequest'
2015-02-24 12:16:25.564 [Comment] reaching state 'S12'
2015-02-24 12:16:25.574 [CheckFailed] Assert.IsTrue failed. expected matching event, found 'event OplockBreakResponse(STATUS_INVALID_OPLOCK_PROTOCOL,OPLOCK_LEVEL_NONE,OPLOCK_LEVEL_BATCH)'. Diagnosis:
  1. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_DEVICE_STATE,oplockLevel1,OPLOCK_LEVEL_II)'
    assert  failed: expected 'STATUS_INVALID_DEVICE_STATE', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S12)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If OplockLevel is SMB2_OPLOCK_LEVEL_II or SMB2_OPLOCK_LEVEL_NONE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_DEVICE_STATE."
  2. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_DEVICE_STATE,oplockLevel1,OPLOCK_LEVEL_BATCH)'
    assert  failed: expected 'STATUS_INVALID_DEVICE_STATE', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S12)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If OplockLevel is SMB2_OPLOCK_LEVEL_II or SMB2_OPLOCK_LEVEL_NONE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_DEVICE_STATE."

2015-02-24 12:16:25.586 [Comment]    at Microsoft.SpecExplorer.Runtime.Testing.DefaultTestManager.ExpectEvent(TimeSpan timeOut, Boolean failIfNone, ExpectedEvent[] expected)

2015-02-24 12:16:25.666 [TestFailed] Microsoft.Protocols.TestSuites.FileSharing.SMB2Model.TestSuite.OplockOnShareWithoutForceLevel2OrSOFSTestCase.OplockOnShareWithoutForceLevel2OrSOFSTestCaseS0
Comment 4 Steve French 2015-02-24 18:23:53 UTC
Created attachment 10772 [details]
wireshark trace to Samba 4.2-rc4 of the problem (oplock test s0)
Comment 5 Steve French 2015-02-24 18:26:19 UTC
Created attachment 10773 [details]
wireshark trace of same test working to Windows 8.1 server (oplock test s0)
Comment 6 Steve French 2015-02-24 18:29:54 UTC
Similar problem with oplock test case S276

2015-02-24 12:27:48.299 [Comment] executing step 'call OplockBreakAcknowledgementRequest(VolatilePortionFound,PersistentMatchesDurableFileId,OPLOCK_LEVEL_LEASE)'
2015-02-24 12:27:48.354 [Comment] reaching state 'S293'
2015-02-24 12:27:48.354 [Comment] checking step 'return OplockBreakAcknowledgementRequest'
2015-02-24 12:27:48.357 [Comment] reaching state 'S294'
2015-02-24 12:27:48.371 [CheckFailed] Assert.IsTrue failed. expected matching event, found 'event OplockBreakResponse(STATUS_INVALID_OPLOCK_PROTOCOL,OPLOCK_LEVEL_NONE,OPLOCK_LEVEL_II)'. Diagnosis:
  1. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_PARAMETER,oplockLevel1,OPLOCK_LEVEL_BATCH)'
    assert  failed: expected 'STATUS_INVALID_PARAMETER', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S294)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If the OplockLevel in the acknowledgment is SMB2_OPLOCK_LEVEL_LEASE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_PARAMETER."
  2. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_PARAMETER,oplockLevel1,OPLOCK_LEVEL_II)'
    assert  failed: expected 'STATUS_INVALID_PARAMETER', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S294)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If the OplockLevel in the acknowledgment is SMB2_OPLOCK_LEVEL_LEASE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_PARAMETER."

2015-02-24 12:27:48.386 [Comment]    at Microsoft.SpecExplorer.Runtime.Testing.DefaultTestManager.ExpectEvent(TimeSpan timeOut, Boolean failIfNone, ExpectedEvent[] expected)

2015-02-24 12:27:48.468 [TestFailed] Microsoft.Protocols.TestSuites.FileSharing.SMB2Model.TestSuite.OplockOnShareWithoutForceLevel2OrSOFSTestCase.OplockOnShareWithoutForceLevel2OrSOFSTestCaseS276
Comment 7 Steve French 2015-02-24 18:31:03 UTC
Created attachment 10774 [details]
wireshark trace to Samba 4.2-rc4 of the problem (oplock test s276)
Comment 8 Steve French 2015-02-24 18:35:02 UTC
Created attachment 10775 [details]
wireshark trace of same test working to Windows 8.1 server (oplock test s276)
Comment 9 Steve French 2015-02-24 18:42:31 UTC
Similar problem found again in test s344, INVALID_DEVICE_STATE instead of INVALID_OPLOCK_PROTOCOL should be returned.

2015-02-24 12:39:14.267 [Checkpoint] "[TestInfo] Open.OplockLevel is set to SMB2_OPLOCK_LEVEL_NONE."
2015-02-24 12:39:14.268 [Checkpoint] "[TestInfo] Open.OplockState is set to None."
2015-02-24 12:39:14.269 [Checkpoint] "[TestInfo] Open.OplockState is set to Held."
2015-02-24 12:39:14.270 [Comment] Unbinding variable 'c1'
2015-02-24 12:39:14.273 [Comment] Unbinding variable 'v2'
2015-02-24 12:39:14.279 [Comment] reaching state 'S370'
2015-02-24 12:39:14.387 [Comment] executing step 'call OplockBreakAcknowledgementRequest(VolatilePortionFound,PersistentMatchesDurableFileId,OPLOCK_LEVEL_NONE)'
2015-02-24 12:39:14.435 [Comment] reaching state 'S374'
2015-02-24 12:39:14.435 [Comment] checking step 'return OplockBreakAcknowledgementRequest'
2015-02-24 12:39:14.437 [Comment] reaching state 'S375'
2015-02-24 12:39:14.448 [CheckFailed] Assert.IsTrue failed. expected matching event, found 'event OplockBreakResponse(STATUS_INVALID_OPLOCK_PROTOCOL,OPLOCK_LEVEL_NONE,OPLOCK_LEVEL_BATCH)'. Diagnosis:
  1. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_DEVICE_STATE,oplockLevel1,OPLOCK_LEVEL_BATCH)'
    assert  failed: expected 'STATUS_INVALID_DEVICE_STATE', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S375)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If OplockLevel is SMB2_OPLOCK_LEVEL_II or SMB2_OPLOCK_LEVEL_NONE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_DEVICE_STATE."
  2. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_DEVICE_STATE,oplockLevel1,OPLOCK_LEVEL_II)'
    assert  failed: expected 'STATUS_INVALID_DEVICE_STATE', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S375)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If OplockLevel is SMB2_OPLOCK_LEVEL_II or SMB2_OPLOCK_LEVEL_NONE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_DEVICE_STATE."

2015-02-24 12:39:14.461 [Comment]    at Microsoft.SpecExplorer.Runtime.Testing.DefaultTestManager.ExpectEvent(TimeSpan timeOut, Boolean failIfNone, ExpectedEvent[] expected)

2015-02-24 12:39:14.535 [TestFailed] Microsoft.Protocols.TestSuites.FileSharing.SMB2Model.TestSuite.OplockOnShareWithoutForceLevel2OrSOFSTestCase.OplockOnShareWithoutForceLevel2OrSOFSTestCaseS344
Comment 10 Steve French 2015-02-24 18:43:57 UTC
Created attachment 10776 [details]
wireshark trace to Samba 4.2-rc4 of the problem (oplock test s344)
Comment 11 Steve French 2015-02-24 18:49:36 UTC
(In reply to Steve French from comment #9)
Actually this part does not look like the same problem - Windows trace doesn't return an error.  Samba seems to be handling this test 344 more differently (not just a return code mismatch in this case.
Comment 12 Steve French 2015-02-24 18:50:07 UTC
Created attachment 10777 [details]
wireshark trace of same test working to Windows 8.1 server (oplock test s344)
Comment 13 Steve French 2015-02-24 20:54:28 UTC
Similarly for oplock test 384 Samba 4.2 is incorrectly returning INVALID_OPLOCK_PROTOCOL instead of INVALID_DEVICE_STATE

2015-02-24 14:48:00.576 [Comment] executing step 'call OplockBreakAcknowledgementRequest(VolatilePortionFound,PersistentMatchesDurableFileId,OPLOCK_LEVEL_NONE)'
2015-02-24 14:48:00.625 [Comment] reaching state 'S374'
2015-02-24 14:48:00.625 [Comment] checking step 'return OplockBreakAcknowledgementRequest'
2015-02-24 14:48:00.627 [Comment] reaching state 'S375'
2015-02-24 14:48:00.637 [CheckFailed] Assert.IsTrue failed. expected matching event, found 'event OplockBreakResponse(STATUS_INVALID_OPLOCK_PROTOCOL,OPLOCK_LEVEL_NONE,OPLOCK_LEVEL_II)'. Diagnosis:
  1. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_DEVICE_STATE,oplockLevel1,OPLOCK_LEVEL_BATCH)'
    assert  failed: expected 'STATUS_INVALID_DEVICE_STATE', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S375)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If OplockLevel is SMB2_OPLOCK_LEVEL_II or SMB2_OPLOCK_LEVEL_NONE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_DEVICE_STATE."
  2. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_DEVICE_STATE,oplockLevel1,OPLOCK_LEVEL_II)'
    assert  failed: expected 'STATUS_INVALID_DEVICE_STATE', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S375)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If OplockLevel is SMB2_OPLOCK_LEVEL_II or SMB2_OPLOCK_LEVEL_NONE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_DEVICE_STATE."

2015-02-24 14:48:00.650 [Comment]    at Microsoft.SpecExplorer.Runtime.Testing.DefaultTestManager.ExpectEvent(TimeSpan timeOut, Boolean failIfNone, ExpectedEvent[] expected)

2015-02-24 14:48:00.725 [TestFailed] Microsoft.Protocols.TestSuites.FileSharing.SMB2Model.TestSuite.OplockOnShareWithoutForceLevel2OrSOFSTestCase.OplockOnShareWithoutForceLevel2OrSOFSTestCaseS385
Comment 14 Steve French 2015-02-24 20:55:29 UTC
(In reply to Steve French from comment #13)
This is actually Microsoft oplock test 385 not test 384
Comment 15 Steve French 2015-02-24 20:56:35 UTC
Created attachment 10779 [details]
wireshark trace to Samba 4.2-rc4 of the problem (oplock test s385)
Comment 16 Steve French 2015-02-24 20:59:26 UTC
Created attachment 10780 [details]
wireshark trace of same test working to Windows 8.1 server (oplock test s385)
Comment 17 Steve French 2015-02-24 21:05:03 UTC
And a similar rc problem again with oplock test 409 
expected 'STATUS_INVALID_DEVICE_STATE', but got 'STATUS_INVALID_OPLOCK_PROTOCOL' from Samba instead


2015-02-24 15:01:16.722 [Comment] executing step 'call OplockBreakAcknowledgementRequest(VolatilePortionFound,PersistentMatchesDurableFileId,OPLOCK_LEVEL_NONE)'
2015-02-24 15:01:16.770 [Comment] reaching state 'S374'
2015-02-24 15:01:16.770 [Comment] checking step 'return OplockBreakAcknowledgementRequest'
2015-02-24 15:01:16.772 [Comment] reaching state 'S375'
2015-02-24 15:01:16.785 [CheckFailed] Assert.IsTrue failed. expected matching event, found 'event OplockBreakResponse(STATUS_INVALID_OPLOCK_PROTOCOL,OPLOCK_LEVEL_NONE,OPLOCK_LEVEL_BATCH)'. Diagnosis:
  1. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_DEVICE_STATE,oplockLevel1,OPLOCK_LEVEL_BATCH)'
    assert  failed: expected 'STATUS_INVALID_DEVICE_STATE', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S375)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If OplockLevel is SMB2_OPLOCK_LEVEL_II or SMB2_OPLOCK_LEVEL_NONE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_DEVICE_STATE."
  2. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_DEVICE_STATE,oplockLevel1,OPLOCK_LEVEL_II)'
    assert  failed: expected 'STATUS_INVALID_DEVICE_STATE', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S375)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If OplockLevel is SMB2_OPLOCK_LEVEL_II or SMB2_OPLOCK_LEVEL_NONE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_DEVICE_STATE."

2015-02-24 15:01:16.799 [Comment]    at Microsoft.SpecExplorer.Runtime.Testing.DefaultTestManager.ExpectEvent(TimeSpan timeOut, Boolean failIfNone, ExpectedEvent[] expected)

2015-02-24 15:01:16.873 [TestFailed] Microsoft.Protocols.TestSuites.FileSharing.SMB2Model.TestSuite.OplockOnShareWithoutForceLevel2OrSOFSTestCase.OplockOnShareWithoutForceLevel2OrSOFSTestCaseS409
Comment 18 Steve French 2015-02-24 21:05:42 UTC
Created attachment 10781 [details]
wireshark trace to Samba 4.2-rc4 of the problem (oplock test s409)
Comment 19 Volker Lendecke 2015-02-24 21:08:19 UTC
How relevant is this really? I've seen this in Redmond already, but I came to the conclusion that this is a broken client. How many clients out there depend on exact 1:1 fidelity when they send broken request? What real clients out there show this broken behaviour anyway?
Comment 20 Steve French 2015-02-24 21:10:27 UTC
Created attachment 10782 [details]
wireshark trace of same test working to Windows 8.1 server (oplock test s409)
Comment 21 Steve French 2015-02-24 21:15:53 UTC
(In reply to Volker Lendecke from comment #19)
That is a good question but basically there are two reasons to match Windows behavior here:

- these functional test cases have value, and not being able to run the oplock subcategory cuts 20 or so useful subtests (out of the 52 applicable oplock tests in the category) 
- in complex cases where we don't agree on whether there is an oplock (network or cluster corner cases)
- more importantly, some of these tests show more than a difference between INVALID_OPLOCK_PROTOCOL return code and INVALID_PARAMETER.  At least two of them don't show errors (not even returning INVALID_PARAMETER) in the Windows case.

By the way we could run 285 more oplock tests that are skipped now if I knew how to set oplock configuration more granularly (for the ForceLevel2 oplock cases which are probably more interesting to you).
Comment 22 Steve French 2015-02-24 21:21:11 UTC
(In reply to Steve French from comment #21)
To be more precise - I think the incorrect rc gets in the way of noticing more important problems, so cleaning up those few places.

I only saw the one place where the error mapping seems to be confusing things at least w.r.t. INVALID_OPLOCK_PROTOCOL (line 78 of smbd/smb2_break.c
Comment 23 Steve French 2015-02-24 21:31:04 UTC
MS-SMB2 describes the difference between the two return codes (INVALID_DEVICE_STATE and INVALID_OPLOCK_PROTOCOL) in MS-SMB2 page 330

Basically return INVALID_OPLOCK_PROTOCOL for the oplock breaking subcases when
Open.OplockLevel is SMB2_OPLOCK_LEVEL_EXCLUSIVE or SMB2_OPLOCK_LEVEL_BATCH, and if OplockLevel is not SMB2_OPLOCK_LEVEL_II or SMB2_OPLOCK_LEVEL_NONE

or

Open.OplockLevel is SMB2_OPLOCK_LEVEL_II, and if OplockLevel is not
SMB2_OPLOCK_LEVEL_NONE

but e.g. if oplock level is none and not breaking an oplock then return INVALID_DEVICE_STATE

Kindof makes sense
Comment 24 Steve French 2015-02-25 01:15:09 UTC
Test 977 fails in similar way

2015-02-24 19:08:54.994 [Comment] executing step 'call OplockBreakAcknowledgementRequest(VolatilePortionFound,PersistentMatchesDurableFileId,OPLOCK_LEVEL_LEASE)'
2015-02-24 19:08:55.043 [Comment] reaching state 'S996'
2015-02-24 19:08:55.043 [Comment] checking step 'return OplockBreakAcknowledgementRequest'
2015-02-24 19:08:55.045 [Comment] reaching state 'S997'
2015-02-24 19:08:55.057 [CheckFailed] Assert.IsTrue failed. expected matching event, found 'event OplockBreakResponse(STATUS_INVALID_OPLOCK_PROTOCOL,OPLOCK_LEVEL_NONE,OPLOCK_LEVEL_II)'. Diagnosis:
  1. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_PARAMETER,oplockLevel1,OPLOCK_LEVEL_II)'
    assert  failed: expected 'STATUS_INVALID_PARAMETER', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S997)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If the OplockLevel in the acknowledgment is SMB2_OPLOCK_LEVEL_LEASE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_PARAMETER."
  2. event parameters do not match
    comment: checking step 'event OplockBreakResponse(STATUS_INVALID_PARAMETER,oplockLevel1,OPLOCK_LEVEL_BATCH)'
    assert  failed: expected 'STATUS_INVALID_PARAMETER', actual 'STATUS_INVALID_OPLOCK_PROTOCOL' (status of OplockBreakResponse, state S997)
    comment: This step would have covered "[MS-SMB2] 3.3.5.22.1   Processing an Oplock Acknowledgment", "[MS-SMB2] If the OplockLevel in the acknowledgment is SMB2_OPLOCK_LEVEL_LEASE, the server MUST do the following:", "[TestInfo] Open.OplockState is Held.", "[MS-SMB2] If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_PARAMETER."

2015-02-24 19:08:55.070 [Comment]    at Microsoft.SpecExplorer.Runtime.Testing.DefaultTestManager.ExpectEvent(TimeSpan timeOut, Boolean failIfNone, ExpectedEvent[] expected)

2015-02-24 19:08:55.148 [TestFailed] Microsoft.Protocols.TestSuites.FileSharing.SMB2Model.TestSuite.OplockOnShareWithoutForceLevel2OrSOFSTestCase.OplockOnShareWithoutForceLevel2OrSOFSTestCaseS977
Comment 25 Steve French 2015-02-25 01:16:45 UTC
Created attachment 10783 [details]
wireshark trace to Samba 4.2-rc4 of the problem (oplock test s977)
Comment 26 Steve French 2015-02-25 01:20:51 UTC
Created attachment 10784 [details]
wireshark trace of same test working to Windows 8.1 server (oplock test s977)

this one looks like a simple rc mapping change
Comment 27 Steve French 2015-02-25 06:23:53 UTC
Created attachment 10785 [details]
trivial patch to correct rc mapping - fixes three of the test cases (276, 743, 977)

This is a trivial fix to address the rc mapping requirement in 3.3.5.22.1 of MS-SMB2

"If the OplockLevel in the acknowledgment is SMB2_OPLOCK_LEVEL_LEASE, the server MUST do the following:  If Open.OplockState is not Breaking, stop processing the acknowledgment, and send an error response with STATUS_INVALID_PARAMETER." 

(if EXCLUSIVE or BATCH and state is not breaking then you would return INVALID_OPLOCK_PROTOCOL)
Comment 28 Steve French 2015-02-25 08:08:49 UTC
Created attachment 10786 [details]
trivial patch to correct rc mapping - fixes the 15 oplock test cases

will remove the debug print statement in final version

This fixes
Comment 29 Jeremy Allison 2015-02-25 21:43:19 UTC
Comment on attachment 10786 [details]
trivial patch to correct rc mapping - fixes the 15 oplock test cases

We need a torture test to confirm these against Windows as well as the patch I think.
Comment 30 Steve French 2015-02-25 22:00:04 UTC
(In reply to Jeremy Allison from comment #29)
I did attach wireshark traces of Windows (correct behavior) for six of the testcases covering at least two of the conditions where we returned the wrong RC.
Comment 31 Jeremy Allison 2015-02-25 22:03:03 UTC
(In reply to Steve French from comment #30)

Wireshark traces are not torture test regression checks :-).