From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 379DB3858409; Wed, 16 Aug 2023 13:12:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 379DB3858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1692191539; bh=sl+wi0DoX+YAagu6CMsh5Qi1RFT4deGmuawwDhSXggQ=; h=From:To:Subject:Date:From; b=W5KU69K+1RlMKV3HjW46cn9zfveTT8XzJTCisfY7Hz0McDP7j0zMhNafCbONI0RKv H27lMyAZ0dEX8tZKazRYTHM5syeznOm5URG7Sya/WRfhW5IO4LgFOs75UdryLtUgCZ qQVjNb//7x+rzQ4CWVbYCfL9BraOdHT1wejNURJg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Takashi Yano To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: shared: Fix access permissions setting in open_shared(). X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: 2ee8de782b809c83c4261cc6e7e17bdaf31cff96 X-Git-Newrev: 65d34484e9097fd9036dd577028423355cb5f5bc Message-Id: <20230816131219.379DB3858409@sourceware.org> Date: Wed, 16 Aug 2023 13:12:19 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D65d34484e90= 97fd9036dd577028423355cb5f5bc commit 65d34484e9097fd9036dd577028423355cb5f5bc Author: Takashi Yano Date: Wed Aug 16 08:00:27 2023 +0900 Cygwin: shared: Fix access permissions setting in open_shared(). =20 After the commit 93508e5bb841, 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. =20 This patch resumes the access permission settings to fix that. =20 Fixes: 93508e5bb841 ("Cygwin: open_shared: don't reuse shared_locations= parameter as output") Reviewed-by: Corinna Vinschen Signedd-off-by: Takashi Yano Diff: --- winsup/cygwin/mm/shared.cc | 6 ++---- winsup/cygwin/release/3.4.8 | 3 +++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/mm/shared.cc b/winsup/cygwin/mm/shared.cc index 40cdd4722..7977df382 100644 --- a/winsup/cygwin/mm/shared.cc +++ b/winsup/cygwin/mm/shared.cc @@ -139,8 +139,7 @@ open_shared (const WCHAR *name, int n, HANDLE& shared_h= , DWORD size, if (name) mapname =3D shared_name (map_buf, name, n); if (m =3D=3D SH_JUSTOPEN) - shared_h =3D OpenFileMappingW (FILE_MAP_READ | FILE_MAP_WRITE, FALSE, - mapname); + shared_h =3D OpenFileMappingW (access, FALSE, mapname); else { created =3D true; @@ -165,8 +164,7 @@ open_shared (const WCHAR *name, int n, HANDLE& shared_h= , DWORD size, do { addr =3D (void *) next_address; - shared =3D MapViewOfFileEx (shared_h, FILE_MAP_READ | FILE_MAP_WRITE, - 0, 0, 0, addr); + shared =3D MapViewOfFileEx (shared_h, access, 0, 0, 0, addr); next_address +=3D wincap.allocation_granularity (); if (next_address >=3D SHARED_REGIONS_ADDRESS_HIGH) { diff --git a/winsup/cygwin/release/3.4.8 b/winsup/cygwin/release/3.4.8 index 448831c65..8cd3eb14b 100644 --- a/winsup/cygwin/release/3.4.8 +++ b/winsup/cygwin/release/3.4.8 @@ -17,3 +17,6 @@ Bug Fixes =20 - 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.