mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user