linux(4): Use the copyin_sigset() in the remaining places

MFC after:		2 weeks
This commit is contained in:
Dmitry Chagin 2022-05-30 19:59:45 +03:00
parent 7a7cee5585
commit 5e872c279a
2 changed files with 21 additions and 41 deletions

View File

@ -2420,7 +2420,6 @@ linux_common_pselect6(struct thread *td, l_int nfds, l_fd_set *readfds,
{
struct timeval utv, tv0, tv1, *tvp;
struct l_pselect6arg lpse6;
l_sigset_t l_ss;
sigset_t *ssp;
sigset_t ss;
int error;
@ -2430,16 +2429,10 @@ linux_common_pselect6(struct thread *td, l_int nfds, l_fd_set *readfds,
error = copyin(sig, &lpse6, sizeof(lpse6));
if (error != 0)
return (error);
if (lpse6.ss_len != sizeof(l_ss))
return (EINVAL);
if (lpse6.ss != 0) {
error = copyin(PTRIN(lpse6.ss), &l_ss,
sizeof(l_ss));
if (error != 0)
return (error);
linux_to_bsd_sigset(&l_ss, &ss);
ssp = &ss;
}
error = linux_copyin_sigset(PTRIN(lpse6.ss),
lpse6.ss_len, &ss, &ssp);
if (error != 0)
return (error);
} else
ssp = NULL;
@ -2530,7 +2523,6 @@ linux_common_ppoll(struct thread *td, struct pollfd *fds, uint32_t nfds,
struct timespec ts0, ts1;
struct pollfd stackfds[32];
struct pollfd *kfds;
l_sigset_t l_ss;
sigset_t *ssp;
sigset_t ss;
int error;
@ -2538,13 +2530,9 @@ linux_common_ppoll(struct thread *td, struct pollfd *fds, uint32_t nfds,
if (kern_poll_maxfds(nfds))
return (EINVAL);
if (sset != NULL) {
if (ssize != sizeof(l_ss))
return (EINVAL);
error = copyin(sset, &l_ss, sizeof(l_ss));
if (error)
return (error);
linux_to_bsd_sigset(&l_ss, &ss);
ssp = &ss;
error = linux_copyin_sigset(sset, ssize, &ss, &ssp);
if (error != 0)
return (error);
} else
ssp = NULL;
if (tsp != NULL)

View File

@ -266,11 +266,10 @@ linux_rt_sigaction(struct thread *td, struct linux_rt_sigaction_args *args)
}
static int
linux_do_sigprocmask(struct thread *td, int how, l_sigset_t *new,
linux_do_sigprocmask(struct thread *td, int how, sigset_t *new,
l_sigset_t *old)
{
sigset_t omask, nmask;
sigset_t *nmaskp;
sigset_t omask;
int error;
td->td_retval[0] = 0;
@ -288,12 +287,7 @@ linux_do_sigprocmask(struct thread *td, int how, l_sigset_t *new,
default:
return (EINVAL);
}
if (new != NULL) {
linux_to_bsd_sigset(new, &nmask);
nmaskp = &nmask;
} else
nmaskp = NULL;
error = kern_sigprocmask(td, how, nmaskp, &omask, 0);
error = kern_sigprocmask(td, how, new, &omask, 0);
if (error == 0 && old != NULL)
bsd_to_linux_sigset(&omask, old);
@ -305,15 +299,17 @@ int
linux_sigprocmask(struct thread *td, struct linux_sigprocmask_args *args)
{
l_osigset_t mask;
l_sigset_t set, oset;
l_sigset_t lset, oset;
sigset_t set;
int error;
if (args->mask != NULL) {
error = copyin(args->mask, &mask, sizeof(l_osigset_t));
if (error)
return (error);
LINUX_SIGEMPTYSET(set);
set.__mask = mask;
LINUX_SIGEMPTYSET(lset);
lset.__mask = mask;
linux_to_bsd_sigset(&lset, &set);
}
error = linux_do_sigprocmask(td, args->how,
@ -332,20 +328,16 @@ linux_sigprocmask(struct thread *td, struct linux_sigprocmask_args *args)
int
linux_rt_sigprocmask(struct thread *td, struct linux_rt_sigprocmask_args *args)
{
l_sigset_t set, oset;
l_sigset_t oset;
sigset_t set, *pset;
int error;
if (args->sigsetsize != sizeof(l_sigset_t))
error = linux_copyin_sigset(args->mask, args->sigsetsize,
&set, &pset);
if (error != 0)
return (EINVAL);
if (args->mask != NULL) {
error = copyin(args->mask, &set, sizeof(l_sigset_t));
if (error)
return (error);
}
error = linux_do_sigprocmask(td, args->how,
args->mask ? &set : NULL,
error = linux_do_sigprocmask(td, args->how, pset,
args->omask ? &oset : NULL);
if (args->omask != NULL && !error) {