Skip to content

Windows Desktop Directory Sharing#13630

Merged
ibeckermayer merged 35 commits intomasterfrom
windows-desktop-directory-sharing
Aug 4, 2022
Merged

Windows Desktop Directory Sharing#13630
ibeckermayer merged 35 commits intomasterfrom
windows-desktop-directory-sharing

Conversation

@ibeckermayer
Copy link
Copy Markdown
Contributor

No description provided.

@ibeckermayer ibeckermayer force-pushed the windows-desktop-directory-sharing branch 2 times, most recently from 725f742 to 2cd91e5 Compare July 6, 2022 16:02
@ibeckermayer ibeckermayer marked this pull request as ready for review July 6, 2022 16:02
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 6, 2022

@ibeckermayer - this PR is large and will require admin approval to merge. Consider breaking it up into a series smaller changes.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 7, 2022

@ibeckermayer - this PR is large and will require admin approval to merge. Consider breaking it up into a series smaller changes.

4 similar comments
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 7, 2022

@ibeckermayer - this PR is large and will require admin approval to merge. Consider breaking it up into a series smaller changes.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 8, 2022

@ibeckermayer - this PR is large and will require admin approval to merge. Consider breaking it up into a series smaller changes.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 8, 2022

@ibeckermayer - this PR is large and will require admin approval to merge. Consider breaking it up into a series smaller changes.

@github-actions
Copy link
Copy Markdown
Contributor

@ibeckermayer - this PR is large and will require admin approval to merge. Consider breaking it up into a series smaller changes.

@github-actions
Copy link
Copy Markdown
Contributor

@ibeckermayer - this PR is large and will require admin approval to merge. Consider breaking it up into a series smaller changes.

@github-actions
Copy link
Copy Markdown
Contributor

@ibeckermayer - this PR is large and will require admin approval to merge. Consider breaking it up into a series smaller changes.

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

@ibeckermayer - this PR is large and will require admin approval to merge. Consider breaking it up into a series smaller changes.

@ibeckermayer ibeckermayer enabled auto-merge (squash) July 26, 2022 21:48
@github-actions
Copy link
Copy Markdown
Contributor

@ibeckermayer - this PR is large and will require admin approval to merge. Consider breaking it up into a series smaller changes.

@ibeckermayer ibeckermayer requested a review from zmb3 July 27, 2022 17:15
@github-actions
Copy link
Copy Markdown
Contributor

@ibeckermayer - this PR is large and will require admin approval to merge. Consider breaking it up into a series smaller changes.

@github-actions
Copy link
Copy Markdown
Contributor

@ibeckermayer - this PR is large and will require admin approval to merge. Consider breaking it up into a series smaller changes.

Comment thread lib/srv/desktop/rdp/rdpclient/client.go
Comment thread lib/srv/desktop/rdp/rdpclient/client.go
Comment thread lib/srv/desktop/rdp/rdpclient/client.go
// In other words, all pointer data that needs to persist after this function returns MUST
// be copied into Rust-owned memory.

let res = SharedDirectoryInfoResponse::from(res);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first, the SharedDirectoryInfoResponse was created in place where it was used, inside the call to handle_tdp_sd_info_response, but now it has been moved into top of the function. There's nothing wrong with defining it as a standalone variable, but I'm just wondering why you've moved it here? There are couple of old functions in which we follow the old pattern, so maybe we should unify them?

Copy link
Copy Markdown
Contributor Author

@ibeckermayer ibeckermayer Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of these changes are to always ensure that we adhere to the following memory safety protocol, all the way up here at the "C" boundary:

// # Safety
//
// This function MUST NOT hang on to any of the pointers passed in to it after it returns.
// In other words, all pointer data that needs to persist after this function returns MUST
// be copied into Rust-owned memory.

(Which we do in SharedDirectoryInfoResponse::from)

This way, we don't need to worry about any tricky memory bugs further down the call stack. It's all taken care of right here at the boundary.

I'm not sure which old functions you're referring to, can you point them out?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the response! I should've included the other function I had in my mind in my previous response. Like here: I did it the other way:

