From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A16ECA9EAF for ; Fri, 25 Oct 2019 02:32:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3A495206DD for ; Fri, 25 Oct 2019 02:32:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pTMCWdIk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A495206DD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BF1DC6B0003; Thu, 24 Oct 2019 22:32:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA2B76B0006; Thu, 24 Oct 2019 22:32:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB8C16B0007; Thu, 24 Oct 2019 22:32:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0249.hostedemail.com [216.40.44.249]) by kanga.kvack.org (Postfix) with ESMTP id 8AC356B0003 for ; Thu, 24 Oct 2019 22:32:58 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 4575A441C for ; Fri, 25 Oct 2019 02:32:58 +0000 (UTC) X-FDA: 76080734436.14.apple73_713005dee1f5a X-HE-Tag: apple73_713005dee1f5a X-Filterd-Recvd-Size: 5603 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Fri, 25 Oct 2019 02:32:57 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id c3so435938plo.2 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=XLOG/Qo2FQsmnZkjs8AxsGPqyTvLB0JaXymzRfCD6VvYwRb6AjqJcr5cs3WTepk/ks e595AzoxV+Lf0WSqzNqtSM0nKJOVfdeOt01q95d0Iq7h+0CIrj40bcAuS09JrCL+MsSB dyfg7feTAZrrqRcLd3ITpnldlpsYStj7OJEjEaZm1K4xkKi3fUNFInw65kC+cTGfK3ns 3wRiDHWc6FfqMxG9akO4waekMm5813ZpKXAZ6ewxsAfiJzNnrqoIP/AN6vanrcGOj1fG 8g7ydFk1Q22Xd093D4LlyzLZYaac0aDoK+hBHNT2p/0KC1aiN4IbrwH1cxDauTZTc40I PjPg== X-Gm-Message-State: APjAAAX8BpHtnVu3kCg5DtPUksw8ud27rZrFfmwsRvMZhJFZtAIsBtTG Wlekn34828vGRpCe+DBLtFV4vA== X-Google-Smtp-Source: APXvYqzBwaAIQFbX3bMEtf0GQp6J6XBRgOCr8x81MVhZh1qy1hbfTEFcOAEv5o2X8PBCHhwS3S4rAA== 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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; > >