boost::process::limit_handles limited to PIDs below 65535

Open
#428 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

Start in include/boost/process/v1/detail/windows/handles.hpp, especially get_handles around lines 41 and 136, and trace how limit_handles queries inherited handles. Compare the documented constraints of SYSTEM_HANDLE_INFORMATION_EX with the suggested UpdateProcThreadAttribute approach for Vista and later. Done means handle limiting works for PIDs above 65535 without regressing supported Windows versions.

Written by the indexing model from the issue text.

Description

The call to get_handles is limited to PID sizes of up to 65535 (USHRT_MAX). This is because of this call to NtQuerySystemInformation.

As it's undocumented it's hard to hunt down but it looks like the NtQuerySystemInformation call is limited to PIDs in the range of an unsigned short. To fix this instead of SYSTEM_HANDLE_INFORMATION we would need to consider using SYSTEM_HANDLE_INFORMATION_EX to query the system handles.

I think it would be safer to possibly use UpdateProcThreadAttribute() (at least for vista +) as suggested originally. It seems a bit unnecessary to iterate over all the system handles in order to limit the handles inherited by a process when UpdateProcThreadAttribute() is supported.

Dominant language
C++
Stars
145
Forks
151
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/process

All issues in boostorg/process

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.