All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael Kerrisk (man-pages)" <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Rich Felker <dalias-8zAoT0mYgF4@public.gmane.org>
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	"linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: Incorrect documentation for tgkill syscall when tgid==-1
Date: Tue, 23 Dec 2014 16:31:14 +0100	[thread overview]
Message-ID: <54998AC2.70202@gmail.com> (raw)
In-Reply-To: <20141219020553.GA23392-C3MtFaGISjmo6RMmaWD+6Sb1p8zYI1N1@public.gmane.org>

Rich,

On 12/19/2014 03:05 AM, Rich Felker wrote:
> The man page for tgkill claims:
> 
>        "If tgid is specified as -1, tgkill() is equivalent to tkill()."
> 
> However, the kernel source contains:
> 
>         /* This is only valid for single tasks */
>         if (pid <= 0 || tgid <= 0)
>                 return -EINVAL;
> 
> and I confirmed that passing -1 results in EINVAL. This discrepency
> should be fixed in the documentation.

Sigh. Text along those lines has been there since the pages added
in 2003.

> Since there's therefore no way to achieve the same behavior as tkill
> using the tgkill syscall, I'd also like to request a removal of the
> text claiming tkill is obsolete. tgkill does not solve the race
> condition it claims to solve (this is documented to some extent in the
> relevant git commits to musl libc, and I intend to write more on the
> issue later) nor is it needed to solve the race (tkill works just as
> well if used correctly).

I guess the relevant bug here is

    http://sourceware.org/bugzilla/show_bug.cgi?id=12889

right?

I'm a little puzzled. In that bug report, you say:

     (The tgkill syscall was designed to eliminate a similar race
     condition in tkill, but it only succeeded in eliminating races
     where the tid gets reused in a different process, and does not
     help if the same tid gets assigned to a new thread in the
     same process.)

Is it not the case that tgkill() solves *some* of the race conditions
that tkill() is vulnerable to (i.e., TID recycled in a different 
process), and therefore is an improvement on tkill() (i.e., renders
it obsolete)?

Cheers,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

       reply	other threads:[~2014-12-23 15:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20141219020553.GA23392@brightrain.aerifal.cx>
     [not found] ` <20141219020553.GA23392-C3MtFaGISjmo6RMmaWD+6Sb1p8zYI1N1@public.gmane.org>
2014-12-23 15:31   ` Michael Kerrisk (man-pages) [this message]
     [not found]     ` <54998AC2.70202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-23 17:14       ` Incorrect documentation for tgkill syscall when tgid==-1 Rich Felker

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=54998AC2.70202@gmail.com \
    --to=mtk.manpages-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=dalias-8zAoT0mYgF4@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.