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]
Date:   Wed, 25 Jan 2023 18:07:08 +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:
>
> > >  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;
> > >  }

...

> But! I just noticed send_sigqueue() does pid_task(pid, type), so the patch
> above needs another change
>
> 	--- a/kernel/signal.c
> 	+++ b/kernel/signal.c
> 	@@ -1970,7 +1970,8 @@ int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type)
> 	 
> 		ret = -1;
> 		rcu_read_lock();
> 	-	t = pid_task(pid, type);
> 	+	// comment to explain why don't we use "type"
> 	+	t = pid_task(pid, PIDTYPE_PID);
> 		if (!t || !likely(lock_task_sighand(t, &flags)))
> 			goto ret;

So. Unless I missed something (quite possibly) we do not even need the patch
above. The one liner change below can work just fine.

Oleg.

--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1970,7 +1970,8 @@ int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type)
 
 	ret = -1;
 	rcu_read_lock();
-	t = pid_task(pid, type);
+	/* GOOD COMMENT */
+	t = type == PIDTYPE_PID ? pid_task(pid, type) : current;
 	if (!t || !likely(lock_task_sighand(t, &flags)))
 		goto ret;
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