* [PATCH] Cygwin: shared: Fix access permissions setting in open_shared().
@ 2023-08-15 23:37 Takashi Yano
2023-08-16 0:07 ` Takashi Yano
2023-08-16 7:51 ` Corinna Vinschen
0 siblings, 2 replies; 4+ messages in thread
From: Takashi Yano @ 2023-08-15 23:37 UTC (permalink / raw)
To: cygwin-patches; +Cc: Takashi Yano
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.
This patch resumes the access permission settings to fix that.
Fixes: 93508e5bb841 ("Cygwin: open_shared: don't reuse shared_locations parameter as output")
Signedd-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
---
winsup/cygwin/mm/shared.cc | 6 ++----
1 file changed, 2 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 = 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;
@@ -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)
{
--
2.39.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Cygwin: shared: Fix access permissions setting in open_shared().
2023-08-15 23:37 [PATCH] Cygwin: shared: Fix access permissions setting in open_shared() Takashi Yano
@ 2023-08-16 0:07 ` Takashi Yano
2023-08-16 7:51 ` Corinna Vinschen
1 sibling, 0 replies; 4+ messages in thread
From: Takashi Yano @ 2023-08-16 0:07 UTC (permalink / raw)
To: cygwin-patches
On Wed, 16 Aug 2023 08:37:46 +0900
Takashi Yano wrote:
> 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.
>
> This patch resumes the access permission settings to fix that.
>
> Fixes: 93508e5bb841 ("Cygwin: open_shared: don't reuse shared_locations parameter as output")
> Signedd-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
> ---
> winsup/cygwin/mm/shared.cc | 6 ++----
> 1 file changed, 2 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 = 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;
> @@ -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)
> {
> --
> 2.39.0
>
cygwin-3_4-branch needs to modify the patch a bit.
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 = 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;
@@ -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/<PID>/maps along. */
addr = (void *) region_address[m];
- shared = MapViewOfFileEx (shared_h, FILE_MAP_READ | FILE_MAP_WRITE,
- 0, 0, 0, addr);
+ shared = MapViewOfFileEx (shared_h, access, 0, 0, 0, addr);
}
/* Also catch the unlikely case that a fixed region can't be mapped at the
fixed address. */
@@ -190,8 +188,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)
{
--
Takashi Yano <takashi.yano@nifty.ne.jp>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Cygwin: shared: Fix access permissions setting in open_shared().
2023-08-15 23:37 [PATCH] Cygwin: shared: Fix access permissions setting in open_shared() Takashi Yano
2023-08-16 0:07 ` Takashi Yano
@ 2023-08-16 7:51 ` Corinna Vinschen
2023-08-16 7:54 ` Corinna Vinschen
1 sibling, 1 reply; 4+ messages in thread
From: Corinna Vinschen @ 2023-08-16 7:51 UTC (permalink / raw)
To: cygwin-patches
On Aug 16 08:37, Takashi Yano wrote:
> 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.
>
> This patch resumes the access permission settings to fix that.
>
> Fixes: 93508e5bb841 ("Cygwin: open_shared: don't reuse shared_locations parameter as output")
> Signedd-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
> ---
> winsup/cygwin/mm/shared.cc | 6 ++----
> 1 file changed, 2 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 = 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;
> @@ -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)
> {
> --
> 2.39.0
Oh drat, whatever was I thinking at the time? Thanks for catching
and fixing this! Please push.
Corinna
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Cygwin: shared: Fix access permissions setting in open_shared().
2023-08-16 7:51 ` Corinna Vinschen
@ 2023-08-16 7:54 ` Corinna Vinschen
0 siblings, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2023-08-16 7:54 UTC (permalink / raw)
To: cygwin-patches
On Aug 16 09:51, Corinna Vinschen wrote:
> On Aug 16 08:37, Takashi Yano wrote:
> > 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.
> >
> > This patch resumes the access permission settings to fix that.
> >
> > Fixes: 93508e5bb841 ("Cygwin: open_shared: don't reuse shared_locations parameter as output")
> > Signedd-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
> > ---
> > winsup/cygwin/mm/shared.cc | 6 ++----
> > 1 file changed, 2 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 = 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;
> > @@ -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)
> > {
> > --
> > 2.39.0
>
> Oh drat, whatever was I thinking at the time? Thanks for catching
> and fixing this! Please push.
Please also add a release message to 3.4.8. I'll create the release
this week.
Thanks,
Corinna
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-16 7:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-15 23:37 [PATCH] Cygwin: shared: Fix access permissions setting in open_shared() Takashi Yano
2023-08-16 0:07 ` Takashi Yano
2023-08-16 7:51 ` Corinna Vinschen
2023-08-16 7:54 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).