Re: [PATCH v2 0/1] Call prctl(2) with signed long integers, and avoid casts

Alejandro Colomar <[email protected]> Wed, 3 Dec 2025 23:36:07 +0100
Newsgroups org.kernel.vger.util-linux
Message-ID <fqh6evzlyowscow44l7b2wa5amiz4b5mbhddavk2nwzcfrtil7@mkv4lsejntlt>
Hi Thomas!

On Wed, Dec 03, 2025 at 11:12:47PM +0100, Thomas Weißschuh wrote:
> Hi!
> 
> On 2025-12-03 22:01:18+0100, Alejandro Colomar wrote:
> > On Wed, Dec 03, 2025 at 09:50:27PM +0100, Alejandro Colomar wrote:
> > > Karel reminded me of this old patch.  Here's a revision of the patch.
> > > Major changes in v2:
> > > 
> > > -  Don't specify the 5 arguments unnecessarily.
> > > 
> > > BTW, I've developed a header file that might be useful for the general
> > > public.  See in a reply to this mail.
> > 
> > Here it is.  I think it would be useful to provide this in some libprctl
> > library so that everyone can use these, instead of raw prctl(2).  What
> > do you think?  We could start by including this header file within
> > util-linux, and then consider providing in a separate git repository so
> > that distros can package it as a system library.
> 
> What about fixing raw prctl(2) in libc to avoid the issues you are
> fixing in your original patch? prctl() could be a macro which counts its
> passed arguments, dispatching to a set of inline functions which then in
> turn call the underlying prctl() with the correct set of parameters.
> This would be backwards-compatible and safe.

I'm not sure how this would be implementable in a single macro.  If
possible at all, I guess such a macro would be easily over 1k lines of
hardly readable code.  I think providing these inline functions in libc
would be more reasonable.  I can ask glibc and see what they think.


Have a lovely night!
Alex

> 
> (...)
> 
> 
> Thomas

-- 
<https://www.alejandro-colomar.es>
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmkwu1EACgkQ64mZXMKQ
wqnsFQ/5AZGAeKmZv+433mdGr/zIsoZYmPF9XTnNwCN2rUKmOxeH3B4ZvyBEMZG7
QdvLQKGzcoleHwTh5SiYKUeWH6JIu7onHmvYqY8I6mpFGX3WNj+CDQHlrI0wcSBL
ab5G/2/4ptq3kmgoR/zlswVZw5JzltjcKb4mlTPqcF4/iIqaNNjZqwWfiUvkjFbw
PBJTUB+H7rSmfvGg3T3L0uR7oPOThUzNzOFoRxzIB7+dSCwxwlZ2uBrUpYvLbt0m
El7g2b2efRgDwlI7sxUV4C99+csRYJyRDjqftxqiZXvM9fC3J9EfmWzLhTq/NM8t
h4Z2Lps/OdCoyHipN+fsFo98OZbu71av8Fn3Q1PyefAkIcGhMk1qfRVESZYiq5+y
rAo+VDf5C7vmdyNYTpE3MI2mEDAaBV5xC5ATq3haZhAxwzHGB+Xy+Y10bW0J8tuk
JOBT1rFHNgY7ymhejhSxlJQG0HspjZEQ694p0QnXPNk6RfIs1TayMPGgWmermD/K
dZWkZ83nxMeVRTO9qrIBZ7i2wB2lQzZm3Onm1z96NnnWj9ENNka2VPK+qqRDVveC
4/xUQYhxXBcjoK32sxOFzP+Udv8+M5eGxnNMt1bikHTehiA2X6sWU1ScYioDq15c
dwFC2l1tT3yj+ap1uFPaIEQQ8l0xfNk/2CnoRpESS6geyo5Dy4E=
=XN/c
-----END PGP SIGNATURE-----