From b52882f3f7b7170716b4d883c75506e8bf6bc98f Mon Sep 17 00:00:00 2001 From: Matheus Date: Fri, 9 Oct 2026 01:41:48 -0300 Subject: [PATCH] syscalls: fix vnode cleanup in some *at syscalls Some *at functions have a cleanup goto which could use an uninitialized vnode. Fix this by defining the vnodes earlier. Found by syzkaller fuzzing. --- kernel-src/sys/syscalls/readlinkat.c | 2 +- kernel-src/sys/syscalls/statvfs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel-src/sys/syscalls/readlinkat.c b/kernel-src/sys/syscalls/readlinkat.c index 186dad66..25674ed2 100644 --- a/kernel-src/sys/syscalls/readlinkat.c +++ b/kernel-src/sys/syscalls/readlinkat.c @@ -26,6 +26,7 @@ syscallret_t syscall_readlinkat(context_t *, int dirfd, char *upath, char *ubuff return ret; } + vnode_t *node = NULL; file_t *file = NULL; vnode_t *dirnode = NULL; char *buffer = NULL; @@ -33,7 +34,6 @@ syscallret_t syscall_readlinkat(context_t *, int dirfd, char *upath, char *ubuff if (ret.errno) goto cleanup; - vnode_t *node = NULL; ret.errno = vfs_lookup(&node, dirnode, path, NULL, VFS_LOOKUP_NOLINK); if (ret.errno) goto cleanup; diff --git a/kernel-src/sys/syscalls/statvfs.c b/kernel-src/sys/syscalls/statvfs.c index 3f9797fb..4c5386d3 100644 --- a/kernel-src/sys/syscalls/statvfs.c +++ b/kernel-src/sys/syscalls/statvfs.c @@ -90,13 +90,13 @@ syscallret_t syscall_fstatvfsat(context_t *ctx, int dirfd, char *upath, stat_t * return ret; } + vnode_t *node = NULL; vnode_t *dirnode = NULL; file_t *file = NULL; ret.errno = dirfd_enter(path, dirfd, &file, &dirnode); if (ret.errno) goto cleanup; - vnode_t *node = NULL; ret.errno = vfs_lookup(&node, dirnode, path, NULL, flags & AT_SYMLINK_NOFOLLOW ? VFS_LOOKUP_NOLINK : 0); if (ret.errno) goto cleanup;