Skip to content

Commit

Permalink
Cygwin: shared: Fix access permissions setting in open_shared().
Browse files Browse the repository at this point in the history
After the commit 93508e5, the access permissions argument passed
to open_shared() is ignored and always replaced with (FILE_MAP_READ |
FILE_MAP_WRITE). This causes the weird behaviour that sshd service
process loses its cygwin PID. This triggers the failure in pty that
transfer_input() does not work properly.

This patch resumes the access permission settings to fix that.

Fixes: 93508e5 ("Cygwin: open_shared: don't reuse shared_locations parameter as output")
Reviewed-by: Corinna Vinschen <[email protected]>
Signedd-off-by: Takashi Yano <[email protected]>
  • Loading branch information
tyan0 committed Aug 16, 2023
1 parent 2ee8de7 commit 65d3448
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 2 additions & 4 deletions winsup/cygwin/mm/shared.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ open_shared (const WCHAR *name, int n, HANDLE& shared_h, DWORD size,
if (name)
mapname = shared_name (map_buf, name, n);
if (m == SH_JUSTOPEN)
shared_h = OpenFileMappingW (FILE_MAP_READ | FILE_MAP_WRITE, FALSE,
mapname);
shared_h = OpenFileMappingW (access, FALSE, mapname);
else
{
created = true;
Expand All @@ -165,8 +164,7 @@ open_shared (const WCHAR *name, int n, HANDLE& shared_h, DWORD size,
do
{
addr = (void *) next_address;
shared = MapViewOfFileEx (shared_h, FILE_MAP_READ | FILE_MAP_WRITE,
0, 0, 0, addr);
shared = MapViewOfFileEx (shared_h, access, 0, 0, 0, addr);
next_address += wincap.allocation_granularity ();
if (next_address >= SHARED_REGIONS_ADDRESS_HIGH)
{
Expand Down
3 changes: 3 additions & 0 deletions winsup/cygwin/release/3.4.8
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ Bug Fixes

- Fix memory leak in printf() regarding gdtoa-based _ldtoa_r().
Addresses: https://cygwin.com/pipermail/cygwin/2023-July/254054.html

- Fix a bug introduced in cygwin 3.4.5 that open_shared() does not set
access permissions as requested by its argument.

0 comments on commit 65d3448

Please sign in to comment.