Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4033400ybg; Fri, 25 Oct 2019 12:21:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMlAz/fC+sQYmEdXqMG+TQNWvsLxe1oQAXfgdAwgan7tyQBW67yQsiCxZN/enDiREbOlqk X-Received: by 2002:aa7:da4a:: with SMTP id w10mr5625227eds.209.1572031305415; Fri, 25 Oct 2019 12:21:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572031305; cv=none; d=google.com; s=arc-20160816; b=W8g9yBAOOunHBFNCFLZN9gCnWTqSTC9oM0UAeqlsqK8Vh7j0TaBqBv+Vv4l062MEYd 21YDQZCAcJnwmHOqOQLYxBgMWBDRCmUEm2cHoYk4Rr1r3NLznCXLYB73PwROEwLYNKDD 2F2yenOhyj+ElWmhNmLewwEYdXINxIhkRVgB96RozpKffL90kIhXM2eeykLUektBEEPB h03T1mU6Mut/AnZbExipF3NyO0Il30DA+/CwfDzGJ2RoBbJNlWni5BVvV0h50J0r8+7I jcNaZG9KSbaITnMlERqI0RHoG2+hHrFkh+BaMVCF//SKrtaTDl/TbbSYUtYSUKQg8p8A gIQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=g1ns30NWBvyr7boX6LL1Xy9XjoQxnnSYF9EZ4Db7JXo=; b=ZeANPyGKHTM9oJCLWUCJKZwku4ZnEeM/UgBwKyK8jik+T4M9Esl/A8qYS+PTIMzP2W l4WxrcL++wohitf6NyXucYNBnxt94CF+S8yIWthgaAHQ2CT2n6g27f3piorJ/P1a8vtE o2MXSVBldw/rJTmKiKTqFng/FC75haoh+i7knQVWVzSe7KJaAAL6czwhHaNMdiIIdss8 qtX3pp1xvSlVjukKWySd1pLclnSNFMjNxHbkw3hvbkAN59f/n1JYx6Zg4zXb2oLR++6d Y9wBE6JmmyHMdJlA51sejYLSSoN3fW9TY6FL3zVo/6JF2jxDlhrbhyfkxuY1muJP2WOD M2MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pTMCWdIk; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g25si1768109edr.71.2019.10.25.12.21.22; Fri, 25 Oct 2019 12:21:45 -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=@google.com header.s=20161025 header.b=pTMCWdIk; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732312AbfJYCc5 (ORCPT + 99 others); Thu, 24 Oct 2019 22:32:57 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46941 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728416AbfJYCc5 (ORCPT ); Thu, 24 Oct 2019 22:32:57 -0400 Received: by mail-pl1-f196.google.com with SMTP id q21so406761plr.13 for ; Thu, 24 Oct 2019 19:32:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=g1ns30NWBvyr7boX6LL1Xy9XjoQxnnSYF9EZ4Db7JXo=; b=pTMCWdIkG2cC3CrrCS6QNFDxjPVipsYh4cnjbLOMvo/dRNvfEgjpLq085gUwWBxFI7 oW1yDmWGuCoUBtppG8o5fzQ84VjmJxenG3SWZwrEd9/irg7P9GghSu4xIjpQMllExLmO IwRRhGZt8peS8UzhqKhVzfAvtwE/2kuxn/C4z5QUmWLo3xL/o5wAPxXOTMB2pFtDknpd aOOQJjxTN+2eWKVYjBl3cRroPcjT5Mzk99ZLS7j/iFml1r3qRFvB4Y895bqdewPlk6sW nL1rYXHyfkVHoYNtwSKzXYWDIkXrdKkSuGcr99FBismEKHoTHzLqFFVtJlV5MW3WZyU4 UAMw== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=g1ns30NWBvyr7boX6LL1Xy9XjoQxnnSYF9EZ4Db7JXo=; b=Ei+mtzcUZjKutkcBK36ocGUQ2+ApPvXagALPqT7xctmN9AzztdUcQu/jgheTMAGEqq gGNlcxHuAeKUW3SUwimU9kPhaF7Ai4hh27GJ+a1HZO/p1fj/cRcild/2AImiOMvNTeiQ QLB3hvF3Bp1wOGhcdVaUZSquYJmD44uzDpR9YPmpQfZGs7+9JsBzS93Ply7VWL9IOCHe Ko3URg3M8PbpK0bZvrAhGDW9wqAU7Nygpvx5jNALHkliW4r9iqBGa6pNOCWWV5o4Gnnu zgcJ3TEIhtE81vgcb/uwl5igsgYGDi8A3lPS6NnDUNbRxKcP8EgFoY6Ota9oJOk0P7Y2 MN9g== X-Gm-Message-State: APjAAAW0+Tx3sMs6K56txPDCLolRrDPN7pWyFlgCgjmwIOgAr7KB5p76 qIP+MQo3MCd2sOGZopfkIbszoQ== X-Received: by 2002:a17:902:44d:: with SMTP id 71mr1069193ple.320.1571970775667; Thu, 24 Oct 2019 19:32:55 -0700 (PDT) Received: from [100.112.92.218] ([104.133.9.106]) by smtp.gmail.com with ESMTPSA id b13sm366035pgd.58.2019.10.24.19.32.54 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Oct 2019 19:32:54 -0700 (PDT) Date: Thu, 24 Oct 2019 19:32:39 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Li Xinhai cc: Vlastimil Babka , Michal Hocko , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Linux API Subject: Re: [PATCH] mm: allow unmapped hole at head side of mbind range In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 24 Oct 2019, Vlastimil Babka wrote: > + linux-api > > On 10/24/19 9:35 AM, Li Xinhai wrote: > > From: Li Xinhai > > > > mbind_range silently ignore unmapped hole at middle and tail of the > > specified range, but report EFAULT if hole at head side. > > > Hmm that's unfortunate. mbind() manpage says: > > EFAULT Part or all of the memory range specified by nodemask and maxnode > points outside your accessible address space. Or, there was an unmapped > hole in the specified memory range specified by addr and len. > > That sounds like any hole inside the specified range should return > EFAULT. Yes (though an exception is allowed when restoring to default). > But perhaps it can be also interpreted as you suggest, that the > whole range is an unmapped hole. There's some risk of breaking existing > userspace if we change it either way. > > > It is more reasonable to support silently ignore holes at any part of > > the range, only report EFAULT if the whole range is in hole. > > > > Signed-off-by: Li Xinhai Xinhai, I'm sceptical about this patch: is it something you found by code inspection, or something you found when using mbind()? I've not looked long enough to be certain, nor experimented, but: mbind_range() is only one stage of the mbind() syscall implementation, and is preceded by queue_pages_range(): look what queue_pages_test_walk() does when MPOL_MF_DISCONTIG_OK not set. My impression is that mbind_range() is merely correcting an omission from the checks already made my queue_pages_test_walk() (an odd way to proceed, I admit: would be better to check initially than later). I do think that you should not make this change without considering MPOL_MF_DISCONTIG_OK and its intention. Hugh > > --- > > > > mm/mempolicy.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > > index 4ae967bcf954..ae160d9936d9 100644 > > --- a/mm/mempolicy.c > > +++ b/mm/mempolicy.c > > @@ -738,7 +738,7 @@ static int mbind_range(struct mm_struct *mm, unsigned long start, > > unsigned long vmend; > > > > vma = find_vma(mm, start); > > - if (!vma || vma->vm_start > start) > > + if (!vma || vma->vm_start >= end) > > return -EFAULT; > > > > prev = vma->vm_prev; > >