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=-8.5 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 4E51CCA9EAF for ; Thu, 24 Oct 2019 12:25:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 19B1720679 for ; Thu, 24 Oct 2019 12:25:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19B1720679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 936026B0269; Thu, 24 Oct 2019 08:25:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E5886B026B; Thu, 24 Oct 2019 08:25:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D54A6B026D; Thu, 24 Oct 2019 08:25:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id 5BE3E6B0269 for ; Thu, 24 Oct 2019 08:25:56 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id B3E0883E3 for ; Thu, 24 Oct 2019 12:25:55 +0000 (UTC) X-FDA: 76078599870.02.lip41_8afbe5fafac0c X-HE-Tag: lip41_8afbe5fafac0c X-Filterd-Recvd-Size: 2881 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Thu, 24 Oct 2019 12:25:54 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 79C7DB259; Thu, 24 Oct 2019 12:25:53 +0000 (UTC) Date: Thu, 24 Oct 2019 14:25:52 +0200 From: Michal Hocko To: Li Xinhai Cc: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] mm: allow unmapped hole at head side of mbind range Message-ID: <20191024122552.GB658@dhcp22.suse.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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-10-19 07:35:06, 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. > 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. The changelog is a bit cryptic but you are right. find_vma returns the first vma that ends above the given address. If vm_start > start then there is still an overlap possible [ vma ] [start end] and we should mbind [vma->vm_start, end] at least. I haven't checked whether changing the condition is sufficient for the rest of the code to work properly. I am pretty sure a test case shouldn't be really hard to construct and add to the kernel testing machinery. Btw. when writing a changelog then it is always preferred to describe user visible effect of the patch. In this case it would be an unexpected EFAULT on a range that starts before an existing VMA while still overlapping it. Make sure to note that. Fixes: 9d8cebd4bcd7 ("mm: fix mbind vma merge problem") > Signed-off-by: Li Xinhai > --- > > 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; > -- Michal Hocko SUSE Labs