Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5442019ybi; Tue, 28 May 2019 13:11:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8j4q+wYOLx7a6aHeEXrR0c4UvOMg33OM3TAJsT/pzq5FE/pDyv488om8632nFRr64n8HB X-Received: by 2002:a17:90a:8d86:: with SMTP id d6mr7794631pjo.127.1559074261782; Tue, 28 May 2019 13:11:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559074261; cv=none; d=google.com; s=arc-20160816; b=CM0Kk+w3ROPDBWYMG3Y64yVYLPVULlQYtDu8YXuE/lWDx9QzJ/TJRHJYXbMczBSDGh wC4zOUI9cdd8bdYg4Fm7qu17bIgNpBS89NGjcJLu3KbLaPQCq9FEECfzNlcD+o6Fxqzw +LzBHsQdT7Lt0cJfh/SY3J/bQYV9t3G2jdI1t7LyolzZWJGLZ67yZUiNILMxCth7aN+e hxDYUydAVcYDrEZlW+Tw+zybS+P9PItnQHIpu0U9RPx6Anou6dcYktv+AH3REVaePEKS o1IC5Za9eotXwLFmRsumHOAdR5SX2Iq70Fr+BwEh4JMfsYlVhJKpS7yw+bGRq2iOdLg+ kqJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=FwyZOikIAHRFT3QzU5wwJvymvoehhUYtGScgb3Iy2KU=; b=WH+E8xF7ihukx6Ve4sef5gHw74ll/UVoe0hQCWIwB4O0/fkL9/ThYX9ilhreSih8Ix HPD4BJqlGa+bT5e8PgSkW0g3rjnqqcr8dmVKKJdgHJVBIMJMaPoOErWwPO1JuxJ9+eBo loDv17j74/8+UytAeA42IJPMAeERdx66bLrOlYEV63trD57TRBEJdUOnGKzpTxVvzE1V Ixk+Dbgx2u9SMg5+qvYRHeHxQS7v+kjvpgmOyfRHD9GkbV1T8JoTwmYMwKCe8vSI2L+e UwNTifxWqM+BKEpkHLsFCwtoQToQELyoqT5LkozpmSxTZTXm+rWvWlH407TYEJr9CKcK G7lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sPR2LkbH; 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 y34si24641787plb.186.2019.05.28.13.10.46; Tue, 28 May 2019 13:11:01 -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=sPR2LkbH; 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 S1727844AbfE1UIu (ORCPT + 99 others); Tue, 28 May 2019 16:08:50 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46526 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727668AbfE1UIb (ORCPT ); Tue, 28 May 2019 16:08:31 -0400 Received: by mail-wr1-f66.google.com with SMTP id r7so3086wrr.13 for ; Tue, 28 May 2019 13:08:30 -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:mime-version:content-disposition :user-agent; bh=FwyZOikIAHRFT3QzU5wwJvymvoehhUYtGScgb3Iy2KU=; b=sPR2LkbHDwHBTrxKddz4MuIh6aBwoiLqSbdvQbRKGiA5Aqukg3caA5AvXt6kAxSkTL sb0u1UNAWSM6ztF0l3FGHD4AK2BOg/fFM0i9KpDsoZOEovrdKkxgxhU26wADOC34XQ94 j33ud1TudwfJjNOyyMCzHvtB7I+lzLZNxrWoZsoq2yg8bWbmhJLxxrwZKwQK8E8iNzIX yeA27iq4cdSD0bOEL8ih2aHe1EzuAwhPdpl8zAbmkm6ZrddC0BkRRoy0l5W/BXLY8D/c oysvMAlxRqGB7lXUbCJEGjC5cD+dQ510HpQ34tosTrJUR79g5esZauTc3f7gy7xRiCUL obuA== 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:mime-version :content-disposition:user-agent; bh=FwyZOikIAHRFT3QzU5wwJvymvoehhUYtGScgb3Iy2KU=; b=PjD5jF83vMA/ZTwZY8gKKt3rzZjvzv3ft3VskKPZaDRojKPnsb/J5T95J1jn0VUfEk v6z988Wp3KfV3YeP1zNJKEx87/8FsYnMbOalwirs59Q4iRQamu1Ikz64j+syGAu8Mpm0 iJz+W8cB2awj68OKfJvwnlXvwhDr8QUEAYYCzNP/y0vgZmuZ9LVbjUIQvp7qGRKbgqoV uMBz4Klgflq1VuceXJS/hUggYfCGcldOtjtMQ263RLYEbtTjXfIuEAAbIQ8SxrPcVlmR bqUVg7ARE7TA3OA6o197bPTHQKZOyUMOuwZr1lyneG8aSu5s8LEHFH6GuhP/5QUf//OH yS3g== X-Gm-Message-State: APjAAAWvTTI6KlxzvDgsPLadT347XOM0ZaDa6vERIVfGB75XWUSr1ZR6 JfvJhCkD9mh1Xb7u9TEwyqY= X-Received: by 2002:a5d:554b:: with SMTP id g11mr601730wrw.10.1559074110241; Tue, 28 May 2019 13:08:30 -0700 (PDT) Received: from gmail.com (79.108.96.12.dyn.user.ono.com. [79.108.96.12]) by smtp.gmail.com with ESMTPSA id g2sm14396336wru.37.2019.05.28.13.08.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 13:08:29 -0700 (PDT) Date: Tue, 28 May 2019 22:05:40 +0200 From: Miguel Ojeda To: Souptick Joarder Cc: Matthew Wilcox , Peter Zijlstra , =?utf-8?B?SsOpcsO0bWU=?= Glisse , "Aneesh Kumar K.V" , Huang Ying , open list Subject: [PATCH] mm: Fail when offset == num in first check of vm_map_pages_zero() Message-ID: <20190528193004.GA7744@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: elm/2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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