[PATCH] sigaction: don't sign-extend sa_flags

наб nabijaczleweli@nabijaczleweli.xyz
Mon Jun 2 22:48:36 GMT 2025


On Tue, Jun 03, 2025 at 01:24:56AM +0300, Dmitry V. Levin wrote:
> Given that glibc by default also supports kernel versions prior to v5.11,
> it seems to me that it should avoid sign-extending sa_flags.  By the way,
> is there any reason why glibc sign-extends sa_flags in the first place?
The current implementation blames back to the initial sigaction()
implementation with divergent kernel/userspace structs sigaction:
  4cca6b868f0 (Ulrich Drepper 1997-03-08 05:28:20 +0000  43)       k_newact.sa_flags = act->sa_flags;
in sysdeps/unix/sysv/linux/i386/sigaction.c
(with no specific notes about sa_flags in the changelog);
this survives (through renames and generalisations)
in sysdeps/unix/sysv/linux/libc_sigaction.c today.

On i386 this doesn't do sign extension since these are the same size,
and my hopefully-reasonable guesstimation is that (a) this works,
so (b) no-one has thought about this since 1997.

(musl does the same thing since git start presumably for the same reasons.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250603/9ed3d1f8/attachment.sig>


More information about the Libc-alpha mailing list