#[no_mangle]
pub unsafe extern "C" fn handle_tdp_sd_read_response(
client_ptr: *mut Client,
res: CGOSharedDirectoryReadResponse,
) -> CGOErrCode {
let client = match Client::from_ptr(client_ptr) {
Ok(client) => client,
Err(cgo_error) => {
return cgo_error;
}
};
let mut rdp_client = client.rdp_client.lock().unwrap();
match rdp_client.handle_tdp_sd_read_response(SharedDirectoryReadResponse::from(res)) {
Ok(()) => CGOErrCode::ErrCodeSuccess,
Err(e) => {
error!("failed to handle Shared Directory Read Response: {:?}", e);
CGOErrCode::ErrCodeFailure
}
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, good eye. I must have not had those functions merged yet whenever I went back and revised all of these functions to use this pattern. The code and memory all works fine, but I'll add the safety comments and rearrange the order in an upcoming PR just for the sake of consistency.

@github-actions github-actions Bot removed the request for review from xacrimon August 3, 2022 18:47
Co-authored-by: Łukasz Kozłowski <admin@lkozlowski.com>
@ibeckermayer ibeckermayer merged commit 361ea8e into master Aug 4, 2022
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 4, 2022

@ibeckermayer See the table below for backport results.

Branch Result
branch/v10 Failed
branch/v9 Failed

ibeckermayer pushed a commit that referenced this pull request Aug 23, 2022
* `IRP_MJ_CREATE` (#12665)

* `IRP_MJ_QUERY_INFORMATION` (#12717)

* `IRP_MJ_CLOSE` (#12729)

* Refactor rdpdr client (#12750)

* Adding logic for `FILE_SUPERSEDE` (#12829)

* Improve `process_irp_create` (#12830)

* adds return statements that got lost in a merge

* `IRP_MJ_DIRECTORY_CONTROL` (#12870)

* `FileFullDirectoryInformation` (#12908)

* Improve `ClientDriveQueryDirectoryResponse.encode()` (#12912)

* `IRP_MJ_QUERY_VOLUME_INFORMATION` (#13071)

* Fix Shared Directory Request handling when feature is disabled (#13439)

* IRP_MJ_READ, IRP_MJ_WRITE, and IRP_MJ_SET_INFORMATION (#13995)

* Adds constants for sizing calculations (#14051)

Co-authored-by: Łukasz Kozłowski <lukasz.kozlowski@goteleport.com>
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
ibeckermayer pushed a commit that referenced this pull request Aug 23, 2022
* `IRP_MJ_CREATE` (#12665)

* `IRP_MJ_QUERY_INFORMATION` (#12717)

* `IRP_MJ_CLOSE` (#12729)

* Refactor rdpdr client (#12750)

* Adding logic for `FILE_SUPERSEDE` (#12829)

* Improve `process_irp_create` (#12830)

* adds return statements that got lost in a merge

* `IRP_MJ_DIRECTORY_CONTROL` (#12870)

* `FileFullDirectoryInformation` (#12908)

* Improve `ClientDriveQueryDirectoryResponse.encode()` (#12912)

* `IRP_MJ_QUERY_VOLUME_INFORMATION` (#13071)

* Fix Shared Directory Request handling when feature is disabled (#13439)

* IRP_MJ_READ, IRP_MJ_WRITE, and IRP_MJ_SET_INFORMATION (#13995)

* Adds constants for sizing calculations (#14051)

Co-authored-by: Łukasz Kozłowski <lukasz.kozlowski@goteleport.com>
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
@zmb3 zmb3 deleted the windows-desktop-directory-sharing branch September 1, 2022 21:15
ibeckermayer pushed a commit that referenced this pull request Sep 7, 2022
…ring) (#15770)

* Windows Desktop Directory Sharing (#13630)

* `IRP_MJ_CREATE` (#12665)

* `IRP_MJ_QUERY_INFORMATION` (#12717)

* `IRP_MJ_CLOSE` (#12729)

* Refactor rdpdr client (#12750)

* Adding logic for `FILE_SUPERSEDE` (#12829)

* Improve `process_irp_create` (#12830)

* adds return statements that got lost in a merge

* `IRP_MJ_DIRECTORY_CONTROL` (#12870)

* `FileFullDirectoryInformation` (#12908)

* Improve `ClientDriveQueryDirectoryResponse.encode()` (#12912)

* `IRP_MJ_QUERY_VOLUME_INFORMATION` (#13071)

* Fix Shared Directory Request handling when feature is disabled (#13439)

* IRP_MJ_READ, IRP_MJ_WRITE, and IRP_MJ_SET_INFORMATION (#13995)

* Adds constants for sizing calculations (#14051)

Co-authored-by: Łukasz Kozłowski <lukasz.kozlowski@goteleport.com>
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

* `UnixPath` and `WindowsPath` (#14267)

* `SharedDirectoryMoveRequest` and `SharedDirectoryMoveResponse` (#14959)

* `SharedDirectoryCreateResponse` update (#15289)

* Fix `process_irp_set_information` (#15364)

* Sanitize Rust Debug Logs (#15743)

* updates rdp-rs ref to include licensing changes

* Updates rdp-rs ref and fixes Cargo

Co-authored-by: Łukasz Kozłowski <lukasz.kozlowski@goteleport.com>
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants