[Bug 283726] wc(1) and other text utilities fail to read some pseudo-filesystem files

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 29 Dec 2024 16:47:00 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=283726

            Bug ID: 283726
           Summary: wc(1) and other text utilities fail to read some
                    pseudo-filesystem files
           Product: Base System
           Version: 15.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: rbranco@suse.com

To reproduce:

$ wc /compat/linux/proc/self/limits
wc: /compat/linux/proc/self/limits: read: Operation not permitted

Both cat(1) and GNU wc run without issues:

$ gwc /compat/linux/proc/self/limits
17 100 1354 /compat/linux/proc/self/limits

Other problematic files:
- /compat/linux/proc/self/maps

Other problematic text utilities:
- head
- tail
- maybe others.

While I'm aware that files from /proc must be read in one go, this doesn't seem
to be the issue because the buffer size in wc.c is big enough (MAXBSIZE =
65536).

At first, this bug seemed a lot like
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276043 but I tried removing
the code that calls kernel_sysctlbyname in linprocfs_doproclimits() and gives
the same error.  So the issue seems to be the Capsicum initialization code. 
The difference with cat(1) is that it calls cap_init, so maybe it needs Casper.

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