-
Notifications
You must be signed in to change notification settings - Fork 274
VSMB fix bugcheck by keeping handle open to empty default share #2591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,9 @@ const ( | |
| LmrInstanceFlagAllowGuestAuth = 0x8 | ||
| LmrInstanceFlagSupportsDirectmappedIo = 0x10 | ||
| SmbCeTransportTypeVmbus = 3 | ||
|
|
||
| FileReadAttributes = 0x00000080 | ||
| FileFlagBackupSemantics = 0x02000000 | ||
| ) | ||
|
|
||
| type IOStatusBlock struct { | ||
|
|
@@ -166,7 +169,7 @@ func isLanmanWorkstationRunning() (bool, error) { | |
| return status.State == svc.Running, nil | ||
| } | ||
|
|
||
| func VsmbMain() { | ||
| func VsmbMain(vsmbKeepAliveHandle *windows.Handle) { | ||
| logrus.Info("Starting VSMB initialization...") | ||
|
|
||
| logrus.Debug("Configuring LanmanWorkstation service...") | ||
|
|
@@ -329,4 +332,31 @@ func VsmbMain() { | |
| } else { | ||
| logrus.Errorf("NtFsControlFile failed: 0x%08X", status) | ||
| } | ||
|
|
||
| const ( | ||
| device = `\\?\GLOBALROOT\Device\vmsmb\VSMB-{dcc079ae-60ba-4d07-847c-3493609c0870}\defaultEmptyShare` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does not seem to work on testing. |
||
| ) | ||
|
|
||
| devicePtr, nerr := windows.UTF16PtrFromString(device) | ||
| if nerr != nil { | ||
| logrus.WithError(nerr).Errorf("invalid device name %q", device) | ||
| return | ||
| } | ||
| vsmbHandle, err := windows.CreateFile( | ||
| devicePtr, | ||
| FileReadAttributes, | ||
| windows.FILE_SHARE_READ|windows.FILE_SHARE_WRITE|windows.FILE_SHARE_DELETE, | ||
| nil, | ||
| windows.OPEN_EXISTING, | ||
| FileFlagBackupSemantics, | ||
| 0, | ||
| ) | ||
|
|
||
| if err != nil { | ||
| logrus.WithError(err).Errorf("Failed to open %s", device) | ||
| return | ||
| } | ||
|
|
||
| *vsmbKeepAliveHandle = vsmbHandle | ||
| logrus.Infof("VSMB connection will be alive...") | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this strictly necessary? you may have the
VsmbMainfunction return a handle, instead of passing a pointer in. Also, as we're finalizing this feature, you may want to consider returning an error in case we fail to setup LMR/dummy share, instead of silently failing as we do now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to make the handle global so it's available until end of process. We do add error log inside vsmb.go in failure case, whats the point of returning an error?