summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-02-14 18:17:58 +0000
committerkib <kib@FreeBSD.org>2016-02-14 18:17:58 +0000
commitc1aec037c122dcfdea3e2f0b0212dc2e28f0f09e (patch)
tree0c705fda325a069a969690b1a295f9fb71410a91 /sys/kern
parent8b9d16815392c18a9a8b20089db0506d3b80e711 (diff)
downloadFreeBSD-src-c1aec037c122dcfdea3e2f0b0212dc2e28f0f09e.zip
FreeBSD-src-c1aec037c122dcfdea3e2f0b0212dc2e28f0f09e.tar.gz
MFC r294596:
Limit the accesses to file' f_advice member to VREG vnodes only. Recheck that f_advice is not NULL after lock is taken. Approved by: re (marius)
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_vnops.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index d4c8693..e35fd35 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -733,12 +733,13 @@ get_advice(struct file *fp, struct uio *uio)
int ret;
ret = POSIX_FADV_NORMAL;
- if (fp->f_advice == NULL)
+ if (fp->f_advice == NULL || fp->f_vnode->v_type != VREG)
return (ret);
mtxp = mtx_pool_find(mtxpool_sleep, fp);
mtx_lock(mtxp);
- if (uio->uio_offset >= fp->f_advice->fa_start &&
+ if (fp->f_advice != NULL &&
+ uio->uio_offset >= fp->f_advice->fa_start &&
uio->uio_offset + uio->uio_resid <= fp->f_advice->fa_end)
ret = fp->f_advice->fa_advice;
mtx_unlock(mtxp);
OpenPOWER on IntegriCloud