Well, lets begin. In the future, I wish to have fd_getfile() returning acquired fp instance. The goal is to not to have pointer to destroyed fp instance in FREF()/FRELE()/fd_getfile() races. This one requres modification of getsock(), getvnode() and dupfdopen() functions, they must receive pointer to struct proc instance for FRELE() call on referenced fp instance while they have internal error cases. While getsock(), getvnode() and dupfdopen() functions are called, "struct proc" instance exists, so their "struct filedesc *" arg can be replaced by "struct proc *" arg which contains pointer to "struct filedesc”.
The races will be appeared right after at least one FRELE(), FREF() or
fd_getfile() call will be done outside kernel lock. The “outside kernel lock"
call
capability requires a little more refactoring, but for this functions only, not
system-wide.
Now we have something like:
if((fp = fd_getfile(fds, fd)) == NULL)
goto error;
/*
* fp can be destroyed here by FRELE() call on other cpu
*/
FREF(fp);
The goal is to avoid this situation.
Should I checkout CURRENT and patch it or 5.7 is fine too?
I attach already exitig patches for git tree. If it required, I'll
remake them and send one after another.
P.S. I'm not a native speaker and my english is ugly. Sorry.
0001-getsock-api-modification.patch
Description: Binary data
0002-getvnode-api-modification.patch
Description: Binary data
0003-dupfdopen-api-modification.patch
Description: Binary data
0004-fd_getfile-returns-acquired-fp-instance-now.patch
Description: Binary data
