readtask() silently ignores all errors
I have a piece of code where the main thread might not have access to its own threads due to LSM and thread labels not being synchronized. In such a case using readtask() (after readproc()) will silently fail on EPERM/EACCESS and return only threads it can access without any indication that some were omitted.
The following code is at fault as it does not check any errors from taskreader silently continuing the loop if it fails for previously found task.
for(;;){
// fills in the path, plus t->tid and t->tgid
if (unlikely(!PT->taskfinder(PT,p,t,path))) goto out; // simple_nexttid
// go read the task data
ret = PT->taskreader(PT,p,t,path); // simple_readtask
if(ret) return ret;
}
errno is set, but I think one cannot rely on this as it can get overwritten due to implementation specific details. This issue seems to be wider as all errors will get ignored, be it EPERM or any other.