* [PATCH] busybox: Guard against interrupted compiles
@ 2017-01-23 12:26 Richard Purdie
2017-01-23 12:35 ` Richard Purdie
0 siblings, 1 reply; 6+ messages in thread
From: Richard Purdie @ 2017-01-23 12:26 UTC (permalink / raw)
To: openembedded-core
If busybox is interrupted during do_compile, it can corrupt .config with
the suid version, or worse. Typically this leads to files disappearing,
particularly /etc/init.d/* which leads to an empty busybox-hwclock.
That then results in errors at do_rootfs time due to the missing package.
The fix is to use any 'orig' present to restore stat at the start of
compile.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
meta/recipes-core/busybox/busybox.inc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc
index 1f4a48c..f247e8d 100644
--- a/meta/recipes-core/busybox/busybox.inc
+++ b/meta/recipes-core/busybox/busybox.inc
@@ -141,6 +141,10 @@ do_compile() {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then
# split the .config into two parts, and make two busybox binaries
+ if [ -e .config.org ]; then
+ # Need to guard again an interrupted do_compile - restore any backup
+ cp .config.orig .config
+ fi
cp .config .config.orig
oe_runmake busybox.cfg.suid
oe_runmake busybox.cfg.nosuid
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] busybox: Guard against interrupted compiles
2017-01-23 12:26 [PATCH] busybox: Guard against interrupted compiles Richard Purdie
@ 2017-01-23 12:35 ` Richard Purdie
2017-01-23 12:56 ` Mario Domenech Goulart
0 siblings, 1 reply; 6+ messages in thread
From: Richard Purdie @ 2017-01-23 12:35 UTC (permalink / raw)
To: openembedded-core
On Mon, 2017-01-23 at 12:26 +0000, Richard Purdie wrote:
> diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-
> core/busybox/busybox.inc
> index 1f4a48c..f247e8d 100644
> --- a/meta/recipes-core/busybox/busybox.inc
> +++ b/meta/recipes-core/busybox/busybox.inc
> @@ -141,6 +141,10 @@ do_compile() {
> unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
> if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep
> "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then
> # split the .config into two parts, and make two busybox
> binaries
> + if [ -e .config.org ]; then
> + # Need to guard again an interrupted
> do_compile - restore any backup
> + cp .config.orig .config
> + fi
I have fixed the typo...
Cheers,
Richard
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] busybox: Guard against interrupted compiles
2017-01-23 12:35 ` Richard Purdie
@ 2017-01-23 12:56 ` Mario Domenech Goulart
2017-01-23 13:05 ` Richard Purdie
0 siblings, 1 reply; 6+ messages in thread
From: Mario Domenech Goulart @ 2017-01-23 12:56 UTC (permalink / raw)
To: Richard Purdie; +Cc: openembedded-core
Hi,
On Mon, 23 Jan 2017 12:35:52 +0000 Richard Purdie <richard.purdie@linuxfoundation.org> wrote:
> On Mon, 2017-01-23 at 12:26 +0000, Richard Purdie wrote:
>> diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-
>> core/busybox/busybox.inc
>> index 1f4a48c..f247e8d 100644
>> --- a/meta/recipes-core/busybox/busybox.inc
>> +++ b/meta/recipes-core/busybox/busybox.inc
>> @@ -141,6 +141,10 @@ do_compile() {
>> unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
>> if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep
>> "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then
>> # split the .config into two parts, and make two busybox
>> binaries
>> + if [ -e .config.org ]; then
>> + # Need to guard again an interrupted
>> do_compile - restore any backup
>> + cp .config.orig .config
>> + fi
>
> I have fixed the typo...
Wouldn't it be better to have something like
cp .config.orig .config || true
instead, to prevent race conditions?
All the best.
Mario
--
http://parenteses.org/mario
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] busybox: Guard against interrupted compiles
2017-01-23 12:56 ` Mario Domenech Goulart
@ 2017-01-23 13:05 ` Richard Purdie
2017-01-23 14:37 ` Mario Domenech Goulart
0 siblings, 1 reply; 6+ messages in thread
From: Richard Purdie @ 2017-01-23 13:05 UTC (permalink / raw)
To: Mario Domenech Goulart; +Cc: openembedded-core
On Mon, 2017-01-23 at 13:56 +0100, Mario Domenech Goulart wrote:
> Hi,
>
> On Mon, 23 Jan 2017 12:35:52 +0000 Richard Purdie <richard.purdie@lin
> uxfoundation.org> wrote:
>
> >
> > On Mon, 2017-01-23 at 12:26 +0000, Richard Purdie wrote:
> > >
> > > diff --git a/meta/recipes-core/busybox/busybox.inc
> > > b/meta/recipes-
> > > core/busybox/busybox.inc
> > > index 1f4a48c..f247e8d 100644
> > > --- a/meta/recipes-core/busybox/busybox.inc
> > > +++ b/meta/recipes-core/busybox/busybox.inc
> > > @@ -141,6 +141,10 @@ do_compile() {
> > > unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
> > > if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep
> > > "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then
> > > # split the .config into two parts, and make two busybox
> > > binaries
> > > + if [ -e .config.org ]; then
> > > + # Need to guard again an interrupted
> > > do_compile - restore any backup
> > > + cp .config.orig .config
> > > + fi
> > I have fixed the typo...
> Wouldn't it be better to have something like
>
> cp .config.orig .config || true
>
> instead, to prevent race conditions?
Prevent which race condition? I'd hope at this point we're the only
thing touching the .config file?
Cheers,
Richard
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] busybox: Guard against interrupted compiles
2017-01-23 13:05 ` Richard Purdie
@ 2017-01-23 14:37 ` Mario Domenech Goulart
2017-01-23 14:41 ` Richard Purdie
0 siblings, 1 reply; 6+ messages in thread
From: Mario Domenech Goulart @ 2017-01-23 14:37 UTC (permalink / raw)
To: Richard Purdie; +Cc: openembedded-core
On Mon, 23 Jan 2017 13:05:48 +0000 Richard Purdie <richard.purdie@linuxfoundation.org> wrote:
> On Mon, 2017-01-23 at 13:56 +0100, Mario Domenech Goulart wrote:
>>
>> On Mon, 23 Jan 2017 12:35:52 +0000 Richard Purdie <richard.purdie@linuxfoundation.org> wrote:
>>
>> > On Mon, 2017-01-23 at 12:26 +0000, Richard Purdie wrote:
>> > >
>> > > diff --git a/meta/recipes-core/busybox/busybox.inc
>> > > b/meta/recipes-
>> > > core/busybox/busybox.inc
>> > > index 1f4a48c..f247e8d 100644
>> > > --- a/meta/recipes-core/busybox/busybox.inc
>> > > +++ b/meta/recipes-core/busybox/busybox.inc
>> > > @@ -141,6 +141,10 @@ do_compile() {
>> > > unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
>> > > if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep
>> > > "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then
>> > > # split the .config into two parts, and make two busybox
>> > > binaries
>> > > + if [ -e .config.org ]; then
>> > > + # Need to guard again an interrupted
>> > > do_compile - restore any backup
>> > > + cp .config.orig .config
>> > > + fi
>> > I have fixed the typo...
>> Wouldn't it be better to have something like
>>
>> cp .config.orig .config || true
>>
>> instead, to prevent race conditions?
>
> Prevent which race condition? I'd hope at this point we're the only
> thing touching the .config file?
Yeah, I hope so.
I mean, the "if exists(file){ do_something_with(file) }" idiom is
intrinsically subject to race conditions (time of check to time of use).
If we can [easily] avoid them, why not?
All the best.
Mario
--
http://parenteses.org/mario
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] busybox: Guard against interrupted compiles
2017-01-23 14:37 ` Mario Domenech Goulart
@ 2017-01-23 14:41 ` Richard Purdie
0 siblings, 0 replies; 6+ messages in thread
From: Richard Purdie @ 2017-01-23 14:41 UTC (permalink / raw)
To: Mario Domenech Goulart; +Cc: openembedded-core
On Mon, 2017-01-23 at 15:37 +0100, Mario Domenech Goulart wrote:
> On Mon, 23 Jan 2017 13:05:48 +0000 Richard Purdie <richard.purdie@lin
> uxfoundation.org> wrote:
> > On Mon, 2017-01-23 at 13:56 +0100, Mario Domenech Goulart wrote:
> > > On Mon, 23 Jan 2017 12:35:52 +0000 Richard Purdie
> > > <richard.purdie@linuxfoundation.org> wrote:
> > > Wouldn't it be better to have something like
> > >
> > > cp .config.orig .config || true
> > >
> > > instead, to prevent race conditions?
> > Prevent which race condition? I'd hope at this point we're the only
> > thing touching the .config file?
> Yeah, I hope so.
>
> I mean, the "if exists(file){ do_something_with(file) }" idiom is
> intrinsically subject to race conditions (time of check to time of
> use).
> If we can [easily] avoid them, why not?
I think it makes the code harder to read/understand and we don't need
to do that...
Cheers,
Richard
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-01-23 14:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-23 12:26 [PATCH] busybox: Guard against interrupted compiles Richard Purdie
2017-01-23 12:35 ` Richard Purdie
2017-01-23 12:56 ` Mario Domenech Goulart
2017-01-23 13:05 ` Richard Purdie
2017-01-23 14:37 ` Mario Domenech Goulart
2017-01-23 14:41 ` Richard Purdie
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.