Permalink
Browse files

MFC r256502:

Similar to debug.iosize_max_clamp sysctl, introduce
devfs_iosize_max_clamp sysctl, which allows/disables SSIZE_MAX-sized
i/o requests on the devfs files.

Approved by:	re (glebius)
  • Loading branch information...
1 parent f2cf20f commit 3056ea94bbf733ca0aeeb7772efef40884382338 @kostikbel kostikbel committed Oct 25, 2013
Showing with 10 additions and 0 deletions.
  1. +4 −0 sys/fs/devfs/devfs_vnops.c
  2. +4 −0 sys/kern/sys_generic.c
  3. +2 −0 sys/sys/systm.h
@@ -1178,6 +1178,8 @@ devfs_read_f(struct file *fp, struct uio *uio, struct ucred *cred,
struct cdevsw *dsw;
struct file *fpop;
+ if (uio->uio_resid > DEVFS_IOSIZE_MAX)
+ return (EINVAL);
fpop = td->td_fpop;
error = devfs_fp_check(fp, &dev, &dsw, &ref);
if (error)
@@ -1653,6 +1655,8 @@ devfs_write_f(struct file *fp, struct uio *uio, struct ucred *cred,
struct cdevsw *dsw;
struct file *fpop;
+ if (uio->uio_resid > DEVFS_IOSIZE_MAX)
+ return (EINVAL);
fpop = td->td_fpop;
error = devfs_fp_check(fp, &dev, &dsw, &ref);
if (error)
@@ -78,6 +78,10 @@ __FBSDID("$FreeBSD$");
int iosize_max_clamp = 1;
SYSCTL_INT(_debug, OID_AUTO, iosize_max_clamp, CTLFLAG_RW,
&iosize_max_clamp, 0, "Clamp max i/o size to INT_MAX");
+int devfs_iosize_max_clamp = 1;
+SYSCTL_INT(_debug, OID_AUTO, devfs_iosize_max_clamp, CTLFLAG_RW,
+ &devfs_iosize_max_clamp, 0, "Clamp max i/o size to INT_MAX for devices");
+
/*
* Assert that the return value of read(2) and write(2) syscalls fits
* into a register. If not, an architecture will need to provide the
View
@@ -146,7 +146,9 @@ extern const void *zero_region; /* address space maps to a zeroed page */
extern int unmapped_buf_allowed;
extern int iosize_max_clamp;
+extern int devfs_iosize_max_clamp;
#define IOSIZE_MAX (iosize_max_clamp ? INT_MAX : SSIZE_MAX)
+#define DEVFS_IOSIZE_MAX (devfs_iosize_max_clamp ? INT_MAX : SSIZE_MAX)
/*
* General function declarations.

0 comments on commit 3056ea9

Please sign in to comment.