Message ID | 20201013211657.1869-1-ludo@gnu.org |
---|---|
State | New |
Headers | show |
Series | hurd: '_hurd_raise_signal' checks signal number is valid | expand |
On 13 Oct 2020, at 22:16, Ludovic Courtès <ludo@gnu.org> wrote: > > Previously, 'pthread_kill (pthread_self (), -1)' would wrongfully > succeed: > > https://lists.gnu.org/archive/html/guix-devel/2020-10/msg00152.html > > Reported-by: Jan Nieuwenhuizen <janneke@gnu.org> > --- > hurd/hurd-raise.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/hurd/hurd-raise.c b/hurd/hurd-raise.c > index d53fd417d2..58b4ffcc83 100644 > --- a/hurd/hurd-raise.c > +++ b/hurd/hurd-raise.c > @@ -28,6 +28,9 @@ int > _hurd_raise_signal (struct hurd_sigstate *ss, > int signo, const struct hurd_signal_detail *detail) > { > + if (signo < 1 || signo >= _NSIG) > + return EINVAL; > + From pthread_kill(3): If sig is 0, then no signal is sent, but error checking is still performed. I interpret that as meaning it validates thread but ignores sig. Jess
Hello, Jessica Clarke, le mar. 13 oct. 2020 22:20:15 +0100, a ecrit: > On 13 Oct 2020, at 22:16, Ludovic Courtès <ludo@gnu.org> wrote: > > Previously, 'pthread_kill (pthread_self (), -1)' would wrongfully > > succeed: > > > > https://lists.gnu.org/archive/html/guix-devel/2020-10/msg00152.html > > --- a/hurd/hurd-raise.c > > +++ b/hurd/hurd-raise.c > > @@ -28,6 +28,9 @@ int > > _hurd_raise_signal (struct hurd_sigstate *ss, > > int signo, const struct hurd_signal_detail *detail) > > { > > + if (signo < 1 || signo >= _NSIG) > > + return EINVAL; > > + > > From pthread_kill(3): > > If sig is 0, then no signal is sent, but error checking is still performed. > > I interpret that as meaning it validates thread but ignores sig. __pthread_kill actually already check for sig == 0, _hurd_raise_signal is really not supposed to be called with sig == 0. But thanks for making sure we don't miss that case :) Samuel
https://sourceware.org/git/?p=glibc.git;a=commit;h=785ec62dbd Andreas.
Andreas Schwab <schwab@linux-m68k.org> skribis:
> https://sourceware.org/git/?p=glibc.git;a=commit;h=785ec62dbd
Thanks, I guess I was looking at a stale checkout, apologies!
Ludo’.
diff --git a/hurd/hurd-raise.c b/hurd/hurd-raise.c index d53fd417d2..58b4ffcc83 100644 --- a/hurd/hurd-raise.c +++ b/hurd/hurd-raise.c @@ -28,6 +28,9 @@ int _hurd_raise_signal (struct hurd_sigstate *ss, int signo, const struct hurd_signal_detail *detail) { + if (signo < 1 || signo >= _NSIG) + return EINVAL; + if (ss == NULL) { ss = _hurd_self_sigstate ();