pipe2: properly clean up vnode references on error

Currently, pipe2 both closes the fds and releases references to the pipe
vnode on failure. However, closing the fds already causes the vnode
references to be dropped.

Make pipe2 only release the vnode references when the respective file_t
were not closed.

Found by syzkaller fuzzing.
This commit is contained in:
Matheus
2026-10-09 02:11:50 -03:00
parent 47ce33935f
commit 5360edb9c7
+3 -7
View File
@@ -52,22 +52,18 @@ syscallret_t syscall_pipe2(context_t *, int flags) {
ret.ret = (uint64_t)readfd | ((uint64_t)writefd << 32);
return ret;
error:
if (readfile) {
fd_release(readfile);
fd_close(readfd);
} else if (node) {
VOP_RELEASE(node);
}
if (writefile) {
fd_release(writefile);
fd_close(writefd);
}
if (node) {
// released twice because of two holds (one at pipefs_newpipe and the manual hold)
VOP_RELEASE(node);
} if (node) {
VOP_RELEASE(node);
}