The branch stable/15 has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=595a705062dee0fd6ae804efe685defdeaba7cbb
commit 595a705062dee0fd6ae804efe685defdeaba7cbb Author: Jamie Gritton <ja...@freebsd.org> AuthorDate: 2025-09-09 18:13:11 +0000 Commit: Jamie Gritton <ja...@freebsd.org> CommitDate: 2025-09-13 22:37:38 +0000 MFC jaildesc: replace EBADF with EINVAL Following fd9e09cb, EBADF is not the suitable error code for a non- jail descriptor passed to jail_set, jail_get, jail_attach_fd, and jail_remove_fd. Reported by: kib (cherry picked from commit 16f600dc30b7bb82429660e540da802a1e3f7449) --- lib/libsys/jail.2 | 26 ++++++-------------------- sys/kern/kern_jaildesc.c | 2 +- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/lib/libsys/jail.2 b/lib/libsys/jail.2 index a0f47cc61cb3..a2640071d1f0 100644 --- a/lib/libsys/jail.2 +++ b/lib/libsys/jail.2 @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 4, 2025 +.Dd September 9, 2025 .Dt JAIL 2 .Os .Sh NAME @@ -402,15 +402,6 @@ The system call will fail if: .Bl -tag -width Er -.It Bq Er EBADF -The -.Va desc -parameter does not refer to a valid jail descriptor, -and either the -.Dv JAIL_USE_DESC -or -.Dv JAIL_AT_DESC -flag was set. .It Bq Er EACCES Write permission is denied on the jail descriptor in the .Va desc @@ -514,15 +505,6 @@ The system call will fail if: .Bl -tag -width Er -.It Bq Er EBADF -The -.Va desc -parameter does not refer to a valid jail descriptor, -and either the -.Dv JAIL_USE_DESC -or -.Dv JAIL_AT_DESC -flag was set. .It Bq Er EACCES Read permission is denied on the jail descriptor in the .Va desc @@ -564,6 +546,10 @@ parameter has been removed .It Bq Er EINVAL A supplied parameter is the wrong size. .It Bq Er EINVAL +A supplied parameter is out of range. +.It Bq Er EINVAL +A supplied string parameter is not null-terminated. +.It Bq Er EINVAL A supplied parameter name does not match any known parameters. .It Bq Er EMFILE A jail descriptor could not be created for the @@ -607,7 +593,7 @@ and system calls will fail if: .Bl -tag -width Er -.It Bq Er EBADF +.It Bq Er EINVAL The .Fa fd argument is not a valid jail descriptor. diff --git a/sys/kern/kern_jaildesc.c b/sys/kern/kern_jaildesc.c index fec9b5719b2e..b4ffad4c88e8 100644 --- a/sys/kern/kern_jaildesc.c +++ b/sys/kern/kern_jaildesc.c @@ -87,7 +87,7 @@ jaildesc_find(struct thread *td, int fd, struct jaildesc **jdp, if (error != 0) return (error); if (fp->f_type != DTYPE_JAILDESC) { - error = EBADF; + error = EINVAL; goto out; } jd = fp->f_data;