[PATCH] fhandler_pipe: add sanity limit to handle loops
Jeremy Drake
cygwin@jdrake.com
Sun Dec 26 21:35:27 GMT 2021
On Sun, 26 Dec 2021, Ken Brown wrote:
> On 12/26/2021 11:04 AM, Ken Brown wrote:
> > On 12/26/2021 10:09 AM, Ken Brown wrote:
> > > 1. For some processes, NtQueryInformationProcess(ProcessHandleInformation)
> > > can return STATUS_SUCCESS with invalid handle information. See the
> > > comment starting at line 5754, where it is shown how to detect this.
I kind of thought something like this (that NumberOfHandles was
uninitialized memory).
> > If I'm right, the following patch should fix the problem:
> >
> > diff --git a/winsup/cygwin/fhandler_pipe.cc b/winsup/cygwin/fhandler_pipe.cc
> > index ba6b70f55..4cef3e4ca 100644
> > --- a/winsup/cygwin/fhandler_pipe.cc
> > +++ b/winsup/cygwin/fhandler_pipe.cc
> > @@ -1228,6 +1228,7 @@ fhandler_pipe::get_query_hdl_per_process (WCHAR *name,
> > HeapAlloc (GetProcessHeap (), 0, nbytes);
> > if (!phi)
> > goto close_proc;
> > + phi->NumberOfHandles = 0;
> > status = NtQueryInformationProcess (proc,
> > ProcessHandleInformation,
> > phi, nbytes, &len);
> > if (NT_SUCCESS (status))
>
> Actually, this first hunk should suffice.
>
> > Jeremy, could you try this?
> >
> > Ken
I've built (leaving the assert in place too), and I've got 3 loops going
on server 2022 and 1 going on ARM64. So far so good. I don't know how
long before calling it good though.
More information about the Cygwin-patches
mailing list