Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Jul 2026 20:53:26 +0000
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: fcee136ce056 - stable/15 - kern_writefile(): fix several regressions
Message-ID:  <6a5e8ac6.1c44d.5a7dd01c@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=fcee136ce0569314a07835171afb115081e1f0fa

commit fcee136ce0569314a07835171afb115081e1f0fa
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-07-08 19:21:00 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-07-20 20:26:04 +0000

    kern_writefile(): fix several regressions
    
    (cherry picked from commit 1364d8fd9b25d6d3e9618e7be073a1a1b41aa19c)
---
 sys/kern/kern_sendfile.c | 8 ++------
 sys/kern/sys_generic.c   | 6 +++---
 sys/sys/syscallsubr.h    | 2 +-
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c
index 9d08f9626d45..a64024cdafe3 100644
--- a/sys/kern/kern_sendfile.c
+++ b/sys/kern/kern_sendfile.c
@@ -1232,8 +1232,7 @@ prepend_header:
 
 		SOCK_IO_SEND_UNLOCK(so);
 		CURVNET_RESTORE();
-		error = kern_filewrite(td, sockfd, sock_fp, trl_uio,
-		    (off_t)-1, 0, &cnt);
+		error = kern_filewrite(td, sockfd, sock_fp, trl_uio, 0, &cnt);
 		if (error == 0)
 			sbytes += cnt;
 		goto out;
@@ -1325,10 +1324,7 @@ sendfile(struct thread *td, struct sendfile_args *uap, int compat)
 			    &trl_uio);
 			if (error != 0)
 				goto out;
-			if (trl_uio->uio_rw != UIO_WRITE) {
-				error = EINVAL;
-				goto out;
-			}
+			trl_uio->uio_rw = UIO_WRITE;
 			trl_uio->uio_td = td;
 		}
 	}
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index cfc3b6f88c34..1b88581714d2 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -555,7 +555,7 @@ dofilewrite(struct thread *td, int fd, struct file *fp, struct uio *auio,
 	auio->uio_rw = UIO_WRITE;
 	auio->uio_td = td;
 	auio->uio_offset = offset;
-	error = kern_filewrite(td, fd, fp, auio, offset, flags, &cnt);
+	error = kern_filewrite(td, fd, fp, auio, flags, &cnt);
 
 	/*
 	 * Handle short writes and generate SIGPIPE if needed.
@@ -563,7 +563,7 @@ dofilewrite(struct thread *td, int fd, struct file *fp, struct uio *auio,
 	 * see sousrsend().
 	 */
 	if (error != 0 && fp->f_type != DTYPE_SOCKET) {
-		if (auio->uio_resid != cnt && (error == ERESTART ||
+		if (cnt != 0 && (error == ERESTART ||
 		    error == EINTR || error == EWOULDBLOCK))
 			error = 0;
 		if (error == EPIPE) {
@@ -584,7 +584,7 @@ dofilewrite(struct thread *td, int fd, struct file *fp, struct uio *auio,
  */
 int
 kern_filewrite(struct thread *td, int fd, struct file *fp, struct uio *auio,
-    off_t offset, int flags, ssize_t *cntp)
+    int flags, ssize_t *cntp)
 {
 	ssize_t cnt;
 	int error;
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index 439edb427ada..164b3d874cf6 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -173,7 +173,7 @@ int	kern_fhopen(struct thread *td, const struct fhandle *u_fhp, int flags);
 int	kern_fhstat(struct thread *td, fhandle_t fh, struct stat *buf);
 int	kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf);
 int	kern_filewrite(struct thread *td, int fd, struct file *fp,
-	    struct uio *auio, off_t offset, int flags, ssize_t *cntp);
+	    struct uio *auio, int flags, ssize_t *cntp);
 int	kern_fpathconf(struct thread *td, int fd, int name, long *valuep);
 int	kern_freebsd11_getfsstat(struct thread *td,
 	    struct freebsd11_statfs *ubuf, long bufsize, int mode);


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a5e8ac6.1c44d.5a7dd01c>