summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-02-21 01:05:12 +0000
committerkib <kib@FreeBSD.org>2012-02-21 01:05:12 +0000
commit80ae8fe82cdaa69f78dc90fa27bc9e79863de0ea (patch)
treed0d078391c4959fc08545db4ab619daadd9cf1d9 /sys/fs
parent31a24bc1664a822f3d06595f42063719e6902ff1 (diff)
downloadFreeBSD-src-80ae8fe82cdaa69f78dc90fa27bc9e79863de0ea.zip
FreeBSD-src-80ae8fe82cdaa69f78dc90fa27bc9e79863de0ea.tar.gz
Fix found places where uio_resid is truncated to int.
Add the sysctl debug.iosize_max_clamp, enabled by default. Setting the sysctl to zero allows to perform the SSIZE_MAX-sized i/o requests from the usermode. Discussed with: bde, das (previous versions) MFC after: 1 month
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/cd9660/cd9660_vnops.c4
-rw-r--r--sys/fs/devfs/devfs_vnops.c6
-rw-r--r--sys/fs/ext2fs/ext2_lookup.c3
-rw-r--r--sys/fs/msdosfs/msdosfs_vnops.c4
-rw-r--r--sys/fs/nfsclient/nfs_clbio.c16
-rw-r--r--sys/fs/nfsclient/nfs_clvnops.c3
-rw-r--r--sys/fs/nfsserver/nfs_nfsdstate.c2
-rw-r--r--sys/fs/pseudofs/pseudofs_vnops.c3
-rw-r--r--sys/fs/udf/udf_vnops.c3
9 files changed, 25 insertions, 19 deletions
diff --git a/sys/fs/cd9660/cd9660_vnops.c b/sys/fs/cd9660/cd9660_vnops.c
index 5f4780f..9a6ecc2 100644
--- a/sys/fs/cd9660/cd9660_vnops.c
+++ b/sys/fs/cd9660/cd9660_vnops.c
@@ -318,7 +318,7 @@ cd9660_read(ap)
do {
lbn = lblkno(imp, uio->uio_offset);
on = blkoff(imp, uio->uio_offset);
- n = min((u_int)(imp->logical_block_size - on),
+ n = MIN((u_int)(imp->logical_block_size - on),
uio->uio_resid);
diff = (off_t)ip->i_size - uio->uio_offset;
if (diff <= 0)
@@ -343,7 +343,7 @@ cd9660_read(ap)
} else
error = bread(vp, lbn, size, NOCRED, &bp);
}
- n = min(n, size - bp->b_resid);
+ n = MIN(n, size - bp->b_resid);
if (error) {
brelse(bp);
return (error);
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c
index 408c981..4a58a42 100644
--- a/sys/fs/devfs/devfs_vnops.c
+++ b/sys/fs/devfs/devfs_vnops.c
@@ -1156,7 +1156,8 @@ static int
devfs_read_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td)
{
struct cdev *dev;
- int ioflag, error, ref, resid;
+ int ioflag, error, ref;
+ ssize_t resid;
struct cdevsw *dsw;
struct file *fpop;
@@ -1634,7 +1635,8 @@ static int
devfs_write_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td)
{
struct cdev *dev;
- int error, ioflag, ref, resid;
+ int error, ioflag, ref;
+ ssize_t resid;
struct cdevsw *dsw;
struct file *fpop;
diff --git a/sys/fs/ext2fs/ext2_lookup.c b/sys/fs/ext2fs/ext2_lookup.c
index 194cd35..35ab631 100644
--- a/sys/fs/ext2fs/ext2_lookup.c
+++ b/sys/fs/ext2fs/ext2_lookup.c
@@ -1001,7 +1001,8 @@ ext2_dirempty(ip, parentino, cred)
off_t off;
struct dirtemplate dbuf;
struct ext2fs_direct_2 *dp = (struct ext2fs_direct_2 *)&dbuf;
- int error, count, namlen;
+ int error, namlen;
+ ssize_t count;
#define MINDIRSIZ (sizeof(struct dirtemplate) / 2)
for (off = 0; off < ip->i_size; off += dp->e2d_reclen) {
diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
index 600aa0f..2c0920d 100644
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ b/sys/fs/msdosfs/msdosfs_vnops.c
@@ -543,7 +543,7 @@ msdosfs_read(ap)
int error = 0;
int blsize;
int isadir;
- int orig_resid;
+ ssize_t orig_resid;
u_int n;
u_long diff;
u_long on;
@@ -643,7 +643,7 @@ msdosfs_write(ap)
{
int n;
int croffset;
- int resid;
+ ssize_t resid;
u_long osize;
int error = 0;
u_long count;
diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c
index 82a3692..d63862e 100644
--- a/sys/fs/nfsclient/nfs_clbio.c
+++ b/sys/fs/nfsclient/nfs_clbio.c
@@ -570,7 +570,7 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
n = 0;
if (on < bcount)
- n = min((unsigned)(bcount - on), uio->uio_resid);
+ n = MIN((unsigned)(bcount - on), uio->uio_resid);
break;
case VLNK:
NFSINCRGLOBAL(newnfsstats.biocache_readlinks);
@@ -589,7 +589,7 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
return (error);
}
}
- n = min(uio->uio_resid, NFS_MAXPATHLEN - bp->b_resid);
+ n = MIN(uio->uio_resid, NFS_MAXPATHLEN - bp->b_resid);
on = 0;
break;
case VDIR:
@@ -757,8 +757,8 @@ nfs_directio_write(vp, uiop, cred, ioflag)
struct iovec iov;
do_sync:
while (uiop->uio_resid > 0) {
- size = min(uiop->uio_resid, wsize);
- size = min(uiop->uio_iov->iov_len, size);
+ size = MIN(uiop->uio_resid, wsize);
+ size = MIN(uiop->uio_iov->iov_len, size);
iov.iov_base = uiop->uio_iov->iov_base;
iov.iov_len = size;
uio.uio_iov = &iov;
@@ -806,8 +806,8 @@ do_sync:
* in NFS directio access.
*/
while (uiop->uio_resid > 0) {
- size = min(uiop->uio_resid, wsize);
- size = min(uiop->uio_iov->iov_len, size);
+ size = MIN(uiop->uio_resid, wsize);
+ size = MIN(uiop->uio_iov->iov_len, size);
bp = getpbuf(&ncl_pbuf_freecnt);
t_uio = malloc(sizeof(struct uio), M_NFSDIRECTIO, M_WAITOK);
t_iov = malloc(sizeof(struct iovec), M_NFSDIRECTIO, M_WAITOK);
@@ -1023,7 +1023,7 @@ flush_and_restart:
NFSINCRGLOBAL(newnfsstats.biocache_writes);
lbn = uio->uio_offset / biosize;
on = uio->uio_offset & (biosize-1);
- n = min((unsigned)(biosize - on), uio->uio_resid);
+ n = MIN((unsigned)(biosize - on), uio->uio_resid);
again:
/*
* Handle direct append and file extension cases, calculate
@@ -1572,7 +1572,7 @@ ncl_doio(struct vnode *vp, struct buf *bp, struct ucred *cr, struct thread *td,
* writes, but that is not possible any longer.
*/
int nread = bp->b_bcount - uiop->uio_resid;
- int left = uiop->uio_resid;
+ ssize_t left = uiop->uio_resid;
if (left > 0)
bzero((char *)bp->b_data + nread, left);
diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index c842c19..f92d193 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -2177,7 +2177,8 @@ nfs_readdir(struct vop_readdir_args *ap)
struct vnode *vp = ap->a_vp;
struct nfsnode *np = VTONFS(vp);
struct uio *uio = ap->a_uio;
- int tresid, error = 0;
+ ssize_t tresid;
+ int error = 0;
struct vattr vattr;
if (vp->v_type != VDIR)
diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c
index f14ad43..f44917e 100644
--- a/sys/fs/nfsserver/nfs_nfsdstate.c
+++ b/sys/fs/nfsserver/nfs_nfsdstate.c
@@ -3962,7 +3962,7 @@ nfsrv_setupstable(NFSPROC_T *p)
struct nfst_rec *tsp;
int error, i, tryagain;
off_t off = 0;
- int aresid, len;
+ ssize_t aresid, len;
struct timeval curtime;
/*
diff --git a/sys/fs/pseudofs/pseudofs_vnops.c b/sys/fs/pseudofs/pseudofs_vnops.c
index a81d7aa..8a9ca64 100644
--- a/sys/fs/pseudofs/pseudofs_vnops.c
+++ b/sys/fs/pseudofs/pseudofs_vnops.c
@@ -589,7 +589,8 @@ pfs_read(struct vop_read_args *va)
struct proc *proc;
struct sbuf *sb = NULL;
int error, locked;
- unsigned int buflen, offset, resid;
+ off_t offset;
+ ssize_t buflen, resid;
PFS_TRACE(("%s", pn->pn_name));
pfs_assert_not_owned(pn);
diff --git a/sys/fs/udf/udf_vnops.c b/sys/fs/udf/udf_vnops.c
index b8e39b3..7a99fcb 100644
--- a/sys/fs/udf/udf_vnops.c
+++ b/sys/fs/udf/udf_vnops.c
@@ -439,8 +439,9 @@ udf_read(struct vop_read_args *ap)
uint8_t *data;
daddr_t lbn, rablock;
off_t diff, fsize;
+ ssize_t n;
int error = 0;
- long size, n, on;
+ long size, on;
if (uio->uio_resid == 0)
return (0);
OpenPOWER on IntegriCloud