summaryrefslogtreecommitdiffstats
path: root/sys/sys/file.h
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2016-03-29 19:57:11 +0000
committerglebius <glebius@FreeBSD.org>2016-03-29 19:57:11 +0000
commite05176a63dbba4794d3d611cf9072885b3cf1eb3 (patch)
tree274dd1a656932d8fc3c71925baabc2c7c736dd84 /sys/sys/file.h
parenteb986c64f5239300e8fa17a18d24d0d3c574a259 (diff)
downloadFreeBSD-src-e05176a63dbba4794d3d611cf9072885b3cf1eb3.zip
FreeBSD-src-e05176a63dbba4794d3d611cf9072885b3cf1eb3.tar.gz
The sendfile(2) allows to send extra data from userspace before the file
data (headers). Historically the size of the headers was not checked against the socket buffer space. Application could easily overcommit the socket buffer space. With the new sendfile (r293439) the problem remained, but a KASSERT was inserted that checked that amount of data written to the socket matches its space. In case when size of headers is bigger that socket space, KASSERT fires. Without INVARIANTS the new sendfile won't panic, but would report incorrect amount of bytes sent. o With this change, the headers copyin is moved down into the cycle, after the sbspace() check. The uio size is trimmed by socket space there, which fixes the overcommit problem and its consequences. o The compatibility handling for FreeBSD 4 sendfile headers API is pushed up the stack to syscall wrappers. This required a copy and paste of the code, but in turn this allowed to remove extra stack carried parameter from fo_sendfile_t, and embrace entire compat code into #ifdef. If in future we got more fo_sendfile_t function, the copy and paste level would even reduce. Reviewed by: emax, gallatin, Maxim Dounin <mdounin mdounin.ru> Tested by: Vitalij Satanivskij <satan ukr.net> Sponsored by: Netflix
Diffstat (limited to 'sys/sys/file.h')
-rw-r--r--sys/sys/file.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/sys/file.h b/sys/sys/file.h
index 524c1ce..c30eb05 100644
--- a/sys/sys/file.h
+++ b/sys/sys/file.h
@@ -112,7 +112,7 @@ typedef int fo_chown_t(struct file *fp, uid_t uid, gid_t gid,
struct ucred *active_cred, struct thread *td);
typedef int fo_sendfile_t(struct file *fp, int sockfd, struct uio *hdr_uio,
struct uio *trl_uio, off_t offset, size_t nbytes,
- off_t *sent, int flags, int kflags, struct thread *td);
+ off_t *sent, int flags, struct thread *td);
typedef int fo_seek_t(struct file *fp, off_t offset, int whence,
struct thread *td);
typedef int fo_fill_kinfo_t(struct file *fp, struct kinfo_file *kif,
@@ -376,11 +376,11 @@ fo_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred,
static __inline int
fo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags,
- int kflags, struct thread *td)
+ struct thread *td)
{
return ((*fp->f_ops->fo_sendfile)(fp, sockfd, hdr_uio, trl_uio, offset,
- nbytes, sent, flags, kflags, td));
+ nbytes, sent, flags, td));
}
static __inline int
OpenPOWER on IntegriCloud