* Re: Incorrect documentation for tgkill syscall when tgid==-1
[not found] ` <20141219020553.GA23392-C3MtFaGISjmo6RMmaWD+6Sb1p8zYI1N1@public.gmane.org>
@ 2014-12-23 15:31 ` Michael Kerrisk (man-pages)
[not found] ` <54998AC2.70202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Michael Kerrisk (man-pages) @ 2014-12-23 15:31 UTC (permalink / raw)
To: Rich Felker
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w,
linux-man-u79uwXL29TY76Z2rM5mHXA@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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Incorrect documentation for tgkill syscall when tgid==-1
[not found] ` <54998AC2.70202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2014-12-23 17:14 ` Rich Felker
0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2014-12-23 17:14 UTC (permalink / raw)
To: Michael Kerrisk (man-pages)
Cc: linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
On Tue, Dec 23, 2014 at 04:31:14PM +0100, Michael Kerrisk (man-pages) wrote:
> > 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)?
Yes, I should have been more precise in my statement. It does solve
that special case, but it's neither necessary nor sufficient to solve
the problem in general. tkill is perfectly usable for solving the
problem in general (it just requires locking local to the process, and
solving the problem using tgkill would require the same locking), and
there are some reasons to prefer it.
Rich
--
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-23 17:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20141219020553.GA23392@brightrain.aerifal.cx>
[not found] ` <20141219020553.GA23392-C3MtFaGISjmo6RMmaWD+6Sb1p8zYI1N1@public.gmane.org>
2014-12-23 15:31 ` Incorrect documentation for tgkill syscall when tgid==-1 Michael Kerrisk (man-pages)
[not found] ` <54998AC2.70202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-23 17:14 ` Rich Felker
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.