Re: CURRENT r296381 panic in vn_sendfile (/usr/src/sys/kern/kern_sendfile.c:833)

From: Vitalij Satanivskij <satan_at_ukr.net>
Date: Tue, 29 Mar 2016 12:42:22 +0300
Just forget, system was upgraded to 296385 (just sync with another servers )


Vitalij Satanivskij wrote:
VS> 
VS> Hello.
VS> 
VS> OK about 3 hours with last patch 
VS> 
VS> No panic. 
VS> 
VS> Sysctl - 
VS> sysctl kern.ipc.sf_long_headers
VS> kern.ipc.sf_long_headers: 1
VS> 
VS> 
VS> Gleb Smirnoff wrote:
VS> GS>   Vitalij,
VS> GS> 
VS> GS>   here is latest version of the patch. If you already run the
VS> GS> previous one, no need to switch to this one, keep running as is.
VS> GS> The update covers only FreeBSD 4 and i386 compatibilties.
VS> GS> 
VS> GS> current_at_, a review is appreciated. The patch not only fixes a
VS> GS> recent bug, but also fixes a long standing problem that headers
VS> GS> were not checked against socket buffer size. One could push
VS> GS> unlimited data into sendfile() with headers. The patch also
VS> GS> pushes also compat code under ifdef, so it is cut away if
VS> GS> you aren't interested in COMPAT_FREEBSD4.
VS> GS> 
VS> GS> On Wed, Mar 23, 2016 at 04:59:25PM -0700, Gleb Smirnoff wrote:
VS> GS> T>   Vitalij,
VS> GS> T> 
VS> GS> T>   although the first patch should fixup the panic, can you please
VS> GS> T> instead run this one. And if it is possible, can you please
VS> GS> T> monitor this sysctl:
VS> GS> T> 
VS> GS> T> sysctl kern.ipc.sf_long_headers
VS> GS> T> 
VS> GS> T> 
VS> GS> T> -- 
VS> GS> T> Totus tuus, Glebius.
VS> GS> 
VS> GS> T> Index: sys/kern/kern_descrip.c
VS> GS> T> ===================================================================
VS> GS> T> --- sys/kern/kern_descrip.c	(revision 297217)
VS> GS> T> +++ sys/kern/kern_descrip.c	(working copy)
VS> GS> T> _at__at_ -3958,7 +3958,7 _at__at_ badfo_chown(struct file *fp, uid_t uid, gid_t gid,
VS> GS> T>  static int
VS> GS> T>  badfo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
VS> GS> T>      struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags,
VS> GS> T> -    int kflags, struct thread *td)
VS> GS> T> +    struct thread *td)
VS> GS> T>  {
VS> GS> T>  
VS> GS> T>  	return (EBADF);
VS> GS> T> _at__at_ -4044,7 +4044,7 _at__at_ invfo_chown(struct file *fp, uid_t uid, gid_t gid,
VS> GS> T>  int
VS> GS> T>  invfo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
VS> GS> T>      struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags,
VS> GS> T> -    int kflags, struct thread *td)
VS> GS> T> +    struct thread *td)
VS> GS> T>  {
VS> GS> T>  
VS> GS> T>  	return (EINVAL);
VS> GS> T> Index: sys/kern/kern_sendfile.c
VS> GS> T> ===================================================================
VS> GS> T> --- sys/kern/kern_sendfile.c	(revision 297217)
VS> GS> T> +++ sys/kern/kern_sendfile.c	(working copy)
VS> GS> T> _at__at_ -95,6 +95,7 _at__at_ struct sendfile_sync {
VS> GS> T>  };
VS> GS> T>  
VS> GS> T>  counter_u64_t sfstat[sizeof(struct sfstat) / sizeof(uint64_t)];
VS> GS> T> +static counter_u64_t sf_long_headers; /* QQQGL */
VS> GS> T>  
VS> GS> T>  static void
VS> GS> T>  sfstat_init(const void *unused)
VS> GS> T> _at__at_ -102,6 +103,7 _at__at_ sfstat_init(const void *unused)
VS> GS> T>  
VS> GS> T>  	COUNTER_ARRAY_ALLOC(sfstat, sizeof(struct sfstat) / sizeof(uint64_t),
VS> GS> T>  	    M_WAITOK);
VS> GS> T> +	sf_long_headers = counter_u64_alloc(M_WAITOK); /* QQQGL */
VS> GS> T>  }
VS> GS> T>  SYSINIT(sfstat, SI_SUB_MBUF, SI_ORDER_FIRST, sfstat_init, NULL);
VS> GS> T>  
VS> GS> T> _at__at_ -117,6 +119,8 _at__at_ sfstat_sysctl(SYSCTL_HANDLER_ARGS)
VS> GS> T>  }
VS> GS> T>  SYSCTL_PROC(_kern_ipc, OID_AUTO, sfstat, CTLTYPE_OPAQUE | CTLFLAG_RW,
VS> GS> T>      NULL, 0, sfstat_sysctl, "I", "sendfile statistics");
VS> GS> T> +SYSCTL_COUNTER_U64(_kern_ipc, OID_AUTO, sf_long_headers, CTLFLAG_RW,
VS> GS> T> +    &sf_long_headers, "times headers did not fit into socket buffer");
VS> GS> T>  
VS> GS> T>  /*
VS> GS> T>   * Detach mapped page and release resources back to the system.  Called
VS> GS> T> _at__at_ -516,7 +520,7 _at__at_ sendfile_getsock(struct thread *td, int s, struct
VS> GS> T>  int
VS> GS> T>  vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
VS> GS> T>      struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags,
VS> GS> T> -    int kflags, struct thread *td)
VS> GS> T> +    struct thread *td)
VS> GS> T>  {
VS> GS> T>  	struct file *sock_fp;
VS> GS> T>  	struct vnode *vp;
VS> GS> T> _at__at_ -534,7 +538,7 _at__at_ vn_sendfile(struct file *fp, int sockfd, struct ui
VS> GS> T>  	so = NULL;
VS> GS> T>  	m = mh = NULL;
VS> GS> T>  	sfs = NULL;
VS> GS> T> -	sbytes = 0;
VS> GS> T> +	hdrlen = sbytes = 0;
VS> GS> T>  	softerr = 0;
VS> GS> T>  
VS> GS> T>  	error = sendfile_getobj(td, fp, &obj, &vp, &shmfd, &obj_size, &bsize);
VS> GS> T> _at__at_ -560,26 +564,6 _at__at_ vn_sendfile(struct file *fp, int sockfd, struct ui
VS> GS> T>  		cv_init(&sfs->cv, "sendfile");
VS> GS> T>  	}
VS> GS> T>  
VS> GS> T> -	/* If headers are specified copy them into mbufs. */
VS> GS> T> -	if (hdr_uio != NULL && hdr_uio->uio_resid > 0) {
VS> GS> T> -		hdr_uio->uio_td = td;
VS> GS> T> -		hdr_uio->uio_rw = UIO_WRITE;
VS> GS> T> -		/*
VS> GS> T> -		 * In FBSD < 5.0 the nbytes to send also included
VS> GS> T> -		 * the header.  If compat is specified subtract the
VS> GS> T> -		 * header size from nbytes.
VS> GS> T> -		 */
VS> GS> T> -		if (kflags & SFK_COMPAT) {
VS> GS> T> -			if (nbytes > hdr_uio->uio_resid)
VS> GS> T> -				nbytes -= hdr_uio->uio_resid;
VS> GS> T> -			else
VS> GS> T> -				nbytes = 0;
VS> GS> T> -		}
VS> GS> T> -		mh = m_uiotombuf(hdr_uio, M_WAITOK, 0, 0, 0);
VS> GS> T> -		hdrlen = m_length(mh, &mhtail);
VS> GS> T> -	} else
VS> GS> T> -		hdrlen = 0;
VS> GS> T> -
VS> GS> T>  	rem = nbytes ? omin(nbytes, obj_size - offset) : obj_size - offset;
VS> GS> T>  
VS> GS> T>  	/*
VS> GS> T> _at__at_ -668,11 +652,23 _at__at_ retry_space:
VS> GS> T>  		SOCKBUF_UNLOCK(&so->so_snd);
VS> GS> T>  
VS> GS> T>  		/*
VS> GS> T> -		 * Reduce space in the socket buffer by the size of
VS> GS> T> -		 * the header mbuf chain.
VS> GS> T> -		 * hdrlen is set to 0 after the first loop.
VS> GS> T> +		 * At the beginning of the first loop check if any headers
VS> GS> T> +		 * are specified and copy them into mbufs.  Reduce space in
VS> GS> T> +		 * the socket buffer by the size of the header mbuf chain.
VS> GS> T> +		 * Clear hdr_uio here and hdrlen at the end of the first loop.
VS> GS> T>  		 */
VS> GS> T> -		space -= hdrlen;
VS> GS> T> +		if (hdr_uio != NULL) {
VS> GS> T> +			hdr_uio->uio_td = td;
VS> GS> T> +			hdr_uio->uio_rw = UIO_WRITE;
VS> GS> T> +			/* QQQGL remove counter */
VS> GS> T> +			if (space < hdr_uio->uio_resid)
VS> GS> T> +				counter_u64_add(sf_long_headers, 1);
VS> GS> T> +			hdr_uio->uio_resid = min(hdr_uio->uio_resid, space);
VS> GS> T> +			mh = m_uiotombuf(hdr_uio, M_WAITOK, 0, 0, 0);
VS> GS> T> +			hdrlen = m_length(mh, &mhtail);
VS> GS> T> +			space -= hdrlen;
VS> GS> T> +			hdr_uio = NULL;
VS> GS> T> +		}
VS> GS> T>  
VS> GS> T>  		if (vp != NULL) {
VS> GS> T>  			error = vn_lock(vp, LK_SHARED);
VS> GS> T> _at__at_ -944,6 +940,17 _at__at_ sendfile(struct thread *td, struct sendfile_args *
VS> GS> T>  			    &hdr_uio);
VS> GS> T>  			if (error != 0)
VS> GS> T>  				goto out;
VS> GS> T> +			/*
VS> GS> T> +			 * In FBSD < 5.0 the nbytes to send also included
VS> GS> T> +			 * the header.  If compat is specified subtract the
VS> GS> T> +			 * header size from nbytes.
VS> GS> T> +			 */
VS> GS> T> +			if (compat) {
VS> GS> T> +				if (uap->nbytes > hdr_uio->uio_resid)
VS> GS> T> +					uap->nbytes -= hdr_uio->uio_resid;
VS> GS> T> +				else
VS> GS> T> +					uap->nbytes = 0;
VS> GS> T> +			}
VS> GS> T>  		}
VS> GS> T>  		if (hdtr.trailers != NULL) {
VS> GS> T>  			error = copyinuio(hdtr.trailers, hdtr.trl_cnt,
VS> GS> T> _at__at_ -965,7 +972,7 _at__at_ sendfile(struct thread *td, struct sendfile_args *
VS> GS> T>  	}
VS> GS> T>  
VS> GS> T>  	error = fo_sendfile(fp, uap->s, hdr_uio, trl_uio, uap->offset,
VS> GS> T> -	    uap->nbytes, &sbytes, uap->flags, compat ? SFK_COMPAT : 0, td);
VS> GS> T> +	    uap->nbytes, &sbytes, uap->flags, td);
VS> GS> T>  	fdrop(fp, td);
VS> GS> T>  
VS> GS> T>  	if (uap->sbytes != NULL)
VS> GS> T> Index: sys/sys/file.h
VS> GS> T> ===================================================================
VS> GS> T> --- sys/sys/file.h	(revision 297217)
VS> GS> T> +++ sys/sys/file.h	(working copy)
VS> GS> T> _at__at_ -112,7 +112,7 _at__at_ typedef	int fo_chown_t(struct file *fp, uid_t uid,
VS> GS> T>  		    struct ucred *active_cred, struct thread *td);
VS> GS> T>  typedef int fo_sendfile_t(struct file *fp, int sockfd, struct uio *hdr_uio,
VS> GS> T>  		    struct uio *trl_uio, off_t offset, size_t nbytes,
VS> GS> T> -		    off_t *sent, int flags, int kflags, struct thread *td);
VS> GS> T> +		    off_t *sent, int flags, struct thread *td);
VS> GS> T>  typedef int fo_seek_t(struct file *fp, off_t offset, int whence,
VS> GS> T>  		    struct thread *td);
VS> GS> T>  typedef int fo_fill_kinfo_t(struct file *fp, struct kinfo_file *kif,
VS> GS> T> _at__at_ -376,11 +376,11 _at__at_ fo_chown(struct file *fp, uid_t uid, gid_t gid, st
VS> GS> T>  static __inline int
VS> GS> T>  fo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
VS> GS> T>      struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags,
VS> GS> T> -    int kflags, struct thread *td)
VS> GS> T> +    struct thread *td)
VS> GS> T>  {
VS> GS> T>  
VS> GS> T>  	return ((*fp->f_ops->fo_sendfile)(fp, sockfd, hdr_uio, trl_uio, offset,
VS> GS> T> -	    nbytes, sent, flags, kflags, td));
VS> GS> T> +	    nbytes, sent, flags, td));
VS> GS> T>  }
VS> GS> T>  
VS> GS> T>  static __inline int
VS> GS> T> Index: sys/sys/socket.h
VS> GS> T> ===================================================================
VS> GS> T> --- sys/sys/socket.h	(revision 297217)
VS> GS> T> +++ sys/sys/socket.h	(working copy)
VS> GS> T> _at__at_ -594,7 +594,6 _at__at_ struct sf_hdtr {
VS> GS> T>  #define	SF_FLAGS(rh, flags)	(((rh) << 16) | (flags))
VS> GS> T>  
VS> GS> T>  #ifdef _KERNEL
VS> GS> T> -#define	SFK_COMPAT	0x00000001
VS> GS> T>  #define	SF_READAHEAD(flags)	((flags) >> 16)
VS> GS> T>  #endif /* _KERNEL */
VS> GS> T>  
VS> GS> 
VS> GS> T> _______________________________________________
VS> GS> T> freebsd-current_at_freebsd.org mailing list
VS> GS> T> https://lists.freebsd.org/mailman/listinfo/freebsd-current
VS> GS> T> To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"
VS> GS> 
VS> GS> 
VS> GS> -- 
VS> GS> Totus tuus, Glebius.
VS> 
VS> GS> Index: sys/compat/freebsd32/freebsd32_misc.c
VS> GS> ===================================================================
VS> GS> --- sys/compat/freebsd32/freebsd32_misc.c	(revision 297366)
VS> GS> +++ sys/compat/freebsd32/freebsd32_misc.c	(working copy)
VS> GS> _at__at_ -1653,6 +1653,19 _at__at_ freebsd32_do_sendfile(struct thread *td,
VS> GS>  			    hdtr32.hdr_cnt, &hdr_uio);
VS> GS>  			if (error)
VS> GS>  				goto out;
VS> GS> +#ifdef COMPAT_FREEBSD4
VS> GS> +			/*
VS> GS> +			 * In FreeBSD < 5.0 the nbytes to send also included
VS> GS> +			 * the header.  If compat is specified subtract the
VS> GS> +			 * header size from nbytes.
VS> GS> +			 */
VS> GS> +			if (compat) {
VS> GS> +				if (uap->nbytes > hdr_uio->uio_resid)
VS> GS> +					uap->nbytes -= hdr_uio->uio_resid;
VS> GS> +				else
VS> GS> +					uap->nbytes = 0;
VS> GS> +			}
VS> GS> +#endif
VS> GS>  		}
VS> GS>  		if (hdtr.trailers != NULL) {
VS> GS>  			iov32 = PTRIN(hdtr32.trailers);
VS> GS> _at__at_ -1670,7 +1683,7 _at__at_ freebsd32_do_sendfile(struct thread *td,
VS> GS>  		goto out;
VS> GS>  
VS> GS>  	error = fo_sendfile(fp, uap->s, hdr_uio, trl_uio, offset,
VS> GS> -	    uap->nbytes, &sbytes, uap->flags, compat ? SFK_COMPAT : 0, td);
VS> GS> +	    uap->nbytes, &sbytes, uap->flags, td);
VS> GS>  	fdrop(fp, td);
VS> GS>  
VS> GS>  	if (uap->sbytes != NULL)
VS> GS> Index: sys/kern/kern_descrip.c
VS> GS> ===================================================================
VS> GS> --- sys/kern/kern_descrip.c	(revision 297366)
VS> GS> +++ sys/kern/kern_descrip.c	(working copy)
VS> GS> _at__at_ -3958,7 +3958,7 _at__at_ badfo_chown(struct file *fp, uid_t uid, gid_t gid,
VS> GS>  static int
VS> GS>  badfo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
VS> GS>      struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags,
VS> GS> -    int kflags, struct thread *td)
VS> GS> +    struct thread *td)
VS> GS>  {
VS> GS>  
VS> GS>  	return (EBADF);
VS> GS> _at__at_ -4044,7 +4044,7 _at__at_ invfo_chown(struct file *fp, uid_t uid, gid_t gid,
VS> GS>  int
VS> GS>  invfo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
VS> GS>      struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags,
VS> GS> -    int kflags, struct thread *td)
VS> GS> +    struct thread *td)
VS> GS>  {
VS> GS>  
VS> GS>  	return (EINVAL);
VS> GS> Index: sys/kern/kern_sendfile.c
VS> GS> ===================================================================
VS> GS> --- sys/kern/kern_sendfile.c	(revision 297366)
VS> GS> +++ sys/kern/kern_sendfile.c	(working copy)
VS> GS> _at__at_ -95,6 +95,7 _at__at_ struct sendfile_sync {
VS> GS>  };
VS> GS>  
VS> GS>  counter_u64_t sfstat[sizeof(struct sfstat) / sizeof(uint64_t)];
VS> GS> +static counter_u64_t sf_long_headers; /* QQQGL */
VS> GS>  
VS> GS>  static void
VS> GS>  sfstat_init(const void *unused)
VS> GS> _at__at_ -102,6 +103,7 _at__at_ sfstat_init(const void *unused)
VS> GS>  
VS> GS>  	COUNTER_ARRAY_ALLOC(sfstat, sizeof(struct sfstat) / sizeof(uint64_t),
VS> GS>  	    M_WAITOK);
VS> GS> +	sf_long_headers = counter_u64_alloc(M_WAITOK); /* QQQGL */
VS> GS>  }
VS> GS>  SYSINIT(sfstat, SI_SUB_MBUF, SI_ORDER_FIRST, sfstat_init, NULL);
VS> GS>  
VS> GS> _at__at_ -117,6 +119,9 _at__at_ sfstat_sysctl(SYSCTL_HANDLER_ARGS)
VS> GS>  }
VS> GS>  SYSCTL_PROC(_kern_ipc, OID_AUTO, sfstat, CTLTYPE_OPAQUE | CTLFLAG_RW,
VS> GS>      NULL, 0, sfstat_sysctl, "I", "sendfile statistics");
VS> GS> +/* QQQGL */
VS> GS> +SYSCTL_COUNTER_U64(_kern_ipc, OID_AUTO, sf_long_headers, CTLFLAG_RW,
VS> GS> +    &sf_long_headers, "times headers did not fit into socket buffer");
VS> GS>  
VS> GS>  /*
VS> GS>   * Detach mapped page and release resources back to the system.  Called
VS> GS> _at__at_ -516,7 +521,7 _at__at_ sendfile_getsock(struct thread *td, int s, struct
VS> GS>  int
VS> GS>  vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
VS> GS>      struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags,
VS> GS> -    int kflags, struct thread *td)
VS> GS> +    struct thread *td)
VS> GS>  {
VS> GS>  	struct file *sock_fp;
VS> GS>  	struct vnode *vp;
VS> GS> _at__at_ -534,7 +539,7 _at__at_ vn_sendfile(struct file *fp, int sockfd, struct ui
VS> GS>  	so = NULL;
VS> GS>  	m = mh = NULL;
VS> GS>  	sfs = NULL;
VS> GS> -	sbytes = 0;
VS> GS> +	hdrlen = sbytes = 0;
VS> GS>  	softerr = 0;
VS> GS>  
VS> GS>  	error = sendfile_getobj(td, fp, &obj, &vp, &shmfd, &obj_size, &bsize);
VS> GS> _at__at_ -560,26 +565,6 _at__at_ vn_sendfile(struct file *fp, int sockfd, struct ui
VS> GS>  		cv_init(&sfs->cv, "sendfile");
VS> GS>  	}
VS> GS>  
VS> GS> -	/* If headers are specified copy them into mbufs. */
VS> GS> -	if (hdr_uio != NULL && hdr_uio->uio_resid > 0) {
VS> GS> -		hdr_uio->uio_td = td;
VS> GS> -		hdr_uio->uio_rw = UIO_WRITE;
VS> GS> -		/*
VS> GS> -		 * In FBSD < 5.0 the nbytes to send also included
VS> GS> -		 * the header.  If compat is specified subtract the
VS> GS> -		 * header size from nbytes.
VS> GS> -		 */
VS> GS> -		if (kflags & SFK_COMPAT) {
VS> GS> -			if (nbytes > hdr_uio->uio_resid)
VS> GS> -				nbytes -= hdr_uio->uio_resid;
VS> GS> -			else
VS> GS> -				nbytes = 0;
VS> GS> -		}
VS> GS> -		mh = m_uiotombuf(hdr_uio, M_WAITOK, 0, 0, 0);
VS> GS> -		hdrlen = m_length(mh, &mhtail);
VS> GS> -	} else
VS> GS> -		hdrlen = 0;
VS> GS> -
VS> GS>  	rem = nbytes ? omin(nbytes, obj_size - offset) : obj_size - offset;
VS> GS>  
VS> GS>  	/*
VS> GS> _at__at_ -668,11 +653,23 _at__at_ retry_space:
VS> GS>  		SOCKBUF_UNLOCK(&so->so_snd);
VS> GS>  
VS> GS>  		/*
VS> GS> -		 * Reduce space in the socket buffer by the size of
VS> GS> -		 * the header mbuf chain.
VS> GS> -		 * hdrlen is set to 0 after the first loop.
VS> GS> +		 * At the beginning of the first loop check if any headers
VS> GS> +		 * are specified and copy them into mbufs.  Reduce space in
VS> GS> +		 * the socket buffer by the size of the header mbuf chain.
VS> GS> +		 * Clear hdr_uio here and hdrlen at the end of the first loop.
VS> GS>  		 */
VS> GS> -		space -= hdrlen;
VS> GS> +		if (hdr_uio != NULL && hdr_uio->uio_resid > 0) {
VS> GS> +			hdr_uio->uio_td = td;
VS> GS> +			hdr_uio->uio_rw = UIO_WRITE;
VS> GS> +			/* QQQGL remove counter */
VS> GS> +			if (space < hdr_uio->uio_resid)
VS> GS> +				counter_u64_add(sf_long_headers, 1);
VS> GS> +			hdr_uio->uio_resid = min(hdr_uio->uio_resid, space);
VS> GS> +			mh = m_uiotombuf(hdr_uio, M_WAITOK, 0, 0, 0);
VS> GS> +			hdrlen = m_length(mh, &mhtail);
VS> GS> +			space -= hdrlen;
VS> GS> +			hdr_uio = NULL;
VS> GS> +		}
VS> GS>  
VS> GS>  		if (vp != NULL) {
VS> GS>  			error = vn_lock(vp, LK_SHARED);
VS> GS> _at__at_ -944,6 +941,19 _at__at_ sendfile(struct thread *td, struct sendfile_args *
VS> GS>  			    &hdr_uio);
VS> GS>  			if (error != 0)
VS> GS>  				goto out;
VS> GS> +#ifdef COMPAT_FREEBSD4
VS> GS> +			/*
VS> GS> +			 * In FreeBSD < 5.0 the nbytes to send also included
VS> GS> +			 * the header.  If compat is specified subtract the
VS> GS> +			 * header size from nbytes.
VS> GS> +			 */
VS> GS> +			if (compat) {
VS> GS> +				if (uap->nbytes > hdr_uio->uio_resid)
VS> GS> +					uap->nbytes -= hdr_uio->uio_resid;
VS> GS> +				else
VS> GS> +					uap->nbytes = 0;
VS> GS> +			}
VS> GS> +#endif
VS> GS>  		}
VS> GS>  		if (hdtr.trailers != NULL) {
VS> GS>  			error = copyinuio(hdtr.trailers, hdtr.trl_cnt,
VS> GS> _at__at_ -965,7 +975,7 _at__at_ sendfile(struct thread *td, struct sendfile_args *
VS> GS>  	}
VS> GS>  
VS> GS>  	error = fo_sendfile(fp, uap->s, hdr_uio, trl_uio, uap->offset,
VS> GS> -	    uap->nbytes, &sbytes, uap->flags, compat ? SFK_COMPAT : 0, td);
VS> GS> +	    uap->nbytes, &sbytes, uap->flags, td);
VS> GS>  	fdrop(fp, td);
VS> GS>  
VS> GS>  	if (uap->sbytes != NULL)
VS> GS> Index: sys/sys/file.h
VS> GS> ===================================================================
VS> GS> --- sys/sys/file.h	(revision 297366)
VS> GS> +++ sys/sys/file.h	(working copy)
VS> GS> _at__at_ -112,7 +112,7 _at__at_ typedef	int fo_chown_t(struct file *fp, uid_t uid,
VS> GS>  		    struct ucred *active_cred, struct thread *td);
VS> GS>  typedef int fo_sendfile_t(struct file *fp, int sockfd, struct uio *hdr_uio,
VS> GS>  		    struct uio *trl_uio, off_t offset, size_t nbytes,
VS> GS> -		    off_t *sent, int flags, int kflags, struct thread *td);
VS> GS> +		    off_t *sent, int flags, struct thread *td);
VS> GS>  typedef int fo_seek_t(struct file *fp, off_t offset, int whence,
VS> GS>  		    struct thread *td);
VS> GS>  typedef int fo_fill_kinfo_t(struct file *fp, struct kinfo_file *kif,
VS> GS> _at__at_ -376,11 +376,11 _at__at_ fo_chown(struct file *fp, uid_t uid, gid_t gid, st
VS> GS>  static __inline int
VS> GS>  fo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
VS> GS>      struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags,
VS> GS> -    int kflags, struct thread *td)
VS> GS> +    struct thread *td)
VS> GS>  {
VS> GS>  
VS> GS>  	return ((*fp->f_ops->fo_sendfile)(fp, sockfd, hdr_uio, trl_uio, offset,
VS> GS> -	    nbytes, sent, flags, kflags, td));
VS> GS> +	    nbytes, sent, flags, td));
VS> GS>  }
VS> GS>  
VS> GS>  static __inline int
VS> GS> Index: sys/sys/socket.h
VS> GS> ===================================================================
VS> GS> --- sys/sys/socket.h	(revision 297366)
VS> GS> +++ sys/sys/socket.h	(working copy)
VS> GS> _at__at_ -594,7 +594,6 _at__at_ struct sf_hdtr {
VS> GS>  #define	SF_FLAGS(rh, flags)	(((rh) << 16) | (flags))
VS> GS>  
VS> GS>  #ifdef _KERNEL
VS> GS> -#define	SFK_COMPAT	0x00000001
VS> GS>  #define	SF_READAHEAD(flags)	((flags) >> 16)
VS> GS>  #endif /* _KERNEL */
VS> GS>  
VS> 
VS> GS> _______________________________________________
VS> GS> freebsd-current_at_freebsd.org mailing list
VS> GS> https://lists.freebsd.org/mailman/listinfo/freebsd-current
VS> GS> To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"
VS> 
VS> _______________________________________________
VS> freebsd-current_at_freebsd.org mailing list
VS> https://lists.freebsd.org/mailman/listinfo/freebsd-current
VS> To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"
Received on Tue Mar 29 2016 - 07:42:25 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:03 UTC