Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5962182ybi; Wed, 29 May 2019 00:10:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+HTEJ/qLwk7DcS3CRQYENKZ77c/a1AFbgE+sj7UIbtPvBhBPemwRC/FaLfpDGXr+QmIvp X-Received: by 2002:a63:1a5e:: with SMTP id a30mr38974123pgm.433.1559113859143; Wed, 29 May 2019 00:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559113859; cv=none; d=google.com; s=arc-20160816; b=zrTQaR2FxJikHvkO/77GAbJjCb+RySl3Alh3Ft0K8eKa0msx5Xy6xb0HqdcqD1y1F1 HiGa7dXrHXrO5UWglzCbUvumu8uzr6zjO19Hw6ZfOtYAH4MQWejCq7OaB5Dm/hAVnaJg 5Cs7uWUsMgUEQmYD2+HiKBNVvPAhejXlqO74RXTIhDWDev2q4OsK23+Tn6KbzAKDz3oh fxVqmM2JGtKnldNV1Biifc/9JqmYbLgWZQdnseEUpLNgSB312ZI3iP9ToizHn5zh1nrP k4QlRPXiRJfeYXhQ/u+iOFCAG6M3uKLbiJQE375Py+o4ZntactMHR78MSdN7Kiiaesi5 B2ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0hmEt8XBAszMFOt/NHrMak9iR4Ln+O6rhKTThaepQX0=; b=y6wScFlVhe15Avbsc29dLg8K24mgf2IW+CTsRfhSNX76n0V0lA+nQ5DunxC4y9Vve3 Tc3HASResisPtR+8rG2NRyjywhImhaCiRpYr4IQ3AJPaCltcV1axTG1GzQPIm6+2tmbp tqtBw6Kx0OulJpAcHIZW/mk7E1rTndVbqW2QugG6p2mgdNRhl1DWy9IrfIkE23QfBDIr ni7/aa/f8qMyohqbzL4ayJAF9xBHtPIZPl6So0vMx3gBj6wb5l0y+P6qbdjzL6Ns2k3T zN9jGloh2hNTRkinurpJ8/36Wjux5cRGBkQctHKBPPc/GhXzs9O25oKe+lgBqYOm1Q6M XidQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p49ChQ13; 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 u1si25302820pgo.595.2019.05.29.00.10.43; Wed, 29 May 2019 00:10:59 -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=p49ChQ13; 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 S1726408AbfE2HJl (ORCPT + 99 others); Wed, 29 May 2019 03:09:41 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:46123 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbfE2HJl (ORCPT ); Wed, 29 May 2019 03:09:41 -0400 Received: by mail-lj1-f195.google.com with SMTP id m15so1295175ljg.13 for ; Wed, 29 May 2019 00:09:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0hmEt8XBAszMFOt/NHrMak9iR4Ln+O6rhKTThaepQX0=; b=p49ChQ13CkTgafcWq6Mx8FOk/3a/AeGpi05o5uxn0TRjMP7yQKQUwXpN1bbkt6bsUL BOp03/oTIkbFDCJgo8EFfNE0dDIo9i7rKReMyFNF1dZ/M1Tga6IFPJqU6RNwQ9ztAKEi kVPSOn09OJUcGey1NdvjzyLfUrSxYu2LvzfPCvj/ykDhrPxYoFREu8hf7+IFKkVuznxg wzzsesZ5sTsck6PUx8smbK+YfBzvT0kXI2A1La8N2CmQUuFn1pR26ai5oseyyE1t//7M Jp5OBTnFMGRX4xsL05DMLjI183G/vREXuSDRD9tAOSzGCVHCv3Od22rktQlI1NPK0/Wh hWLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0hmEt8XBAszMFOt/NHrMak9iR4Ln+O6rhKTThaepQX0=; b=n+VW0VvtJ6xS5GzeRNo78U9H48ms2BOpcKA3Ce/G0hwPVIysTFDqh4GJ8JrbuALCRk SzwpvlBcbdOOGK8uGU8JAKEnu8N743BVl5N4yyCPXbQHmA7au3artTfsXnPZOQrgRcJb HiStFb/CZ3evEBC3MS5vWYciYw+GbHouZfPy+T9T2ZYq6aru+mjwvRabmanspJIFaB42 6QlSjhm5W+fwWFugPRYEXYGTm0B+uyHrhbM4HF4LBDQrUWoF8SK3MLkVTPVlgdOJox1Y GS/QBXwEHNpOrl2aNmtRMPAPJxmHgT0g+RiAASLneFIybQcvZWE5vIGY9EVs5cjXSvOh u/OA== X-Gm-Message-State: APjAAAX1qow/Q0UkQGFG+K1SUpJa1ZAL2/DWXccs1tRaHqouwSpXyKjy VvV08yIzXvQ2n5nLToSyTdU5kIB+31Gm30fQ7iI= X-Received: by 2002:a2e:9dc6:: with SMTP id x6mr1537784ljj.27.1559113778900; Wed, 29 May 2019 00:09:38 -0700 (PDT) MIME-Version: 1.0 References: <20190528193004.GA7744@gmail.com> In-Reply-To: <20190528193004.GA7744@gmail.com> From: Souptick Joarder Date: Wed, 29 May 2019 12:39:27 +0530 Message-ID: Subject: Re: [PATCH] mm: Fail when offset == num in first check of vm_map_pages_zero() To: Miguel Ojeda Cc: Matthew Wilcox , Peter Zijlstra , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , "Aneesh Kumar K.V" , Huang Ying , open list , Linux-MM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 29, 2019 at 1:38 AM Miguel Ojeda wrote: > > If the user asks us for offset == num, we should already fail in the > first check, i.e. the one testing for offsets beyond the object. > > At the moment, we are failing on the second test anyway, > since count cannot be 0. Still, to agree with the comment of the first > test, we should first there. I think, we need to cc linux-mm. > > Signed-off-by: Miguel Ojeda > --- > mm/memory.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/memory.c b/mm/memory.c > index ddf20bd0c317..74cf8b0ce353 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -1547,7 +1547,7 @@ static int __vm_map_pages(struct vm_area_struct *vma, struct page **pages, > int ret, i; > > /* Fail if the user requested offset is beyond the end of the object */ > - if (offset > num) > + if (offset >= num) > return -ENXIO; > > /* Fail if the user requested size exceeds available object size */ > -- > 2.17.1 >