From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752563AbbFDJLK (ORCPT ); Thu, 4 Jun 2015 05:11:10 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:35833 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbbFDJLF (ORCPT ); Thu, 4 Jun 2015 05:11:05 -0400 Date: Thu, 4 Jun 2015 11:11:00 +0200 From: Ingo Molnar To: Milos Vyletel Cc: Peter Zijlstra , Paul Mackerras , Ingo Molnar , Arnaldo Carvalho de Melo , Jiri Olsa , Don Zickus , Andy Shevchenko , "Steven Rostedt (Red Hat)" , "open list:PERFORMANCE EVENT..." Subject: Re: [PATCH] perf tools: avoid possible race condition in copyfile Message-ID: <20150604091100.GA19775@gmail.com> References: <1433407453-28739-1-git-send-email-milos@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433407453-28739-1-git-send-email-milos@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Milos Vyletel wrote: > Use unique temporary files when copying to buildid dir to prevent races > in case multiple instances are trying to copy same file. This is done by > > - creating template in form /..XXXXXX where the suffix is > used by mkstemp() to create unique file > - change file mode > - copy content > - if successful link temp file to target file > - unlink temp file > > At this point the only file left at target path should be the desired > one either created by us or other instance if we raced. This should also > prevent not yet fully copied files to be visible to to other perf > instances that could try to parse them. > > On top of that slow_copyfile no longer needs to deal with file mode when > creating file since temporary file is already created and mode is set. > > Signed-off-by: Milos Vyletel Ok, that looks nice! Assuming it passes testing you can add my ack to it: Acked-by: Ingo Molnar Is there any other place in tools/perf where we are using file locking or racy shared access to the same file(s)? Thanks, Ingo