signal: Use correct type for si_band in siginfo_t [BZ #23562]

Message ID 877eifgpn7.fsf@oldenburg.str.redhat.com
State Committed
Headers

Commit Message

Florian Weimer Oct. 18, 2018, 4:56 p.m. UTC
  Perhaps I a SPARC maintainer could review this as well?

I tested it on x86-64 and found no regressions.  Based on the sources,
the change should only impact SPARC.

2018-10-18  Ilya Yu. Malakhov  <malakhov@mcst.ru>

	[BZ #23562]
	* sysdeps/unix/sysv/linux/bits/types/siginfo_t.h
	(struct siginfo_t): Use correct type for si_band.
  

Comments

Adhemerval Zanella Netto Oct. 18, 2018, 6:10 p.m. UTC | #1
On 18/10/2018 13:56, Florian Weimer wrote:
> Perhaps I a SPARC maintainer could review this as well?
> 
> I tested it on x86-64 and found no regressions.  Based on the sources,
> the change should only impact SPARC.
> 
> 2018-10-18  Ilya Yu. Malakhov  <malakhov@mcst.ru>
> 
> 	[BZ #23562]
> 	* sysdeps/unix/sysv/linux/bits/types/siginfo_t.h
> 	(struct siginfo_t): Use correct type for si_band.
> 

LGTM, it seems to match kernel definition:

include/uapi/asm-generic/siginfo.h

120                 /* SIGPOLL */
121                 struct {
122                         __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
123                         int _fd;
124                 } _sigpoll;
				

arch/sparc/include/uapi/asm/siginfo.h

  8 #define __ARCH_SI_BAND_T int


> diff --git a/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h b/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h
> index 33766d1813..43c4e009a4 100644
> --- a/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h
> +++ b/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h
> @@ -107,7 +107,7 @@ typedef struct
>  	/* SIGPOLL.  */
>  	struct
>  	  {
> -	    long int si_band;	/* Band event for SIGPOLL.  */
> +	    __SI_BAND_TYPE si_band;	/* Band event for SIGPOLL.  */
>  	    int si_fd;
>  	  } _sigpoll;
>  
>
  
Joseph Myers Oct. 22, 2018, 3:07 p.m. UTC | #2
This has broken the conform/ tests for SPARC, so that you now get:

FAIL: conform/POSIX2008/signal.h/conform
FAIL: conform/POSIX2008/sys/wait.h/conform
FAIL: conform/UNIX98/signal.h/conform
FAIL: conform/UNIX98/sys/wait.h/conform
FAIL: conform/XOPEN2K/signal.h/conform
FAIL: conform/XOPEN2K/sys/wait.h/conform
FAIL: conform/XOPEN2K8/signal.h/conform
FAIL: conform/XOPEN2K8/sys/wait.h/conform
FAIL: conform/XPG42/signal.h/conform
FAIL: conform/XPG42/sys/wait.h/conform

because si_band no longer has the POSIX-specified type.

For 32-bit SPARC you should be able to use long int and so avoid the 
failures, as that won't change the layout.  For 64-bit SPARC this would be 
a case where the kernel having the wrong type means you need an 
appropriately conditioned and commented XFAIL in signal.h-data and 
sys/wait.h-data (and appropriately conditioned and commented 
conformtest-xfail-conds definition in a relevant sysdeps Makefile to 
define the condition that's used in the conform/ data changes).
  
Florian Weimer Oct. 22, 2018, 3:18 p.m. UTC | #3
* Joseph Myers:

> This has broken the conform/ tests for SPARC, so that you now get:
>
> FAIL: conform/POSIX2008/signal.h/conform
> FAIL: conform/POSIX2008/sys/wait.h/conform
> FAIL: conform/UNIX98/signal.h/conform
> FAIL: conform/UNIX98/sys/wait.h/conform
> FAIL: conform/XOPEN2K/signal.h/conform
> FAIL: conform/XOPEN2K/sys/wait.h/conform
> FAIL: conform/XOPEN2K8/signal.h/conform
> FAIL: conform/XOPEN2K8/sys/wait.h/conform
> FAIL: conform/XPG42/signal.h/conform
> FAIL: conform/XPG42/sys/wait.h/conform
>
> because si_band no longer has the POSIX-specified type.

Sorry about that.

> For 32-bit SPARC you should be able to use long int and so avoid the 
> failures, as that won't change the layout.

Okay, that makes sense.

> For 64-bit SPARC this would be a case where the kernel having the
> wrong type means you need an appropriately conditioned and commented
> XFAIL in signal.h-data and sys/wait.h-data (and appropriately
> conditioned and commented conformtest-xfail-conds definition in a
> relevant sysdeps Makefile to define the condition that's used in the
> conform/ data changes).

Why wasn't this a problem before
sysdeps/unix/sysv/linux/bits/types/siginfo_t.h was split out?  SPARC
clearly had int as the type of si_band back then.

Thanks,
Florian
  
Joseph Myers Oct. 22, 2018, 3:46 p.m. UTC | #4
On Mon, 22 Oct 2018, Florian Weimer wrote:

> > For 64-bit SPARC this would be a case where the kernel having the
> > wrong type means you need an appropriately conditioned and commented
> > XFAIL in signal.h-data and sys/wait.h-data (and appropriately
> > conditioned and commented conformtest-xfail-conds definition in a
> > relevant sysdeps Makefile to define the condition that's used in the
> > conform/ data changes).
> 
> Why wasn't this a problem before
> sysdeps/unix/sysv/linux/bits/types/siginfo_t.h was split out?  SPARC
> clearly had int as the type of si_band back then.

XFAILs at the Makefile level for the signal.h and sys/wait.h tests for 
most standards weren't removed until August 2017 (commit 
4fa9b3bfe6759c82beb4b043a54a3598ca467289, once the ucontext.h namespace 
fixes were completed), after the accidental SPARC si_band change, and so 
served to hide that architecture-specific problem.
  
Adhemerval Zanella Netto Oct. 22, 2018, 7:49 p.m. UTC | #5
On 22/10/2018 12:07, Joseph Myers wrote:
> This has broken the conform/ tests for SPARC, so that you now get:
> 
> FAIL: conform/POSIX2008/signal.h/conform
> FAIL: conform/POSIX2008/sys/wait.h/conform
> FAIL: conform/UNIX98/signal.h/conform
> FAIL: conform/UNIX98/sys/wait.h/conform
> FAIL: conform/XOPEN2K/signal.h/conform
> FAIL: conform/XOPEN2K/sys/wait.h/conform
> FAIL: conform/XOPEN2K8/signal.h/conform
> FAIL: conform/XOPEN2K8/sys/wait.h/conform
> FAIL: conform/XPG42/signal.h/conform
> FAIL: conform/XPG42/sys/wait.h/conform
> 
> because si_band no longer has the POSIX-specified type.
> 
> For 32-bit SPARC you should be able to use long int and so avoid the 
> failures, as that won't change the layout.  For 64-bit SPARC this would be 
> a case where the kernel having the wrong type means you need an 
> appropriately conditioned and commented XFAIL in signal.h-data and 
> sys/wait.h-data (and appropriately conditioned and commented 
> conformtest-xfail-conds definition in a relevant sysdeps Makefile to 
> define the condition that's used in the conform/ data changes).
> 

I think we should XFAIL for both 32-bit and 64-bit, siginfo_t is passed
directly by kernel in signal handlers and passed unmodified on sigtimedwait,
sigwait, and sigwaitinfo syscalls.
  
Joseph Myers Oct. 22, 2018, 9:45 p.m. UTC | #6
On Mon, 22 Oct 2018, Adhemerval Zanella wrote:

> I think we should XFAIL for both 32-bit and 64-bit, siginfo_t is passed

Since long int and int have the same size for 32-bit, I see no need to 
XFAIL there when you can just use the proper POSIX type without affecting 
the layout.
  
Adhemerval Zanella Netto Oct. 22, 2018, 10:02 p.m. UTC | #7
On 22/10/2018 18:45, Joseph Myers wrote:
> On Mon, 22 Oct 2018, Adhemerval Zanella wrote:
> 
>> I think we should XFAIL for both 32-bit and 64-bit, siginfo_t is passed
> 
> Since long int and int have the same size for 32-bit, I see no need to 
> XFAIL there when you can just use the proper POSIX type without affecting 
> the layout.
> 
I see your point, I would just like to keep documented that for SPARC there
is this small divergence between POSIX and kernel definition.
  
Joseph Myers Oct. 22, 2018, 10:10 p.m. UTC | #8
On Mon, 22 Oct 2018, Adhemerval Zanella wrote:

> On 22/10/2018 18:45, Joseph Myers wrote:
> > On Mon, 22 Oct 2018, Adhemerval Zanella wrote:
> > 
> >> I think we should XFAIL for both 32-bit and 64-bit, siginfo_t is passed
> > 
> > Since long int and int have the same size for 32-bit, I see no need to 
> > XFAIL there when you can just use the proper POSIX type without affecting 
> > the layout.
> > 
> I see your point, I would just like to keep documented that for SPARC there
> is this small divergence between POSIX and kernel definition.

I think XFAILing for such conform/ test assertions is only for the cases 
where the issue is hard to fix - not where the bad type can be replaced by 
the standard one with no change of layout involved.
  

Patch

diff --git a/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h b/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h
index 33766d1813..43c4e009a4 100644
--- a/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h
+++ b/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h
@@ -107,7 +107,7 @@  typedef struct
 	/* SIGPOLL.  */
 	struct
 	  {
-	    long int si_band;	/* Band event for SIGPOLL.  */
+	    __SI_BAND_TYPE si_band;	/* Band event for SIGPOLL.  */
 	    int si_fd;
 	  } _sigpoll;