Received: by 10.213.65.68 with SMTP id h4csp381367imn; Tue, 27 Mar 2018 00:34:38 -0700 (PDT) X-Google-Smtp-Source: AG47ELuCpDPj9pSAyb1Y94nVOyyId6Z2mBvuCJczN68CIs86LKeb478pT+wO6Cs6gU/0h/+FMsnE X-Received: by 10.98.138.144 with SMTP id o16mr16371604pfk.216.1522136078660; Tue, 27 Mar 2018 00:34:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522136078; cv=none; d=google.com; s=arc-20160816; b=DtwI1gf++9HKB9zgQGM0qU4DWxj7r4KC2K8ZpAZPI4XmwnkSTcGDN53JuTE2Dz6DfQ 3eJiKA1zQmktTW9Sdl7eAV9D5txiEyfqEK5QKyFqErybXOi8d5jhYxhERnwk3u6B4snF ufo4tYx7YR89Z1fhDT3VlaAhNB+C4jlsBH+xyGOavH/nCeG358yCfkIqSorLyNs84B2o iI8KKtd0HjYCsKHKhDg6PfapjFTMNACxjrB4lVW66Uqy95Y4oxjfKgexX3Ht1RDEq4k+ LZXDmxrI9UF9UB5tVWgGNXLR9YGaslbs6uUACpJbPYWhfTJBEGwH8uxqEFGJdxTh6bzG bsEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=bioSDpUNJWfdAN62d/rReyZM2jRh1Ow+eB6XLi1NXj4=; b=JbE/McHGjSRJGnU8kZEQn2fp6KHLUVUBqp+z9ubP8jHequ1lpGjMFlNlpS0eW4AYi3 QXVZCDAgqDxK3hDYnEIrhfunnF4xPJl+XX447p5tZ/bEjC6GzFWQ/U3eW3/ieehDtqRY 3DiH59EzlIiFBmBhZIbY8Y/S295alMEWVbdtXnzt76ewLgFyAkG1R9Sq0JRZNwrVj/m6 Zpcod1TBvpxL5rJoRNMIAZufDMEFSKzNxmpss+F6u3Lp0DFQYDWYNU4ecClNugKDuOpY 2LhMJSjarewHO61nc9qk2ZTooWrXxdlJh4+hD8vQoRRdJeAj2zydO7015IHfK2OFvTvk w21Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tAhT1kjo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si459006pgq.260.2018.03.27.00.34.24; Tue, 27 Mar 2018 00:34:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tAhT1kjo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751732AbeC0HcR (ORCPT + 99 others); Tue, 27 Mar 2018 03:32:17 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:45279 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750944AbeC0HcP (ORCPT ); Tue, 27 Mar 2018 03:32:15 -0400 Received: by mail-lf0-f65.google.com with SMTP id q5-v6so6580141lff.12 for ; Tue, 27 Mar 2018 00:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bioSDpUNJWfdAN62d/rReyZM2jRh1Ow+eB6XLi1NXj4=; b=tAhT1kjoTn9t8NVsJYggGqGL0hT1jLm7i/w1B4IszV+Fh6tZ2BeEfhgMAKxE5Q1kAk LL8fswAtTADzCiVI5atJbPAWu9WPqVv6/+c7glTlAU6eQFiJ8ib3HMQfnwXqDoRtjyNA z1DqN02g+JlTHckLzIeQXAh11iK7JJ3nBzUyp8m7lZlDryvTyXV3qkHfe3MQWXv+7fzn 1eO+L6BavZ0pTtDOV3vA/WJOv53TE70xft5K6kvQgaokhhwXVixw/mJOF1HKFa+Woffi aQrxmN8KyONgJuC19EikVJHiaKkoPnFtuViwQPQRf0YA7au1Gwo13QcIwaxg3K/ELDoA MNkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bioSDpUNJWfdAN62d/rReyZM2jRh1Ow+eB6XLi1NXj4=; b=pzZtccPFcnG62yZXi19h3bsotAzw3DD6O60aYprQylIPgwcPn5lTKkwdmKASvbLfeQ zZA3a6asj0U9wl5NwZHCOnhP477btIOHDHwRHtkT0utyZnXhnKH4SYKnkbvzqszDomwO NqO+y18ARX/Rye3EsRVP6tizszMRQYRdQwtaLnb1gjOCSnyOdBSPhys1ieF0vJVBYX1o WwlgiMlu0gZJBrvwhBZAypFyaUXFSERmtg8dS/m8QnCkjv51NvqCGy23IupEbts+HiJW EKjopdJZdHQfq6OOCmWlC9AoGTJ3VOUsYSucnlNKdIxVD+084DcfVwZc37Be1IJ+1MWV cCZg== X-Gm-Message-State: AElRT7EUZpPjpzdEL8YJu1mjUPOlkVA0qQcCOI02gEeKSgbai3CBDayW vR6MdDYmMy7/QbA6cdRldLo= X-Received: by 10.46.146.18 with SMTP id k18mr4009784ljg.100.1522135933737; Tue, 27 Mar 2018 00:32:13 -0700 (PDT) Received: from uranus.localdomain ([5.18.102.224]) by smtp.gmail.com with ESMTPSA id e28-v6sm113231lfb.52.2018.03.27.00.32.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Mar 2018 00:32:12 -0700 (PDT) Received: by uranus.localdomain (Postfix, from userid 1000) id 8B9AD460AA4; Tue, 27 Mar 2018 10:32:12 +0300 (MSK) Date: Tue, 27 Mar 2018 10:32:12 +0300 From: Cyrill Gorcunov To: Yang Shi Cc: Matthew Wilcox , adobriyan@gmail.com, mhocko@kernel.org, mguzik@redhat.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [v2 PATCH] mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct Message-ID: <20180327073212.GG2236@uranus> References: <1522088439-105930-1-git-send-email-yang.shi@linux.alibaba.com> <20180326183725.GB27373@bombadil.infradead.org> <20180326192132.GE2236@uranus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 26, 2018 at 05:59:49PM -0400, Yang Shi wrote: > > Say we've two syscalls running prctl_set_mm_map in parallel, and imagine > > one have @start_brk = 20 @brk = 10 and second caller has @start_brk = 30 > > and @brk = 20. Since now the call is guarded by _read_ the both calls > > unlocked and due to OO engine it may happen then when both finish > > we have @start_brk = 30 and @brk = 10. In turn "write" semaphore > > has been take to have consistent data on exit, either you have [20;10] > > or [30;20] assigned not something mixed. > > > > That said I think using read-lock here would be a bug. > > Yes it sounds so. However, it was down_read before > ddf1d398e517e660207e2c807f76a90df543a217 ("prctl: take mmap sem for writing > to protect against others"). And, that commit is for fixing the concurrent > writing to arg_* and env_*. I just checked that commit, but omitted the brk > part. The potential issue mentioned by you should exist before that commit, > but might be just not discovered or very rare to hit. > > I will change it back to down_write. down_read before was a bug ;) And it was not discovered earlier simply because not that many users of this interface exist, namely only criu as far as I know by now.