All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@stusta.de>
To: Khem Raj <raj.khem@gmail.com>
Cc: openembedded-devel@lists.openembedded.org
Subject: Re: [meta-oe][PATCH V2] ledmon: control hard disk led for RAID arrays
Date: Mon, 15 Apr 2019 14:44:10 +0300	[thread overview]
Message-ID: <20190415114410.GA9707@localhost> (raw)
In-Reply-To: <20190410043244.12131-1-raj.khem@gmail.com>

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



  reply	other threads:[~2019-04-15 11:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-10  4:32 [meta-oe][PATCH V2] ledmon: control hard disk led for RAID arrays Khem Raj
2019-04-15 11:44 ` Adrian Bunk [this message]
2019-04-15 14:29   ` Khem Raj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190415114410.GA9707@localhost \
    --to=bunk@stusta.de \
    --cc=openembedded-devel@lists.openembedded.org \
    --cc=raj.khem@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.