[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen-mapcache: avoid a race on memory map while using MAP_FIXED


  • To: Igor Druzhinin <igor.druzhinin@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 20 Apr 2021 12:26:45 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jpWLRdkqxEup8pvZVCLInMLs+8avjXBNMuSlaH9B3QU=; b=N4R6G9SawBQtzp8fBbp7wYpJvjHkImWliO2Pp40aFOrO5lq8G6YaMsASdFvCzcMzPAFenRCA3ULs/DaaoS1sFiD+lCPKLh71c6YCE70sh3qdUnMprYqLWRSCAue/YEiKQxhrr9xRx5c4zLJXzIZpbTzQtumCM53mY57eA/TbvIg6j19j6567RpxTa3IPZhTQ+aXjx92FA6m2Fpr+bDZ1k/zGhfG8IbEnaHBvcdFI7TBcaD1CwD4l1f1WIfggT5iTAxl8FzcPdghZHUZcSF47PZ/b/iH4UHmMMZLefzJRPGfpVHDLunn9Q4T6sgIbwYyd4VMmE+YQNQjMl551YWKuzw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NuZdLOglEfg1R2vL9OStc4gXVWH57GUkFORr6Ygu+6VOnFmH4BiYFCgC1pL+hvAn1XVsg3uyvZdlYlPJUlncfFX8fe6q9ZkGAkw6t33vUEetiVR3TOQESoR82KbmhVn3+yBznyCPYvY4TxxN6qMOeXn3p4zscmzfpX3MfRkRJ5Ie31863Ra8hG9OM7jbTUcsA7ppvp0L09aQjCZllJyfwhGIsINtQlUL3lpeESBuaYt/ZozUXFHJlyifxhe5AM9we/1cTodTgah3dbJMGCTwIyoTpmqwN6g95XtomBjMwtg1JQDZATe6dZNIzMeUUklgTKo0V7u9C8z/6a9+THGaXA==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <qemu-devel@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <sstabellini@xxxxxxxxxx>, <anthony.perard@xxxxxxxxxx>, <paul@xxxxxxx>, <mst@xxxxxxxxxx>, <marcel.apfelbaum@xxxxxxxxx>, <pbonzini@xxxxxxxxxx>, <richard.henderson@xxxxxxxxxx>, <ehabkost@xxxxxxxxxx>
  • Delivery-date: Tue, 20 Apr 2021 10:27:12 +0000
  • Ironport-hdrordr: A9a23:kYS7RKOs0m4BEcBcTjajsMiAIKoaSvp033AA3SlKKSB9WMqeis yogbAnxQb54QxhPE0ItPKhHO27QX3a/YNo+oV5B9yfdSTvpWfAFu1fxKT4xTmIIULD38p88Y slTKRkEt33CjFB/KPHyS21CcwpztXC0I3Av5a8815XQQtna75t4m5CY273LmRMSBBCFd4FEv OniPZvnSaqengcc62Adxs4dtXEzuerqLvWJT4cARkf7hKSyRuWgYSRLySl
  • Ironport-sdr: SgYqYk9E/02wCfi7S6/YPYFuO2zCXtPzS48MtR/wzUA/tQZ7m5qqnxfKVJyONl7gZe37/turJk x1yzIQyhB8LoVBygCeBBNoZpeKrEaI9ylwmDPDMBegQrAEA08mLr9/ax4+pQqvo8ruflfwBiNh dgYuq5CWGkoThrXhe3o00ixCxODjgH3BrFHu6b+M9ylScwxUjduSaYlAl/gV3lz1nH+UkRCGlb zki2C9Ob/j3pp0/MQUuYR/n8O8l//ySp+lw6xvlp2cvh8ax9l03O7CdE2LFfiKsKY0xftjW2i4 S1M=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Apr 20, 2021 at 10:45:03AM +0100, Igor Druzhinin wrote:
> On 20/04/2021 09:53, Roger Pau Monné wrote:
> > On Tue, Apr 20, 2021 at 04:35:02AM +0100, Igor Druzhinin wrote:
> > > When we're replacing the existing mapping there is possibility of a race
> > > on memory map with other threads doing mmap operations - the address being
> > > unmapped/re-mapped could be occupied by another thread in between.
> > > 
> > > Linux mmap man page recommends keeping the existing mappings in place to
> > > reserve the place and instead utilize the fact that the next mmap 
> > > operation
> > > with MAP_FIXED flag passed will implicitly destroy the existing mappings
> > > behind the chosen address. This behavior is guaranteed by POSIX / BSD and
> > > therefore is portable.
> > > 
> > > Note that it wouldn't make the replacement atomic for parallel accesses to
> > > the replaced region - those might still fail with SIGBUS due to
> > > xenforeignmemory_map not being atomic. So we're still not expecting those.
> > > 
> > > Tested-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
> > > Signed-off-by: Igor Druzhinin <igor.druzhinin@xxxxxxxxxx>
> > 
> > Should we add a 'Fixes: 759235653de ...' or similar tag here?
> 
> I was thinking about it and decided - no. There wasn't a bug here until QEMU
> introduced usage of iothreads at the state loading phase. Originally this
> process was totally single-threaded. And it's hard to pinpoint the exact
> moment when it happened which is also not directly related to the change
> here.

Right, might be worth mentioning in the commit message then, that the
code was designed to be used without any parallelism, and that the
addition of iothreads is what actually triggered the bug here.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.