[PATCH] stdlib: Support malloc-managed environ arrays for compatibility

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Wed Jan 22 21:53:34 GMT 2025



On 22/01/25 18:47, Florian Weimer wrote:
> * Andreas K. Huettel:
> 
>> [...]
>>> The interim approach was more compatible with other libcs because
>>> it does not assume that the incoming environ pointer is allocated
>>> as if by malloc (if it was written by the application).  However,
>>> it seems to be more important to stay compatible with previous
>>> glibc version: assume the incoming pointer is heap allocated,
>>> and preserve this property after setenv calls.
>>>
>>> Tested on x86_64-linux-gnu.
>>>
>>> I'd prefer to get this into the upcoming
>>> release if possible,  assuming that I can get a review in a timely
>>> fashion.
>>
>> Makes sense. [Where did you find this, and how big is the impact?]
> 
> It's in usermode, a polkit (pkexec)/sudo variant.  It basically does
> free (environ[i]) (which has always been invalid) followed by free
> (environ).  Only the latter crashes, and the posted patch papers over
> that.
> 
>   userhelper dumped core when running subscription-manager
>   <https://issues.redhat.com/browse/RHEL-73769>
> 
>> I guess you know who to poke for the review.
> 
> Adhemerval, could you review this?  Carlos probably won't be able to
> have a look this week.

I will take a look tomorrow or Friday.



More information about the Libc-alpha mailing list