From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 4C4D1385DC18; Wed, 16 Aug 2023 13:12:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C4D1385DC18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1692191567; bh=1K6NBwJivAPd5LOXuIzotY+g8xd8y406t/KueLT43aI=; h=From:To:Subject:Date:From; b=jTGXDbPVVijtrmoLNjfry+/HxJinvCgNavE/qkz2WlApFHcyp6bOl0bj5k20PBuow WgA+6OVDdIPsFVE/ncb0uVQaY6LrqIVL8cHoFu/0V3oIVW1zKGS8XbyS4wfRftsEHl 5f3fsos1u0+SFm0mkKeqHtfEV252cpqLyXabT4Tg= 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-3_4-branch] Cygwin: shared: Fix access permissions setting in open_shared(). X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/cygwin-3_4-branch X-Git-Oldrev: efba30dd1d4cf3db6df7f7bc7ee13775c577f1a1 X-Git-Newrev: c3eab1e295c2716b9c670213d7de21c968ebc161 Message-Id: <20230816131247.4C4D1385DC18@sourceware.org> Date: Wed, 16 Aug 2023 13:12:47 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dc3eab1e295c= 2716b9c670213d7de21c968ebc161 commit c3eab1e295c2716b9c670213d7de21c968ebc161 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 62f11a5a5704, 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: 62f11a5a5704 ("Cygwin: open_shared: don't reuse shared_locations= parameter as output") Fixes: fb16f490bf6e ("Cygwin: open_shared: try harder allocating a shar= ed region") Reviewed-by: Corinna Vinschen Signedd-off-by: Takashi Yano Diff: --- winsup/cygwin/mm/shared.cc | 9 +++------ winsup/cygwin/release/3.4.8 | 3 +++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/mm/shared.cc b/winsup/cygwin/mm/shared.cc index 2ea3a4336..20b57ff4d 100644 --- a/winsup/cygwin/mm/shared.cc +++ b/winsup/cygwin/mm/shared.cc @@ -148,8 +148,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; @@ -175,8 +174,7 @@ open_shared (const WCHAR *name, int n, HANDLE& shared_h= , DWORD size, Note that we don't actually *need* fixed addresses. The only advantage is reproducibility to help /proc//maps along. */ addr =3D (void *) region_address[m]; - 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); } /* Also catch the unlikely case that a fixed region can't be mapped at t= he fixed address. */ @@ -190,8 +188,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.