public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
@ 2020-04-22  8:27 Florian Weimer
  2020-04-22  8:37 ` Andreas Schwab
  2020-04-28 10:48 ` Florian Weimer
  0 siblings, 2 replies; 14+ messages in thread
From: Florian Weimer @ 2020-04-22  8:27 UTC (permalink / raw)
  To: libc-alpha

This avoids changing the entire sigset_t structure.  Updating the
actually used part is sufficient.

Tested on x86_64-linux-gnu and i686-linux-gnu.

-----
 signal/sigempty.c   | 7 +++----
 signal/sigfillset.c | 6 ++----
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/signal/sigempty.c b/signal/sigempty.c
index 794e449997..e9f3b571b6 100644
--- a/signal/sigempty.c
+++ b/signal/sigempty.c
@@ -17,20 +17,19 @@
 
 #include <errno.h>
 #include <signal.h>
-#include <string.h>
+#include <sigsetops.h>
 
 /* Clear all signals from SET.  */
 int
 sigemptyset (sigset_t *set)
 {
-  if (set == NULL)
+  if (__glibc_unlikely (set == NULL))
     {
       __set_errno (EINVAL);
       return -1;
     }
 
-  memset (set, 0, sizeof (sigset_t));
-
+  __sigemptyset (set);
   return 0;
 }
 libc_hidden_def (sigemptyset)
diff --git a/signal/sigfillset.c b/signal/sigfillset.c
index 0ca8b6b534..29e98a5864 100644
--- a/signal/sigfillset.c
+++ b/signal/sigfillset.c
@@ -17,8 +17,8 @@
 
 #include <errno.h>
 #include <signal.h>
-#include <string.h>
 #include <internal-signals.h>
+#include <sigsetops.h>
 
 /* Set all signals in SET.  */
 int
@@ -30,10 +30,8 @@ sigfillset (sigset_t *set)
       return -1;
     }
 
-  memset (set, 0xff, sizeof (sigset_t));
-
+  __sigfillset (set);
   __clear_internal_signals (set);
