[oe] [meta-oe][PATCH V2] ledmon: control hard disk led for RAID arrays

Adrian Bunk bunk at stusta.de
Mon Apr 15 11:44:10 UTC 2019


On Tue, Apr 09, 2019 at 09:32:44PM -0700, Khem Raj wrote:
>...
> +musl does not support on_exit which is used in clean up.
> +Instead use atexit with is supported by musl and glibc.

The functions have different signatures, and this patch introduces bugs 
for cases that use the parameters of on_exit.

int on_exit(void (*function)(int , void *), void *arg);
int atexit(void (*function)(void));

Example:

>...
> +-	if (on_exit(_ledmon_status, &terminate))
> ++	if (atexit(_ledmon_status))
>...

static void _ledmon_status(int status, void *ignore)
{
        if (*((int *)ignore) != 0)
                log_info("exit status is %s.", strstatus(status));
        else if (status != STATUS_SUCCESS)
                log_error("parent exit status is %s.", strstatus(status));
}

With the bogus atexit change no parameters are passed to _ledmon_status,
and the function uses (and dereferenes) whatever garbage is currently
in the stack/registers where function parameters are expected.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed



More information about the Openembedded-devel mailing list