From patchwork Thu Jul 22 05:48:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 12393113 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 9D1D6C6377D for ; Thu, 22 Jul 2021 05:49:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 31C2260232 for ; Thu, 22 Jul 2021 05:49:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31C2260232 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B5A0B6B006C; Thu, 22 Jul 2021 01:49:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE2886B005D; Thu, 22 Jul 2021 01:49:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9AA956B006C; Thu, 22 Jul 2021 01:49:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0185.hostedemail.com [216.40.44.185]) by kanga.kvack.org (Postfix) with ESMTP id 7FC206B0036 for ; Thu, 22 Jul 2021 01:49:00 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2AD7220424 for ; Thu, 22 Jul 2021 05:49:00 +0000 (UTC) X-FDA: 78389145240.15.4F2B437 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf15.hostedemail.com (Postfix) with ESMTP id CA62FD008332 for ; Thu, 22 Jul 2021 05:48:59 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id y3so3239812plp.4 for ; Wed, 21 Jul 2021 22:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MKNRjsgk6Q8Cz/z0+I/JgI7Vh/QJ95/oO70XlxKCdNI=; b=EXrXNjHeSZAbgTUvugLwo6VhkTI3G5WNxFbXoZVs46+4X5P9+lXwd+Tg+Yxjgw6JM0 jR4LeMe86lJShvoDxFT/XSCLmYO7oT9SkvFg0TqsZ2mVfGFxDaEFPf8M1+m1cyP/mIH9 gHWnIio96Pq2oDvbiFZtLVzDqVzK7qg/fS7DcDXAF/evKPLBc8qwddtnwLWaQq601MPK jc7SQURlQD88Q03z/MBn2syijIjtLgnY/ypVHe9H5bmaqu6wZTxAPuXN2pOZxER/i6eD B8nHan7uPxjE++1B58+IOXIuWDiQhMRefz7ir5N7dCDmmbTgbmesdpC558A8mDlpX46w Salw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MKNRjsgk6Q8Cz/z0+I/JgI7Vh/QJ95/oO70XlxKCdNI=; b=rB7/7Hxz5EJb6fr0DJFAbqqQyre8e/+4ZVzKhekf68v9LxdW8Jh4JAVarjGC+3opha YSmKqLrrbMk23HE7LbhQaf6Ztaz6Al6lh8er4MN5JMbP4UQesU/ERXvximg1V27zu+JT F3FnTY6kC2v2z17WHNQVDMYPPa4Ht3DXfj1JLDsKqhDuCiujcrh0RWJgh1W++/PZ3MKI L+XPrgryIjPztfv6Be4Y7JeWF6rzmFrVv7aY7hkA2KafNO3Td7EEdFxzcYWCoXXJwy6G 9RU1teSyh6217eEMJGlJEtv3luDh04m6EDu67h3i+ZovrVSnX07ffE34gmmIgkONrTWg TAzw== X-Gm-Message-State: AOAM530h/BCI3+qA60D+H2PuDZGFsV8s+svDCUBo6oYr0HpUF+D1oON4 I6eR/ypWUhCAWxaBE2FFDqo= X-Google-Smtp-Source: ABdhPJynacIyEjM8Yl/r6ysvvKK/6/vUTX86SKobzTyyhhTTJEYzfjH0b+Z82glIOkpARufqoKWYYQ== X-Received: by 2002:a65:6243:: with SMTP id q3mr39791545pgv.297.1626932938773; Wed, 21 Jul 2021 22:48:58 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (27-33-83-114.tpgi.com.au. [27.33.83.114]) by smtp.gmail.com with ESMTPSA id a23sm28164153pff.43.2021.07.21.22.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jul 2021 22:48:58 -0700 (PDT) From: Nicholas Piggin To: Andrew Morton Cc: Nicholas Piggin , Mel Gorman , Yang Shi , linux-mm@kvack.org, Alexey Kardashevskiy Subject: [PATCH] mm/migrate: fix page state accounting type conversion underflow Date: Thu, 22 Jul 2021 15:48:40 +1000 Message-Id: <20210722054840.501423-1-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=EXrXNjHe; spf=pass (imf15.hostedemail.com: domain of npiggin@gmail.com designates 209.85.214.175 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: CA62FD008332 X-Stat-Signature: 3nu76miph7j6bp1kzw6yqpgpfgixoxsh X-HE-Tag: 1626932939-689155 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: Similarly to commit 2da9f6305f306 ("mm/vmscan: fix NR_ISOLATED_FILE corruption on 64-bit"), fix -ve int -> unsigned int -> long bug. Reported-by: Alexey Kardashevskiy Fixes: c5fc5c3ae0c84 ("mm: migrate: account THP NUMA migration counters correctly") Signed-off-by: Nicholas Piggin --- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index 34a9ad3e0a4f..7e240437e7d9 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2068,7 +2068,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, LIST_HEAD(migratepages); new_page_t *new; bool compound; - unsigned int nr_pages = thp_nr_pages(page); + int nr_pages = thp_nr_pages(page); /* * PTE mapped THP or HugeTLB page can't reach here so the page could