I've received a request to clarify the semantics of the pid argument to cap_get_pid() when invoked from within a namespace. I'm filing this bug to make sure I do this. My belief at present is that within the namespace, the caller can only see the pid view visible within that namespace.
I chatted with Serge Hallyn and he confirms that the pid argument is interpreted "relative to the caller's pid_ns".
Fixed via: https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=ceaa591b012610d3fe402d33e7d7ca14716cf965
This man page needs some discussion of the returned capabilities too, in the case of querying a PID inside some other namespace.
Fixed with: https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=9a9579181897a62dc107b121f139a319d7e297fa