summaryrefslogtreecommitdiffstats
path: root/sys/fs/nfsclient/nfs_clrpcops.c
diff options
context:
space:
mode:
authorrmacklem <rmacklem@FreeBSD.org>2011-04-20 00:21:51 +0000
committerrmacklem <rmacklem@FreeBSD.org>2011-04-20 00:21:51 +0000
commit0c98c8ec08afc5fc5355f0979d8bd731f6648e1b (patch)
tree56960f7f7f3107b789df2418c6fe1f32c34e21cc /sys/fs/nfsclient/nfs_clrpcops.c
parent664be6d28d564878f33076aa934457da6ba70db7 (diff)
downloadFreeBSD-src-0c98c8ec08afc5fc5355f0979d8bd731f6648e1b.zip
FreeBSD-src-0c98c8ec08afc5fc5355f0979d8bd731f6648e1b.tar.gz
Modify the offset + size checks for read and write in the
experimental NFS client to take care of overflows. Thanks go to dillon at apollo.backplane.com for providing the snippet of code that does this. MFC after: 2 weeks
Diffstat (limited to 'sys/fs/nfsclient/nfs_clrpcops.c')
-rw-r--r--sys/fs/nfsclient/nfs_clrpcops.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c
index d95a56a..7af0852 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -1285,12 +1285,13 @@ nfsrpc_readrpc(vnode_t vp, struct uio *uiop, struct ucred *cred,
struct nfsmount *nmp = VFSTONFS(vnode_mount(vp));
struct nfsrv_descript *nd = &nfsd;
int rsize;
+ off_t tmp_off;
*attrflagp = 0;
tsiz = uio_uio_resid(uiop);
+ tmp_off = uiop->uio_offset + tsiz;
NFSLOCKMNT(nmp);
- if (uiop->uio_offset + tsiz > nmp->nm_maxfilesize) {
- /* XXX Needs overflow/negative check for uio_offset */
+ if (tmp_off > nmp->nm_maxfilesize || tmp_off < uiop->uio_offset) {
NFSUNLOCKMNT(nmp);
return (EFBIG);
}
@@ -1458,12 +1459,14 @@ nfsrpc_writerpc(vnode_t vp, struct uio *uiop, int *iomode,
struct nfsrv_descript nfsd;
struct nfsrv_descript *nd = &nfsd;
nfsattrbit_t attrbits;
+ off_t tmp_off;
KASSERT(uiop->uio_iovcnt == 1, ("nfs: writerpc iovcnt > 1"));
*attrflagp = 0;
tsiz = uio_uio_resid(uiop);
+ tmp_off = uiop->uio_offset + tsiz;
NFSLOCKMNT(nmp);
- if (uiop->uio_offset + tsiz > nmp->nm_maxfilesize) {
+ if (tmp_off > nmp->nm_maxfilesize || tmp_off < uiop->uio_offset) {
NFSUNLOCKMNT(nmp);
return (EFBIG);
}
OpenPOWER on IntegriCloud