Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 23 Apr 2015 00:24:46 -0400
From: Jean-Marc Pigeon <jmp@...e.ca>
To: musl@...ts.openwall.com
Subject: Re: setenv if value=NULL, what say standard? Bug?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/22/2015 10:15 PM, Rich Felker wrote:
> On Wed, Apr 22, 2015 at 09:26:57PM -0400, Jean-Marc Pigeon wrote:
>>> I think the only safe conclusion is that the application is 
>>> incorrect and should ensure that setenv() is never called with
>>> a NULL value.
>>> 
>> Checked glibc, My understanding, it set something as "name=" in
>> the environment, so the variable is present but value is "empty"i
>> (top application to decide what to do). uclibc does something
>> similar (as far I can tell looking at source code)..
>> 
>> 
>> The application is not careful enough, but not incorrect as
>> such.
> 
> It's definitely incorrect. It's doing something that invokes
> undefined behavior.
> 
>> Note: we may have tons of applications with the same problem. if
>> we keep musl setenv like that, musl will be seen as quite
>> unreliable.
> 
> No, actually glibc is fixing this bug (maybe they already did).
> See the thread beginning here:
> 
> https://sourceware.org/ml/libc-alpha/2015-03/threads.html#00449
> 
> My understanding is that glibc is planning to do, or already does
> in the latest version, exactly what musl is doing.
> 
>> If this situation is indeed UB, there is 2 options for musl: 1)
>> Swallow the problem nicely... as glibc and uclibc does. 2) Report
>> an error.. EINVAL? (and document it in manual)
>> 
>> Crashing at "libc" level is not an option.
> 
> I can see how it might seem like that at first, but crashing is 
> actually the best possible behavior. Options 1 and 2 cover up a
I strongly disagree, crashing is not an option for a tools as
musl/libc.

Think about this, you write an application working perfectly right,
but 1 in 1000000 you reach something not trapped by low level and
once in while the application (in production for month) just stop
to work because "unexpected" within musl...
(so someone will propose to set a cron to automatically restart this
unreliable daemon, hmmm...)

Far better to return "trouble" status, then it is to the application
to decide what must be done in context, as ignore, override, bypass,
crash, etc.

A sensible policy in case of UB would be for such low level code to
swallow the problem, (protect the hardware and keep the program
running as much as possible).

> potentially serious bug -- it's not clear what the application was 
> trying to do, most likely nobody even thought about what they were 
> trying to do, and even if they did have something in mind it's not 
> reliable or portable. The glibc wiki has some text taken from text
> I wrote on the topic (copied from a stack overflow answer I gave)
> here:

As reported, the crashing application is hwclock, (util-linux-2.26),
this a kind of code in the field for a very  very long time, so the
library (glibc and old libc) used for linux over the years defined an
expected behavior to this "UB".
As other occurrence of this could be present too in other
program/application, crashing would make a bench of applications
to be running hazard (you can have all kind situation with
env variables, near unpredictable).

Something worry me in comments I have seen in the proposed URL,
IMHO purpose of musl/glibc is not to "find bugs by crashing", its
purpose is to be a code "clean, lean, reliable, predictable" (as said
above, "Protect the hardware, report problem, lets the above layer
application decide what to do in case of problem").

Crashing is not an option for code pertaining to musl/libc layer.

(:-} why bother to return an error, just crash for all
problems in open, close, write, etc. just bringing the crashing
concept to the extreme :-}).



> 
> https://sourceware.org/glibc/wiki/Style_and_Conventions#Invalid_pointers
>
>  Specifically it covers why returning an error is not a good idea.
My experience (for a long time now) about writing complex daemon
running for months/year, it is not that straightforward (may
be for a simple application it is)

> 
> Rich
> 


- -- 

A bientôt
===========================================================
Jean-Marc Pigeon                        E-Mail: jmp@...e.ca
SAFE Inc.                             Phone: (514) 493-4280
  Clement, 'a kiss solution' to get rid of SPAM (at last)
     Clement' Home base <"http://www.clement.safe.ca">
===========================================================
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJVOHQOAAoJEAtgwJ4bBQU5bCUP/jxt74112bqFat0+CvFpqNG8
sCEYEIpRcKIB7wWRLwQXQTQ0M82oUzo6bmpYtgorcwJWh5NIo/dFm2FvDW+/uiTs
dtutt45jJN7tsq4BhE/z/jyD44vrVqYZ+gJXf3MFPWeTFx4Kd7aCq3dCDvvoT9lk
Mp9KiiSY+WXfwE/a8CAiw6D+Ma2/iN4zTD1fUekXcZDgu0iMsieeF5uhZNT/L+62
U8K2VdOoR1H731v3GzKFUiesPTiPNbASg0MDfKyYe5kCZMkijbHIx7fGb/VID6dv
01u3bNA8yTfj51MplGv3ddgAzYcOMBMrQ6IXBK4hQPm4wuGp3ELr6IiTepUfkc3y
WYlNHCFqpgMthj2+nsMllwK+uZcbW36+QlYQ4FCuAMaqOjpA+Yr6qmoiOl5HFSMA
FoqarDkUeH3jYWYBFq8aUFQdD8Esyj3mKXAc/Bw45vWGkBykTyJXMYGVh4idukFQ
dkiYTM5rOB3H55dkjB9EnojAX+w0+VG+0H5xtb8fybtQYEr7SbsRO5fhTbmTr/1P
Q6ojm8fhkoRT0JXC+94htj5rT/87QerVIu06YcozqOsqCKBm7HBkokkMTMtWofJ4
sznm9/OtNqbYYTSdDQ7AVn1x0K8ycz5Aw302NOWd5NuSEPal+GuWP2mewhydlXAj
2+W/ox353kVOSWf0t2Ql
=R+I2
-----END PGP SIGNATURE-----


Download attachment "smime.p7s" of type "application/pkcs7-signature" (4242 bytes)

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.