jail_{get,set}: user_ implementations

This will enable compat implementations in the future.

Reviewed by:	jamie, jhb
Effort:		CHERI upstreaming
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D60026
This commit is contained in:
Brooks Davis committed 2026-09-29 19:14:07 +01:00
1 parent afe41f1ab9
commit 2127135a22
2 files changed
+29 -8

No files matched your search

+24 -8
View File
@@ -575,18 +575,26 @@ kern_jail(struct thread *td, struct jail *j)
*/
int
sys_jail_set(struct thread *td, struct jail_set_args *uap)
{
return (user_jail_set(td, uap->iovp, uap->iovcnt, uap->flags,
copyinuio));
}
int
user_jail_set(struct thread *td, struct iovec *iovp,
unsigned int iovcnt, int flags, copyinuio_t *copyinuio_f)
{
struct uio *auio;
int error;
/* Check that we have an even number of iovecs. */
if (uap->iovcnt & 1)
if (iovcnt & 1)
return (EINVAL);
error = copyinuio(uap->iovp, uap->iovcnt, &auio);
error = copyinuio_f(iovp, iovcnt, &auio);
if (error)
return (error);
error = kern_jail_set(td, auio, uap->flags);
error = kern_jail_set(td, auio, flags);
freeuio(auio);
return (error);
}
@@ -2560,21 +2568,29 @@ get_next_deadid(struct prison **dinsprp)
*/
int
sys_jail_get(struct thread *td, struct jail_get_args *uap)
{
return (user_jail_get(td, uap->iovp, uap->iovcnt, uap->flags,
copyinuio, updateiov));
}
int
user_jail_get(struct thread *td, struct iovec *iovp,
unsigned int iovcnt, int flags, copyinuio_t *copyinuio_f,
updateiov_t *updateiov_f)
{
struct uio *auio;
int error;
/* Check that we have an even number of iovecs. */
if (uap->iovcnt & 1)
if (iovcnt & 1)
return (EINVAL);
error = copyinuio(uap->iovp, uap->iovcnt, &auio);
error = copyinuio_f(iovp, iovcnt, &auio);
if (error)
return (error);
error = kern_jail_get(td, auio, uap->flags);
error = kern_jail_get(td, auio, flags);
if (error == 0)
error = copyout(auio->uio_iov, uap->iovp,
uap->iovcnt * sizeof(struct iovec));
error = updateiov_f(auio, iovp);
freeuio(auio);
return (error);
}
+5
View File
@@ -445,6 +445,11 @@ int user_cpuset_getaffinity(struct thread *td, cpulevel_t level,
int user_cpuset_setaffinity(struct thread *td, cpulevel_t level,
cpuwhich_t which, id_t id, size_t cpusetsize,
const cpuset_t *maskp, const struct cpuset_copy_cb *cb);
int user_jail_get(struct thread *td, struct iovec *iovp,
unsigned int iovcnt, int flags, copyinuio_t *copyinuio_f,
updateiov_t *updateiov_f);
int user_jail_set(struct thread *td, struct iovec *iovp,
unsigned int iovcnt, int flags, copyinuio_t *copyinuio_f);
/* flags for kern_sigaction */
#define KSA_OSIGSET 0x0001 /* uses osigact_t */