From: Jeremy Allison Date: Fri, 6 Aug 2021 17:54:31 +0000 (-0700) Subject: s4: torture: Add test for smb2.ioctl.bug14769. X-Git-Tag: ldb-2.5.0~988 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e7ea761a37f46f758582981bc40404ffd815513;p=thirdparty%2Fsamba.git s4: torture: Add test for smb2.ioctl.bug14769. Add knownfails. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14769 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/selftest/knownfail b/selftest/knownfail index b2c09e73393..9f362c02b47 100644 --- a/selftest/knownfail +++ b/selftest/knownfail @@ -198,6 +198,7 @@ ^samba4.smb2.ioctl.req_two_resume_keys\(ad_dc_ntvfs\) # not supported by s4 ntvfs server ^samba4.smb2.ioctl.copy_chunk_\w*\(ad_dc_ntvfs\) # not supported by s4 ntvfs server ^samba4.smb2.ioctl.copy-chunk streams\(ad_dc_ntvfs\) # not supported by s4 ntvfs server +^samba4.smb2.ioctl.bug14769\(ad_dc_ntvfs\) # not supported by s4 ntvfs server ^samba3.smb2.dir.one ^samba3.smb2.dir.modify ^samba3.smb2.oplock.batch20 diff --git a/selftest/knownfail.d/smb2_ioctl_bug14769 b/selftest/knownfail.d/smb2_ioctl_bug14769 new file mode 100644 index 00000000000..783a863cc06 --- /dev/null +++ b/selftest/knownfail.d/smb2_ioctl_bug14769 @@ -0,0 +1,3 @@ +^samba3.smb2.ioctl fs_specific.bug14769\(nt4_dc\) +^samba3.smb2.ioctl.bug14769\(nt4_dc\) +^samba3.smb2.ioctl.bug14769\(ad_dc\) diff --git a/source4/torture/smb2/ioctl.c b/source4/torture/smb2/ioctl.c index 1de5179e336..022ea001688 100644 --- a/source4/torture/smb2/ioctl.c +++ b/source4/torture/smb2/ioctl.c @@ -6845,6 +6845,84 @@ static bool test_ioctl_bug14607(struct torture_context *torture, return true; } +/* + basic regression test for BUG 14769 + https://bugzilla.samba.org/show_bug.cgi?id=14769 +*/ +static bool test_ioctl_bug14769(struct torture_context *torture, + struct smb2_tree *tree) +{ + NTSTATUS status; + const char *fname = "bug14769"; + bool ret = false; + struct smb2_handle h; + struct smb2_ioctl ioctl; + struct smb2_close cl; + struct smb2_request *smb2arr[2] = { 0 }; + uint8_t tosend_msec = 200; + DATA_BLOB send_buf = { &tosend_msec, 1 }; + + /* Create a test file. */ + smb2_util_unlink(tree, fname); + status = torture_smb2_testfile(tree, fname, &h); + torture_assert_ntstatus_ok(torture, status, "create bug14769"); + + /* + * Send (not receive) the FSCTL. + * This should go async with a wait time of 200 msec. + */ + ZERO_STRUCT(ioctl); + ioctl.in.file.handle = h; + ioctl.in.function = FSCTL_SMBTORTURE_FSP_ASYNC_SLEEP; + ioctl.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL; + ioctl.in.out = send_buf; + + smb2arr[0] = smb2_ioctl_send(tree, &ioctl); + torture_assert_goto(torture, + smb2arr[0] != NULL, + ret, + done, + "smb2_ioctl_send failed\n"); + /* Immediately send the close. */ + ZERO_STRUCT(cl); + cl.in.file.handle = h; + cl.in.flags = 0; + smb2arr[1] = smb2_close_send(tree, &cl); + torture_assert_goto(torture, + smb2arr[1] != NULL, + ret, + done, + "smb2_close_send failed\n"); + + /* Now get the FSCTL reply. */ + /* + * If we suffer from bug #14769 this will fail as + * the ioctl will return with NT_STATUS_FILE_CLOSED, + * as the close will have closed the handle without + * waiting for the ioctl to complete. The server shouldn't + * complete the close until the ioctl finishes. + */ + status = smb2_ioctl_recv(smb2arr[0], tree, &ioctl); + torture_assert_ntstatus_ok_goto(torture, + status, + ret, + done, + "smb2_ioctl_recv failed\n"); + + /* Followed by the close reply. */ + status = smb2_close_recv(smb2arr[1], &cl); + torture_assert_ntstatus_ok_goto(torture, + status, + ret, + done, + "smb2_ioctl_close failed\n"); + ret = true; + + done: + smb2_util_unlink(tree, fname); + return ret; +} + /* * testing of SMB2 ioctls */ @@ -6992,6 +7070,8 @@ struct torture_suite *torture_smb2_ioctl_init(TALLOC_CTX *ctx) test_ioctl_dup_extents_dest_lck); torture_suite_add_1smb2_test(suite, "bug14607", test_ioctl_bug14607); + torture_suite_add_1smb2_test(suite, "bug14769", + test_ioctl_bug14769); suite->description = talloc_strdup(suite, "SMB2-IOCTL tests");