mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Hurley <peter@hurleysoftware.com>
To: Patrick Donnelly <batrick@batbytes.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.cz>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] tty: add missing rcu_read_lock for task_pgrp
Date: Sun, 28 Jun 2015 15:21:19 -0400	[thread overview]
Message-ID: <5590492F.9010507@hurleysoftware.com> (raw)
In-Reply-To: <CACh33FrCn+pDPNLVnrYVQ5sf92m8hj+oiQJ2U6RM2CtqDBf=OQ@mail.gmail.com>

On 06/28/2015 01:20 PM, Patrick Donnelly wrote:
> On Sun, Jun 28, 2015 at 11:23 AM, Peter Hurley <peter@hurleysoftware.com> wrote:
>> On 06/27/2015 08:51 PM, Patrick Donnelly wrote:
>>> task_pgrp requires an rcu or tasklist lock to be obtained if the returned pid
>>> is to be dereferenced, which kill_pgrp does. Obtain an RCU lock for the
>>> duration of use.
>>
>> kill_pgrp() obtains tasklist_lock, so I don't see an unsafe deref.
> 
> I see a race between looking up the pgrp via task_pgrp and passing it
> to kill_pgrp. The pgrp struct pid may be freed via setpgid/setsid, as
> mentioned in the comment for task_pgrp:
> 
>  * Without tasklist or rcu lock it is not safe to dereference
>  * the result of task_pgrp/task_session even if task == current,
>  * we can race with another thread doing sys_setsid/sys_setpgid.
> 
> Getting the lock after the lookup is getting the lock too late. I
> could be wrong though as I'm no expert on locking in Linux.

I suppose it can't hurt; please add similar logic to job_control() in
drivers/tty/n_tty.c which handles the corresponding SIGTTIN signal conditions.

Regards,
Peter Hurley

  reply	other threads:[~2015-06-28 19:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-27 21:17 [PATCH 1/2] Add " Patrick Donnelly
2015-06-27 21:17 ` [PATCH 2/2] Check tcsetpgrp p is a process group Patrick Donnelly
2015-06-27 23:26   ` Greg Kroah-Hartman
2015-06-28  0:53     ` Patrick Donnelly
2015-06-27 23:27   ` Greg Kroah-Hartman
2015-06-27 23:25 ` [PATCH 1/2] Add missing rcu_read_lock for task_pgrp Greg Kroah-Hartman
2015-06-28  0:51 ` [PATCH v2 1/2] tty: add " Patrick Donnelly
2015-06-28  0:51   ` [PATCH v2 2/2] tty: check tcsetpgrp p is a process group Patrick Donnelly
2015-06-28 16:07     ` Peter Hurley
2015-06-29  1:27       ` Patrick Donnelly
2015-06-28 15:23   ` [PATCH v2 1/2] tty: add missing rcu_read_lock for task_pgrp Peter Hurley
2015-06-28 17:20     ` Patrick Donnelly
2015-06-28 19:21       ` Peter Hurley [this message]
2015-06-28 19:27   ` Peter Hurley
2015-06-29 23:38     ` Patrick Donnelly
2015-06-29 23:59 ` [PATCH v3] " Patrick Donnelly
2015-07-09  2:07   ` Peter Hurley
2015-07-12  2:05   ` Peter Hurley
2015-07-12 22:42     ` Patrick Donnelly
2015-07-12 22:51 ` [PATCH v4] " Patrick Donnelly
2015-07-13  0:35   ` Peter Hurley
2015-07-20  9:26   ` Jiri Slaby
2015-07-20 19:40     ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5590492F.9010507@hurleysoftware.com \
    --to=peter@hurleysoftware.com \
    --cc=batrick@batbytes.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome