summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorniklas <niklas@openbsd.org>1997-02-26 16:38:20 +0000
committerniklas <niklas@openbsd.org>1997-02-26 16:38:20 +0000
commit9fc358adb88bd1712c3d7dad87138c151d8ad934 (patch)
tree2851ac1c6c370fbd34c7342bb68481333ac69580
parentAdd IP-SEC (diff)
downloadwireguard-openbsd-9fc358adb88bd1712c3d7dad87138c151d8ad934.tar.xz
wireguard-openbsd-9fc358adb88bd1712c3d7dad87138c151d8ad934.zip
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.
-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;