This is an archive of the discontinued LLVM Phabricator instance.

[lldb][windows] _wsopen_s does not accept bits other than `_S_IREAD | _S_IWRITE`
ClosedPublic

Authored by yshui on Aug 1 2023, 10:48 AM.

Details

Summary

When sending file from a Linux host to a Windows remote, Linux host will try to copy the source file's permission bits, which will contain _S_I?GRP and _S_I?OTH bits. Those bits are rejected by _wsopen_s, causing it to return EINVAL.

This patch masks out the rejected bits.

GitHub issue: #64313

Diff Detail

Event Timeline

yshui created this revision.Aug 1 2023, 10:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2023, 10:48 AM
yshui requested review of this revision.Aug 1 2023, 10:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2023, 10:48 AM
jasonmolenda accepted this revision.Aug 1 2023, 5:22 PM
jasonmolenda added a subscriber: jasonmolenda.

LGTM.

This revision is now accepted and ready to land.Aug 1 2023, 5:22 PM

I just commented on the issue, thanks for the fix!

What exactly are the other bits in the mode here, are we losing something important potentially? I guess it can't be that important if Windows rejects them.

Also please put [lldb][Windows] at the start of the commit title.

lldb/source/Host/windows/FileSystem.cpp
104

Nitpick: comments are usually on the line before.

yshui retitled this revision from _wsopen_s does not accept bits other than `_S_IREAD | _S_IWRITE` to [lldb][windows] _wsopen_s does not accept bits other than `_S_IREAD | _S_IWRITE`.Aug 3 2023, 8:54 AM

What exactly are the other bits in the mode here, are we losing something important potentially? I guess it can't be that important if Windows rejects them.

I don't think so, group and other permission bits don't really make sense on Windows anyways, unless we use ACL or something.

DavidSpickett accepted this revision.Aug 3 2023, 9:39 AM

I think this could be tested with an lldb-server test, but it would likely go in lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py which has every test marked as skipped on Windows. For reasons lost to time.

If you feel like trying to re-enable them, great, otherwise I'm ok for such a simple fix to go in as is. Thanks again!

I noticed this review is accepted but not committed. If you don't have commit access, what's your preferred git identity, i.e. Real Name <email@address>?

I noticed this review is accepted but not committed. If you don't have commit access, what's your preferred git identity, i.e. Real Name <email@address>?

"Yuxuan Shui <yshuiv7@gmail.com>"

Thanks.