From nobody Tue Apr 26 16:37:17 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A900C199B27E; Tue, 26 Apr 2022 16:37:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Knnbf03SFz4hqy; Tue, 26 Apr 2022 16:37:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650991038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8KsuRVOepQoFGx0Wx9v6mlT18Ej9+phxWPJ6CWkGGcU=; b=QuTAOE1kQD78y1uHzPFa8K6zUY4kpdlEhcE2Bmz1vLUN1x8cywdZSKLiB/w72lw4hJF/x9 f6VxfCBMoMoSRXeGQtTGtUvAY1n+75vUEvR2N+hH6NwuEkJqFx8YIXn/Wt1wQIlvf2Xh3w 9mOIbi+FNfLbzf0x30T1Xw5iUWAL6M3kFIdlFMK1/a/Kba2sw2/tSyWgNrRL1FzNi2fEqg x9UssnhOG9sl1HR8ZQJluHF825DkC6sccRS8BxmFmV/wmpn/PyC4YHB269i833HD+mPTnC SI1emT5F+Af7W/KQ/NeL6WkieAefJnpsjrnAxGLP9zqT3hozV7eWd3BUJXuZ/A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AFA8212FA6; Tue, 26 Apr 2022 16:37:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23QGbHOb065487; Tue, 26 Apr 2022 16:37:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23QGbHjh065486; Tue, 26 Apr 2022 16:37:17 GMT (envelope-from git) Date: Tue, 26 Apr 2022 16:37:17 GMT Message-Id: <202204261637.23QGbHjh065486@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 3923e632094a - main - linux(4): Add copyin_sigset() helper. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3923e632094a7e4cc66cd8e68964b9cb495119e2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650991038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8KsuRVOepQoFGx0Wx9v6mlT18Ej9+phxWPJ6CWkGGcU=; b=LQgPgJzPFLqNQeli3ghOKNItVfedCNgB1wYW21pDna8BMny+NVemV2m4JT8zyoBPz28WLR 7uWTp0/o8kZEZw8x/frAqEfO+HsGOnARPu87B4y6UotCLT6sdRM4zUXquHznHe50CXXbZh 17XrkiNEpGPaVUBMU+aVZQn+UCJb6DfwDm4ENjZxHmbLdh2PYlKaMnStTccd51dBEj1klt ShQhFXPr3JvLEzxtPPVnjTwj/kxo4rwxZdbWHvQl7r23g7yR5fQCzMcme391eBeZAwUps2 /hOF4IzG3EPx/Fgb6znesYGjGKE65tzAcbZQUKe4APZOFZcQBgmir9A2gkHlOg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650991038; a=rsa-sha256; cv=none; b=DeIPB2/m1eJ7iTvsVUeKjaJ6PtmbB1Gdwse3p+mX6y2j61k2GKRQH4is7vPi0Rpwtsok9l u6SrOZR17Sl9XNgL/lWtheTl4BAaZWXf4Z0YaS1+EzdqS4nVv1J6G/t7ZzpsmB6ZcVmRxy BBg6mxTTYBayjLq1CkjefVSm9Sle5p9EaDQNCDwtxl40AcfS1b1IPdX6Uh+dkzhsUuGOZL V0WmavzOnl5G7ifDlo4R7hSMzFkVH7GDBa5ARO4PDF+mZk+43F81DXFPrUrNHw2JQQr5CA Yfhd4KFPDHPJwiUhgIIOwlOyksHtcO5nf6AlpHVwcL5sHe2HX115J0umqebnSg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=3923e632094a7e4cc66cd8e68964b9cb495119e2 commit 3923e632094a7e4cc66cd8e68964b9cb495119e2 Author: Dmitry Chagin AuthorDate: 2022-04-26 16:35:57 +0000 Commit: Dmitry Chagin CommitDate: 2022-04-26 16:35:57 +0000 linux(4): Add copyin_sigset() helper. MFC after: 2 weeks --- sys/compat/linux/linux_event.c | 17 ++++++----------- sys/compat/linux/linux_signal.c | 37 +++++++++++++++++++++++++------------ sys/compat/linux/linux_signal.h | 1 + 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c index 4389e8daa0dd..52f7c58a4347 100644 --- a/sys/compat/linux/linux_event.c +++ b/sys/compat/linux/linux_event.c @@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -523,19 +524,13 @@ int linux_epoll_pwait(struct thread *td, struct linux_epoll_pwait_args *args) { sigset_t mask, *pmask; - l_sigset_t lmask; int error; - if (args->mask != NULL) { - if (args->sigsetsize != sizeof(l_sigset_t)) - return (EINVAL); - error = copyin(args->mask, &lmask, sizeof(l_sigset_t)); - if (error != 0) - return (error); - linux_to_bsd_sigset(&lmask, &mask); - pmask = &mask; - } else - pmask = NULL; + error = linux_copyin_sigset(args->mask, sizeof(l_sigset_t), + &mask, &pmask); + if (error != 0) + return (error); + return (linux_epoll_wait_common(td, args->epfd, args->events, args->maxevents, args->timeout, pmask)); } diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c index c506edae0fc9..0848040d009c 100644 --- a/sys/compat/linux/linux_signal.c +++ b/sys/compat/linux/linux_signal.c @@ -458,17 +458,13 @@ linux_common_rt_sigtimedwait(struct thread *td, l_sigset_t *mask, struct timespec *tsa, l_siginfo_t *ptr, l_size_t sigsetsize) { int error, sig; - l_sigset_t lset; sigset_t bset; l_siginfo_t lsi; ksiginfo_t ksi; - if (sigsetsize != sizeof(l_sigset_t)) - return (EINVAL); - - if ((error = copyin(mask, &lset, sizeof(lset)))) + error = linux_copyin_sigset(mask, sigsetsize, &bset, NULL); + if (error != 0) return (error); - linux_to_bsd_sigset(&lset, &bset); ksiginfo_init(&ksi); error = kern_sigtimedwait(td, bset, &ksi, tsa); @@ -772,18 +768,14 @@ linux_rt_tgsigqueueinfo(struct thread *td, struct linux_rt_tgsigqueueinfo_args * int linux_rt_sigsuspend(struct thread *td, struct linux_rt_sigsuspend_args *uap) { - l_sigset_t lmask; sigset_t sigmask; int error; - if (uap->sigsetsize != sizeof(l_sigset_t)) - return (EINVAL); - - error = copyin(uap->newset, &lmask, sizeof(l_sigset_t)); + error = linux_copyin_sigset(uap->newset, uap->sigsetsize, + &sigmask, NULL); if (error != 0) return (error); - linux_to_bsd_sigset(&lmask, &sigmask); return (kern_sigsuspend(td, sigmask)); } @@ -867,3 +859,24 @@ linux_psignal(struct thread *td, int pid, int sig) ksi.ksi_uid = td->td_proc->p_ucred->cr_ruid; return (linux_pksignal(td, pid, sig, &ksi)); } + +int +linux_copyin_sigset(l_sigset_t *lset, l_size_t sigsetsize, sigset_t *set, + sigset_t **pset) +{ + l_sigset_t lmask; + int error; + + if (sigsetsize != sizeof(l_sigset_t)) + return (EINVAL); + if (lset != NULL) { + error = copyin(lset, &lmask, sizeof(l_sigset_t)); + if (error != 0) + return (error); + linux_to_bsd_sigset(&lmask, set); + if (pset != NULL) + *pset = set; + } else if (pset != NULL) + *pset = NULL; + return (0); +} diff --git a/sys/compat/linux/linux_signal.h b/sys/compat/linux/linux_signal.h index f434ab1b1b35..8d6022fc3cc7 100644 --- a/sys/compat/linux/linux_signal.h +++ b/sys/compat/linux/linux_signal.h @@ -47,5 +47,6 @@ int linux_do_sigaction(struct thread *, int, l_sigaction_t *, l_sigaction_t *); void siginfo_to_lsiginfo(const siginfo_t *si, l_siginfo_t *lsi, l_int sig); int lsiginfo_to_siginfo(struct thread *td, const l_siginfo_t *lsi, siginfo_t *si, int sig); +int linux_copyin_sigset(l_sigset_t *, l_size_t, sigset_t *, sigset_t **); #endif /* _LINUX_SIGNAL_H_ */