Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Mon, 27 Jun 2022 16:27:53 -0400
From: Rich Felker <dalias@...c.org>
To: Florian Weimer <fweimer@...hat.com>
Cc: 张 译仁 <zyr_ms@...look.com>,
	"musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: Re: Confused length of `sigset_t`

On Mon, Jun 27, 2022 at 06:18:26PM +0200, Florian Weimer wrote:
> * 张 译仁:
> 
> > When supporting signal handling for my tiny OS, I notice that the defination of `sigset_t`
> > which is used in signal handling is weird.
> >
> > ```
> > // include/alltypes.h.in
> > TYPEDEF struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t;
> > ```
> >
> > 128 bytes (16 * long) are used for sigmask​ when 128 bits (2 * long) is enough.
> >
> > Why? For strange compatibility?
> 
> I suspect it's for glibc compatibility.  glibc did that in case the
> kernel ever added support for more signals.  The rt_sigprocmask system
> call has a size argument, so it could potentially be extended beyond the
> currently supported 64 or 128 bits (most architectures only support 64).
> 
> But later system calls that deal with signal sets do not take a size
> argument, I think, so the extensibility just isn't there in practice,
> and the glibc-reserved space is wasted.

Yes, that was the reason. However in musl it's also used in the
jmp_buf for a few extra words of storage to implement sigsetjmp.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.