diff options
| author | mlelstv <mlelstv@NetBSD.org> | 2022-07-31 13:08:18 +0000 |
|---|---|---|
| committer | mlelstv <mlelstv@NetBSD.org> | 2022-07-31 13:08:18 +0000 |
| commit | 8cf738c317247a243b3aa90ebb820ed1a2db13e9 (patch) | |
| tree | 87832f3dbcc12cf5d84248da9ba89616ec081880 /sys/fs | |
| parent | 139d4be7285a14b6b2321c3cd01ac88cb031f9cf (diff) | |
Don't panic for a negative offset, just fail the operation with EINVAL.
Diffstat (limited to 'sys/fs')
| -rw-r--r-- | sys/fs/sysvbfs/sysvbfs_vnops.c | 8 | ||||
| -rw-r--r-- | sys/fs/v7fs/v7fs_vnops.c | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/sys/fs/sysvbfs/sysvbfs_vnops.c b/sys/fs/sysvbfs/sysvbfs_vnops.c index 2d5e3dc9353..2633cc2919d 100644 --- a/sys/fs/sysvbfs/sysvbfs_vnops.c +++ b/sys/fs/sysvbfs/sysvbfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: sysvbfs_vnops.c,v 1.68 2021/10/20 03:08:17 thorpej Exp $ */ +/* $NetBSD: sysvbfs_vnops.c,v 1.69 2022/07/31 13:08:18 mlelstv Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.68 2021/10/20 03:08:17 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.69 2022/07/31 13:08:18 mlelstv Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -632,7 +632,9 @@ sysvbfs_readdir(void *v) uio->uio_offset, uio->uio_resid); KDASSERT(vp->v_type == VDIR); - KDASSERT(uio->uio_offset >= 0); + + if (uio->uio_offset < 0) + return EINVAL; dp = malloc(sizeof(struct dirent), M_BFS, M_WAITOK | M_ZERO); diff --git a/sys/fs/v7fs/v7fs_vnops.c b/sys/fs/v7fs/v7fs_vnops.c index 6814c9b3d0c..2524b996391 100644 --- a/sys/fs/v7fs/v7fs_vnops.c +++ b/sys/fs/v7fs/v7fs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: v7fs_vnops.c,v 1.37 2022/05/22 11:27:36 andvar Exp $ */ +/* $NetBSD: v7fs_vnops.c,v 1.38 2022/07/31 13:08:19 mlelstv Exp $ */ /*- * Copyright (c) 2004, 2011 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.37 2022/05/22 11:27:36 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.38 2022/07/31 13:08:19 mlelstv Exp $"); #if defined _KERNEL_OPT #include "opt_v7fs.h" #endif @@ -996,9 +996,11 @@ v7fs_readdir(void *v) DPRINTF("offset=%zu residue=%zu\n", uio->uio_offset, uio->uio_resid); KDASSERT(vp->v_type == VDIR); - KDASSERT(uio->uio_offset >= 0); KDASSERT(v7fs_inode_isdir(inode)); + if (uio->uio_offset < 0) + return EINVAL; + struct v7fs_readdir_arg arg; arg.start = uio->uio_offset / sizeof(*dp); arg.end = arg.start + uio->uio_resid / sizeof(*dp); |
