svn commit: r257125 - in stable/9/sys: fs/devfs kern sys

Konstantin Belousov kib at FreeBSD.org
Fri Oct 25 17:04:47 UTC 2013


Author: kib
Date: Fri Oct 25 17:04:46 2013
New Revision: 257125
URL: http://svnweb.freebsd.org/changeset/base/257125

Log:
  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.

Modified:
  stable/9/sys/fs/devfs/devfs_vnops.c
  stable/9/sys/kern/sys_generic.c
  stable/9/sys/sys/systm.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/fs/   (props changed)
  stable/9/sys/sys/   (props changed)

Modified: stable/9/sys/fs/devfs/devfs_vnops.c
==============================================================================
--- stable/9/sys/fs/devfs/devfs_vnops.c	Fri Oct 25 16:49:32 2013	(r257124)
+++ stable/9/sys/fs/devfs/devfs_vnops.c	Fri Oct 25 17:04:46 2013	(r257125)
@@ -49,6 +49,7 @@
 #include <sys/filio.h>
 #include <sys/jail.h>
 #include <sys/kernel.h>
+#include <sys/limits.h>
 #include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/mount.h>
@@ -1178,6 +1179,8 @@ devfs_read_f(struct file *fp, struct uio
 	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 +1656,8 @@ devfs_write_f(struct file *fp, struct ui
 	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)

Modified: stable/9/sys/kern/sys_generic.c
==============================================================================
--- stable/9/sys/kern/sys_generic.c	Fri Oct 25 16:49:32 2013	(r257124)
+++ stable/9/sys/kern/sys_generic.c	Fri Oct 25 17:04:46 2013	(r257125)
@@ -77,6 +77,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

Modified: stable/9/sys/sys/systm.h
==============================================================================
--- stable/9/sys/sys/systm.h	Fri Oct 25 16:49:32 2013	(r257124)
+++ stable/9/sys/sys/systm.h	Fri Oct 25 17:04:46 2013	(r257125)
@@ -138,7 +138,9 @@ extern const void *zero_region;	/* addre
 
 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.


More information about the svn-src-stable-9 mailing list