-
   return 0;
 }
 libc_hidden_def (sigfillset)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
  2020-04-22  8:27 [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset Florian Weimer
@ 2020-04-22  8:37 ` Andreas Schwab
  2020-04-22  8:39   ` Florian Weimer
  2020-04-28 13:13   ` Florian Weimer
  2020-04-28 10:48 ` Florian Weimer
  1 sibling, 2 replies; 14+ messages in thread
From: Andreas Schwab @ 2020-04-22  8:37 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

On Apr 22 2020, Florian Weimer wrote:

> This avoids changing the entire sigset_t structure.  Updating the
> actually used part is sufficient.

I'm not sure it's a good idea to leave most of the structure
uninitialized.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
  2020-04-22  8:37 ` Andreas Schwab
@ 2020-04-22  8:39   ` Florian Weimer
  2020-04-22  9:40     ` Andreas Schwab
  2020-04-28 13:13   ` Florian Weimer
  1 sibling, 1 reply; 14+ messages in thread
From: Florian Weimer @ 2020-04-22  8:39 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha

* Andreas Schwab:

> On Apr 22 2020, Florian Weimer wrote:
>
>> This avoids changing the entire sigset_t structure.  Updating the
>> actually used part is sufficient.
>
> I'm not sure it's a good idea to leave most of the structure
> uninitialized.

Would you please elaborate?  How is this different from padding?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
  2020-04-22  8:39   ` Florian Weimer
@ 2020-04-22  9:40     ` Andreas Schwab
  2020-04-22  9:44       ` Florian Weimer
  0 siblings, 1 reply; 14+ messages in thread
From: Andreas Schwab @ 2020-04-22  9:40 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

On Apr 22 2020, Florian Weimer wrote:

> * Andreas Schwab:
>
>> On Apr 22 2020, Florian Weimer wrote:
>>
>>> This avoids changing the entire sigset_t structure.  Updating the
>>> actually used part is sufficient.
>>
>> I'm not sure it's a good idea to leave most of the structure
>> uninitialized.
>
> Would you please elaborate?  How is this different from padding?

Padding is always unnamed.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
  2020-04-22  9:40     ` Andreas Schwab
@ 2020-04-22  9:44       ` Florian Weimer
  2020-04-22 10:02         ` Florian Weimer
  0 siblings, 1 reply; 14+ messages in thread
From: Florian Weimer @ 2020-04-22  9:44 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha

* Andreas Schwab:

> On Apr 22 2020, Florian Weimer wrote:
>
>> * Andreas Schwab:
>>
>>> On Apr 22 2020, Florian Weimer wrote:
>>>
>>>> This avoids changing the entire sigset_t structure.  Updating the
>>>> actually used part is sufficient.
>>>
>>> I'm not sure it's a good idea to leave most of the structure
>>> uninitialized.
>>
>> Would you please elaborate?  How is this different from padding?
>
> Padding is always unnamed.

Not if it is called __glibc_reserved.  I obviously meant named
padding.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
  2020-04-22  9:44       ` Florian Weimer
@ 2020-04-22 10:02         ` Florian Weimer
  2020-04-22 11:47           ` Adhemerval Zanella
  0 siblings, 1 reply; 14+ messages in thread
From: Florian Weimer @ 2020-04-22 10:02 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha

* Florian Weimer:

> * Andreas Schwab:
>
>> On Apr 22 2020, Florian Weimer wrote:
>>
>>> * Andreas Schwab:
>>>
>>>> On Apr 22 2020, Florian Weimer wrote:
>>>>
>>>>> This avoids changing the entire sigset_t structure.  Updating the
>>>>> actually used part is sufficient.
>>>>
>>>> I'm not sure it's a good idea to leave most of the structure
>>>> uninitialized.
>>>
>>> Would you please elaborate?  How is this different from padding?
>>
>> Padding is always unnamed.
>
> Not if it is called __glibc_reserved.  I obviously meant named
> padding.

And sigprocmask has always left the padding uninitialized (even before
Adhemerval's changes).

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
  2020-04-22 10:02         ` Florian Weimer
@ 2020-04-22 11:47           ` Adhemerval Zanella
  2020-04-22 12:14             ` Florian Weimer
  0 siblings, 1 reply; 14+ messages in thread
From: Adhemerval Zanella @ 2020-04-22 11:47 UTC (permalink / raw)
  To: libc-alpha



On 22/04/2020 07:02, Florian Weimer wrote:
> * Florian Weimer:
> 
>> * Andreas Schwab:
>>
>>> On Apr 22 2020, Florian Weimer wrote:
>>>
>>>> * Andreas Schwab:
>>>>
>>>>> On Apr 22 2020, Florian Weimer wrote:
>>>>>
>>>>>> This avoids changing the entire sigset_t structure.  Updating the
>>>>>> actually used part is sufficient.
>>>>>
>>>>> I'm not sure it's a good idea to leave most of the structure
>>>>> uninitialized.
>>>>
>>>> Would you please elaborate?  How is this different from padding?
>>>
>>> Padding is always unnamed.
>>
>> Not if it is called __glibc_reserved.  I obviously meant named
>> padding.
> 
> And sigprocmask has always left the padding uninitialized (even before
> Adhemerval's changes).
> 

Should we change __sigemptyset/__sigfillset to fill the ununsed bits
instead?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
  2020-04-22 11:47           ` Adhemerval Zanella
@ 2020-04-22 12:14             ` Florian Weimer
  2020-04-22 12:22               ` Florian Weimer
  0 siblings, 1 reply; 14+ messages in thread
From: Florian Weimer @ 2020-04-22 12:14 UTC (permalink / raw)
  To: Adhemerval Zanella via Libc-alpha

* Adhemerval Zanella via Libc-alpha:

> On 22/04/2020 07:02, Florian Weimer wrote:
>> * Florian Weimer:
>> 
>>> * Andreas Schwab:
>>>
>>>> On Apr 22 2020, Florian Weimer wrote:
>>>>
>>>>> * Andreas Schwab:
>>>>>
>>>>>> On Apr 22 2020, Florian Weimer wrote:
>>>>>>
>>>>>>> This avoids changing the entire sigset_t structure.  Updating the
>>>>>>> actually used part is sufficient.
>>>>>>
>>>>>> I'm not sure it's a good idea to leave most of the structure
>>>>>> uninitialized.
>>>>>
>>>>> Would you please elaborate?  How is this different from padding?
>>>>
>>>> Padding is always unnamed.
>>>
>>> Not if it is called __glibc_reserved.  I obviously meant named
>>> padding.
>> 
>> And sigprocmask has always left the padding uninitialized (even before
>> Adhemerval's changes).
>
> Should we change __sigemptyset/__sigfillset to fill the ununsed bits
> instead?

We would have to change sigprocmask as well.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
  2020-04-22 12:14             ` Florian Weimer
@ 2020-04-22 12:22               ` Florian Weimer
  2020-04-22 13:23                 ` Adhemerval Zanella
  0 siblings, 1 reply; 14+ messages in thread
From: Florian Weimer @ 2020-04-22 12:22 UTC (permalink / raw)
  To: Adhemerval Zanella via Libc-alpha

* Florian Weimer:

> * Adhemerval Zanella via Libc-alpha:
>
>> On 22/04/2020 07:02, Florian Weimer wrote:
>>> * Florian Weimer:
>>> 
>>>> * Andreas Schwab:
>>>>
>>>>> On Apr 22 2020, Florian Weimer wrote:
>>>>>
>>>>>> * Andreas Schwab:
>>>>>>
>>>>>>> On Apr 22 2020, Florian Weimer wrote:
>>>>>>>
>>>>>>>> This avoids changing the entire sigset_t structure.  Updating the
>>>>>>>> actually used part is sufficient.
>>>>>>>
>>>>>>> I'm not sure it's a good idea to leave most of the structure
>>>>>>> uninitialized.
>>>>>>
>>>>>> Would you please elaborate?  How is this different from padding?
>>>>>
>>>>> Padding is always unnamed.
>>>>
>>>> Not if it is called __glibc_reserved.  I obviously meant named
>>>> padding.
>>> 
>>> And sigprocmask has always left the padding uninitialized (even before
>>> Adhemerval's changes).
>>
>> Should we change __sigemptyset/__sigfillset to fill the ununsed bits
>> instead?
>
> We would have to change sigprocmask as well.

Just to be clear: I don't think writing more data in sigprocmask is a
useful change.  We might even have to introduce a new symbol version.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
  2020-04-22 12:22               ` Florian Weimer
@ 2020-04-22 13:23                 ` Adhemerval Zanella
  0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2020-04-22 13:23 UTC (permalink / raw)
  To: Florian Weimer, Adhemerval Zanella via Libc-alpha



On 22/04/2020 09:22, Florian Weimer wrote:
> * Florian Weimer:
> 
>> * Adhemerval Zanella via Libc-alpha:
>>
>>> On 22/04/2020 07:02, Florian Weimer wrote:
>>>> * Florian Weimer:
>>>>
>>>>> * Andreas Schwab:
>>>>>
>>>>>> On Apr 22 2020, Florian Weimer wrote:
>>>>>>
>>>>>>> * Andreas Schwab:
>>>>>>>
>>>>>>>> On Apr 22 2020, Florian Weimer wrote:
>>>>>>>>
>>>>>>>>> This avoids changing the entire sigset_t structure.  Updating the
>>>>>>>>> actually used part is sufficient.
>>>>>>>>
>>>>>>>> I'm not sure it's a good idea to leave most of the structure
>>>>>>>> uninitialized.
>>>>>>>
>>>>>>> Would you please elaborate?  How is this different from padding?
>>>>>>
>>>>>> Padding is always unnamed.
>>>>>
>>>>> Not if it is called __glibc_reserved.  I obviously meant named
>>>>> padding.
>>>>
>>>> And sigprocmask has always left the padding uninitialized (even before
>>>> Adhemerval's changes).
>>>
>>> Should we change __sigemptyset/__sigfillset to fill the ununsed bits
>>> instead?
>>
>> We would have to change sigprocmask as well.
> 
> Just to be clear: I don't think writing more data in sigprocmask is a
> useful change.  We might even have to introduce a new symbol version.
> 

Although I considered this option on BZ#25657, I tend to agree with you.
The data is no longer accessed by GNU signal functions, so it should not 
trigger any static or sanitizer.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
  2020-04-22  8:27 [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset Florian Weimer
  2020-04-22  8:37 ` Andreas Schwab
@ 2020-04-28 10:48 ` Florian Weimer
  2020-04-28 12:55   ` Adhemerval Zanella
  1 sibling, 1 reply; 14+ messages in thread
From: Florian Weimer @ 2020-04-28 10:48 UTC (permalink / raw)
  To: libc-alpha

Any additional comments on this patch?  Thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
  2020-04-28 10:48 ` Florian Weimer
@ 2020-04-28 12:55   ` Adhemerval Zanella
  2020-05-08 16:34     ` Florian Weimer
  0 siblings, 1 reply; 14+ messages in thread
From: Adhemerval Zanella @ 2020-04-28 12:55 UTC (permalink / raw)
  To: libc-alpha



On 28/04/2020 07:48, Florian Weimer wrote:
> Any additional comments on this patch?  Thanks.
> 

LGTM, thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
  2020-04-22  8:37 ` Andreas Schwab
  2020-04-22  8:39   ` Florian Weimer
@ 2020-04-28 13:13   ` Florian Weimer
  1 sibling, 0 replies; 14+ messages in thread
From: Florian Weimer @ 2020-04-28 13:13 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha

* Andreas Schwab:

> On Apr 22 2020, Florian Weimer wrote:
>
>> This avoids changing the entire sigset_t structure.  Updating the
>> actually used part is sufficient.
>
> I'm not sure it's a good idea to leave most of the structure
> uninitialized.

Andreas, is this a sustained objection?  Thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset
  2020-04-28 12:55   ` Adhemerval Zanella
@ 2020-05-08 16:34     ` Florian Weimer
  0 siblings, 0 replies; 14+ messages in thread
From: Florian Weimer @ 2020-05-08 16:34 UTC (permalink / raw)
  To: Adhemerval Zanella via Libc-alpha

* Adhemerval Zanella via Libc-alpha:

> On 28/04/2020 07:48, Florian Weimer wrote:
>> Any additional comments on this patch?  Thanks.
>> 
>
> LGTM, thanks.

Thanks, I pushed this without the spurious __glibc_unlikely change.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-05-08 16:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-22  8:27 [PATCH] signal: Use <sigsetops.h> for sigemptyset, sigfillset Florian Weimer
2020-04-22  8:37 ` Andreas Schwab
2020-04-22  8:39   ` Florian Weimer
2020-04-22  9:40     ` Andreas Schwab
2020-04-22  9:44       ` Florian Weimer
2020-04-22 10:02         ` Florian Weimer
2020-04-22 11:47           ` Adhemerval Zanella
2020-04-22 12:14             ` Florian Weimer
2020-04-22 12:22               ` Florian Weimer
2020-04-22 13:23                 ` Adhemerval Zanella
2020-04-28 13:13   ` Florian Weimer
2020-04-28 10:48 ` Florian Weimer
2020-04-28 12:55   ` Adhemerval Zanella
2020-05-08 16:34     ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).