All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] binman: ensure temp filenames don't collide
Date: Thu, 19 Jul 2018 15:14:49 -0600	[thread overview]
Message-ID: <22be70bb-35f8-8cde-d377-d04e00991185@wwwdotorg.org> (raw)
In-Reply-To: <CAPnjgZ0MBJouSQNs6OcK9H_fC4XOKnwBHaJLNEAN=7JrBN3PbQ@mail.gmail.com>

On 07/18/2018 07:32 PM, Simon Glass wrote:
> Hi Stephen,
> 
> On 16 July 2018 at 16:51, Stephen Warren <swarren@wwwdotorg.org> wrote:
>> From: Stephen Warren <swarren@nvidia.com>
>>
>> The U-Boot Makefile can invoke binman multiple times in parallel. This
>> is problematic because binman uses a static hard-coded temporary file
>> name. If two instances of binman use that filename at the same time, one
>> writing one reading, they may silently read the wrong content or actively
>> detect missing signatures and error out the build process. Fix this by
>> using a PID-specific filename instead.
>>
>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>> ---
>>  tools/binman/control.py | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/binman/control.py b/tools/binman/control.py
>> index a40b300fdacb..515999278949 100644
>> --- a/tools/binman/control.py
>> +++ b/tools/binman/control.py
>> @@ -121,7 +121,7 @@ def Binman(options, args):
>>              # output into a file in our output directly. Then scan it for use
>>              # in binman.
>>              dtb_fname = fdt_util.EnsureCompiled(dtb_fname)
>> -            fname = tools.GetOutputFilename('u-boot-out.dtb')
>> +            fname = tools.GetOutputFilename('u-boot-out.dtb') + str(os.getpid())
>>              with open(dtb_fname) as infd:
>>                  with open(fname, 'wb') as outfd:
>>                      outfd.write(infd.read())
>> --
>> 2.18.0
>>
> 
> But the output directory is itself (normally) a temporary dir. That
> determines the directly which GetOutputFilename() uses. So I am not
> sure how this can happen in practice?

IIRC, the output directory for all 3 files was the same; the root of the
build output directory. Perhaps the fact I run "make O=build-xxx" rather
than just "make" makes a difference?

  reply	other threads:[~2018-07-19 21:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16 22:51 [U-Boot] [PATCH] binman: ensure temp filenames don't collide Stephen Warren
2018-07-19  1:32 ` Simon Glass
2018-07-19 21:14   ` Stephen Warren [this message]
2018-07-20  2:17     ` Simon Glass
2018-07-20  4:43       ` Stephen Warren
2018-07-21  1:52         ` Simon Glass

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=22be70bb-35f8-8cde-d377-d04e00991185@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=u-boot@lists.denx.de \
    /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.