lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230125151717.GB13746@redhat.com>
Date:   Wed, 25 Jan 2023 16:17:17 +0100
From:   Oleg Nesterov <oleg@...hat.com>
To:     Dmitry Vyukov <dvyukov@...gle.com>
Cc:     tglx@...utronix.de, linux-kernel@...r.kernel.org,
        "Eric W . Biederman" <ebiederm@...ssion.com>,
        Frederic Weisbecker <frederic@...nel.org>,
        Marco Elver <elver@...gle.com>
Subject: Re: [RFC PATCH v2] posix-timers: Support delivery of signals to the
 current thread

On 01/25, Oleg Nesterov wrote:
>
> Other than that I see nothing wrong in this patch, but I forgot everything
> about posix timers many years ago ;)

Stupid question. Am I right that in posix_timer_event()

	same_thread_group(current, pid_task(timr->it_pid, PIDTYPE_PID))

is always true?

If yes, perhaps we can do a much simpler change which doesn't even affect API?
See the trivial patch below.

send_sigqueue(PIDTYPE_TGID) notify any thread in thread group, so this doesn't
really change the semantics, just complete_signal() will likely choose "current"
as a target for signal_wake_up() and iiuc this is what we want for balancing?

Oleg.


diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 5dead89308b7..e38b53a0f814 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -336,6 +336,7 @@ void posixtimer_rearm(struct kernel_siginfo *info)
 int posix_timer_event(struct k_itimer *timr, int si_private)
 {
 	enum pid_type type;
+	struct pid *pid;
 	int ret;
 	/*
 	 * FIXME: if ->sigq is queued we can race with
@@ -350,8 +351,9 @@ int posix_timer_event(struct k_itimer *timr, int si_private)
 	 */
 	timr->sigq->info.si_sys_private = si_private;
 
-	type = !(timr->it_sigev_notify & SIGEV_THREAD_ID) ? PIDTYPE_TGID : PIDTYPE_PID;
-	ret = send_sigqueue(timr->sigq, timr->it_pid, type);
+	type = (timr->it_sigev_notify & SIGEV_THREAD_ID) ? PIDTYPE_PID : PIDTYPE_TGID;
+	pid = (type == PIDTYPE_PID) ? timr->it_pid : task_pid(current);
+	ret = send_sigqueue(timr->sigq, pid, type);
 	/* If we failed to send the signal the timer stops. */
 	return ret > 0;
 }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