summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1997-02-26 16:38:21 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1997-02-26 16:38:21 +0000
commitcb2eb095fa8af44f6bb3cc1179a3e781f2866c3b (patch)
tree378dbd3a57e3d9ddd841c2c2e5416d13a1387044 /sys/kern
parente473839f593321a5f904140f2c59c762795806fc (diff)
From tholo: Do not do strict POSIX offset checking on character devices.
This fixes the problem of not being able to read kernel virtual memory on the alpha, thus breaking things like ps etc.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_syscalls.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 46df453aa0c..ebfa0276489 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls.c,v 1.23 1997/02/14 17:20:09 deraadt Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.24 1997/02/26 16:38:20 niklas Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@@ -1166,7 +1166,7 @@ sys_lseek(p, v, retval)
register struct file *fp;
struct vattr vattr;
struct vnode *vp;
- int error;
+ int error, special;
if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
(fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
@@ -1176,9 +1176,13 @@ sys_lseek(p, v, retval)
vp = (struct vnode *)fp->f_data;
if (vp->v_type == VFIFO)
return (ESPIPE);
+ if (vp->v_type == VCHR)
+ special = 1;
+ else
+ special = 0;
switch (SCARG(uap, whence)) {
case L_INCR:
- if (fp->f_offset + SCARG(uap, offset) < 0)
+ if (!special && fp->f_offset + SCARG(uap, offset) < 0)
return (EINVAL);
fp->f_offset += SCARG(uap, offset);
break;
@@ -1187,12 +1191,12 @@ sys_lseek(p, v, retval)
cred, p);
if (error)
return (error);
- if ((off_t)vattr.va_size + SCARG(uap, offset) < 0)
+ if (!special && (off_t)vattr.va_size + SCARG(uap, offset) < 0)
return (EINVAL);
fp->f_offset = SCARG(uap, offset) + vattr.va_size;
break;
case L_SET:
- if (SCARG(uap, offset) < 0)
+ if (!special && SCARG(uap, offset) < 0)
return (EINVAL);
fp->f_offset = SCARG(uap, offset);
break;