Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp250312ybd; Tue, 25 Jun 2019 20:44:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSOC7XhDWJnLSYvcl4qKxuUok0lmiETDG4gTJca/JJ+/q3w57Wm9GUIXsQRkbM+GIp6P1s X-Received: by 2002:a17:90a:2244:: with SMTP id c62mr1832278pje.29.1561520684987; Tue, 25 Jun 2019 20:44:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561520684; cv=none; d=google.com; s=arc-20160816; b=0fawO9sWnDAsVM7NAnQtb1u0Z6wfHp0gjd7waWmCdI9z/fUoqi+Lt5Dhe8DfPjQcGn RPo12AD1+46p+mpDrTKV4zNOn5+r7eSHSvJyZoBLoHrQJKdax7mtgGlFg55UUHrWnZqa VFq+bPdXcEOA6oWJ1vlCyvuuaL6bGfxxyBC+iOZ7jE0I3uUlCMgRvGo7yvXj2FSS0LHJ NG3RUnsE12ydKcKaEN6OANyZvJvnDDM4Z3DjePNe9D/yjdMZ5x2ULBVVneqMkiUAYLsJ E/5wfutYtrFy/gNzSJHwmsiwl5GSmjidwmnxxi0ZPTTzCThgFB6+vsE9ZUGLFg4IX1LD 6PVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NFfZ9NrVPY4DNRbADS4q9T3gLqVCLiY8Sf362/w8mB0=; b=fmwVM2gzO4LSnaPkzaLbuM2wehR7sPLfHZVAEUocxiw35TndFBai4qGpnBH91A5o4v pru4y/nGEFIs0O0NCmDPrAohcwj/0gfs3O+GZRjEV99T1FdiN8KHGvNOUw52YgSuqDBG tGg/nZYEa1RiJC5d9VixHcZqMnmZRrHI+KRYGXRmpR8kaL7UYAtIt3130e+3hAm9kbVE yofomRoYN2ULRJXBan+iSHode1+VJ8iv0WArlv4Bx4MReQrQI8VYGgfvcso51W+QkMV+ EdIalxorji1T2XwQj9i2Hc2/ZNeezyA40B4cggaYY20j/wxZfCou5EBBqVXt5x+zv0QN CJEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PUcE084K; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2si15719883pgh.524.2019.06.25.20.44.28; Tue, 25 Jun 2019 20:44:44 -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=@kernel.org header.s=default header.b=PUcE084K; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727368AbfFZDne (ORCPT + 99 others); Tue, 25 Jun 2019 23:43:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:54718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727345AbfFZDna (ORCPT ); Tue, 25 Jun 2019 23:43:30 -0400 Received: from sasha-vm.mshome.net (mobile-107-77-172-74.mobile.att.net [107.77.172.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9B065205ED; Wed, 26 Jun 2019 03:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561520609; bh=WQG4d7wo+oT5gncaeN0iEZzrks+hX0cXQBbrKttkDlE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PUcE084K2KRcE/FFl+hqg91ZWD1kWylsIRx8keUUQWpXH9KGe6Kq0PMWacbzfyM2F kyJEOEY0GR/Wt9U7PbA2GpDLQmmZyl0sDcYSPGg+zVKnB7eEIV0PK6rzkg2gq7LP9q zAdb8G36+jQlFtd0FlqdaMyE116871+vSxTqHaAE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: swkhack , Michal Hocko , Andrew Morton , Linus Torvalds , Sasha Levin , linux-mm@kvack.org Subject: [PATCH AUTOSEL 5.1 48/51] mm/mlock.c: change count_mm_mlocked_page_nr return type Date: Tue, 25 Jun 2019 23:41:04 -0400 Message-Id: <20190626034117.23247-48-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190626034117.23247-1-sashal@kernel.org> References: <20190626034117.23247-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: swkhack [ Upstream commit 0874bb49bb21bf24deda853e8bf61b8325e24bcb ] On a 64-bit machine the value of "vma->vm_end - vma->vm_start" may be negative when using 32 bit ints and the "count >> PAGE_SHIFT"'s result will be wrong. So change the local variable and return value to unsigned long to fix the problem. Link: http://lkml.kernel.org/r/20190513023701.83056-1-swkhack@gmail.com Fixes: 0cf2f6f6dc60 ("mm: mlock: check against vma for actual mlock() size") Signed-off-by: swkhack Acked-by: Michal Hocko Reviewed-by: Andrew Morton Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/mlock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/mlock.c b/mm/mlock.c index 080f3b36415b..d614163f569b 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -636,11 +636,11 @@ static int apply_vma_lock_flags(unsigned long start, size_t len, * is also counted. * Return value: previously mlocked page counts */ -static int count_mm_mlocked_page_nr(struct mm_struct *mm, +static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm, unsigned long start, size_t len) { struct vm_area_struct *vma; - int count = 0; + unsigned long count = 0; if (mm == NULL) mm = current->mm; -- 2.20.1