From patchwork Thu May 3 07:12:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 907871 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40c5vR3cDhz9s3G for ; Thu, 3 May 2018 17:12:51 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 723323E75D7 for ; Thu, 3 May 2018 09:12:47 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id ACAF93E7095 for ; Thu, 3 May 2018 09:12:45 +0200 (CEST) Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 248F11A0100E for ; Thu, 3 May 2018 09:12:43 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE015406C743 for ; Thu, 3 May 2018 07:12:41 +0000 (UTC) Received: from dhcp-12-102.nay.redhat.com (unknown [10.66.12.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 092E4111764E for ; Thu, 3 May 2018 07:12:40 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Thu, 3 May 2018 15:12:38 +0800 Message-Id: <20180503071238.29890-1-liwang@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 03 May 2018 07:12:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 03 May 2018 07:12:41 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'liwang@redhat.com' RCPT:'' X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH] move_pages: fix integer overflow in memfree X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Move_page12 get integer overflow failure on large RAM machine as: move_pages12.c:198: INFO: Free RAM -127127648 kB move_pages12.c:201: BROK: Not enough free RAM My test box: # cat /proc/meminfo |grep -i memfree MemFree: 21348021204 kB Here changing the memfree type from 'int' to 'long' to avoid the problem. Signed-off-by: Li Wang --- testcases/kernel/syscalls/move_pages/move_pages12.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/testcases/kernel/syscalls/move_pages/move_pages12.c b/testcases/kernel/syscalls/move_pages/move_pages12.c index 4c37bfe..5e6245d 100644 --- a/testcases/kernel/syscalls/move_pages/move_pages12.c +++ b/testcases/kernel/syscalls/move_pages/move_pages12.c @@ -180,7 +180,8 @@ static void alloc_free_huge_on_node(unsigned int node, size_t size) static void setup(void) { - int memfree, ret; + int ret; + long memfree; check_config(TEST_NODES); @@ -194,8 +195,8 @@ static void setup(void) pgsz = (int)get_page_size(); SAFE_FILE_LINES_SCANF(PATH_MEMINFO, "Hugepagesize: %d", &hpsz); - SAFE_FILE_LINES_SCANF(PATH_MEMINFO, "MemFree: %d", &memfree); - tst_res(TINFO, "Free RAM %d kB", memfree); + SAFE_FILE_LINES_SCANF(PATH_MEMINFO, "MemFree: %ld", &memfree); + tst_res(TINFO, "Free RAM %ld kB", memfree); if (4 * hpsz > memfree) tst_brk(TBROK, "Not enough free RAM");