[Bug 297512] kern.proc.env sysctl fails with ENOMEM when last env string is near the end of the stack mapping; breaks ConsoleKit2 session lookup and GNOME screen unlock

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 14 Aug 2026 13:38:43 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=297512

--- Comment #3 from Stéphane D'Alu <sdalu@sdalu.com> ---
Tested D58838 on my machine, the screen unlock problem didn't reproduced.
Thanks for the quick fix!

Here is the follow-up of the test suite run by Fable:

- Whole-system scan (ptrace-based measurement of each process's
  last-env-string distance to the next unmapped page): 96 processes,
  3 landed in the previously-failing layout (distance < 256 with the
  next page unmapped: zfsd at 163, getty at 164, ibus-portal at 203).
  kern.proc.env now succeeds for all of them; zero ENOMEM system-wide.
  On the unpatched kernel the same predicate matched the ENOMEM
  failures exactly (4 predicted / 4 failing out of 139).

- On-demand reproduction: spawned /bin/sleep with varying environment
  sizes until an instance landed 72 bytes from the unmapped boundary;
  procstat penv read its complete environment (33 entries) without
  error.

-- 
You are receiving this mail because:
You are the assignee for the bug.