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. Sponsored by: The FreeBSD Foundation Reminded by: Dmitry Sivachenko <trtrmitya@gmail.com> MFC after: 1 week
This commit is contained in:
parent
58fc49ff4f
commit
3dc87905fa
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user