From patchwork Thu May 27 23:12:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 12285599 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 0A567C4707F for ; Thu, 27 May 2021 23:12:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 96BA8613BF for ; Thu, 27 May 2021 23:12:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96BA8613BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 95CCF6B006C; Thu, 27 May 2021 19:12:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FFD06B006E; Thu, 27 May 2021 19:12:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2252C6B0070; Thu, 27 May 2021 19:12:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id D5B456B006C for ; Thu, 27 May 2021 19:12:41 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 83E26BA06 for ; Thu, 27 May 2021 23:12:41 +0000 (UTC) X-FDA: 78188562522.10.E676949 Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by imf14.hostedemail.com (Postfix) with ESMTP id 356F1C00775B for ; Thu, 27 May 2021 23:12:32 +0000 (UTC) Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14RN97xR146826; Thu, 27 May 2021 23:12:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=FvvKFMkQjy+UvjtT+9o8xiGw1n1aHX7MgLG8GjJnFWM=; b=D1Mk234kgPfcGMJxBY+kMTvMZpkM2SJrh70OTN1YJIxeLkuZgRIoqNNmcDg4tOfHLqkt q4gEJPcp0xQ1kfIj+NZ6tDlRLiUEe9NPOve9ry1A0BzmHmJto9tq3FJlYGEoy5QudCaF MdeH6aV9fhLXGdx5GEMRI6EKz33sN0Kr+fJVs6Q1PdRiSpo9ybeELDIVmw48DqKZ3J+9 skR1vGYyTxq/Qw98EQpn7CQcIHEDEHeKZGczS7LONTLfn2KAdUpPGEMnVdCUqLJBPJA2 29Bx6MdjwTDnsoqRw1E0z1ZVACvHp/LCoHeGrOCHZDyGujG/tcwJGLee3HCI4Q9i7VW1 lw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 38pqfcnkwg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 May 2021 23:12:38 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14RNBZ3k050942; Thu, 27 May 2021 23:12:38 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by userp3030.oracle.com with ESMTP id 38pq2wvsr9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 May 2021 23:12:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UDEyYvkSucS6s9N6o77kstYc1sAQRwF6UEGaKoX1zCaUJDKx2RuvUUTjqck8l4zfqZHYl1WfvuDtVYDBT2n741vTcVy9j5VIdWvt/0q1FpDhkLxnXHl4vo/BgTW2NmxmIzLRaRRbOx2wlB1gTMVYwuC3VWERrxocS27nxOPbMH1+tfyWp3P/MeeaIQPDHLCKW6Moog/OC1kJVTqd2vp+TyrgjCsx0sXjlCjqGuRr36DMqO7cP/7t0mspPajyYtVXyrqUtBmOt1qeEQ29/H/ztPYEcC8EFe3eReq0XOomFbXhUiCH24YRntqgfMmOvYDEmJAeH+w+3zI4Of7GITcIyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FvvKFMkQjy+UvjtT+9o8xiGw1n1aHX7MgLG8GjJnFWM=; b=fbOn1RFPneSACoJAuqH+P72+1/LfUA8dtfLOGC7aahTA4dzz0OvgtOBQEYWXUFRyY6rmnm2B5Hshuee0rzPl1q2tQYcf3zh485bbszO5pcCBZJiCRD+Dq0eJWfNKNyP7BLv+PgN5JhSxezVGgmfdAWkJKIy1ZNF40RlWLvUwWoENt/PcbMh/aJckc5GYFGCBICeKqUq1fDbvZEiomvIvADKxXfg17r7IntcOsdgN5DfteU/Xhqh8KlirM77/kFciHYnUXRlaq+G3Z8y68DOhQ3qeBCfTXG+ToEdUCwv7BxOeGTuUHOR+cXvoaWc4BzLoi4pCnwa3pq9hAdgZN2hHMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FvvKFMkQjy+UvjtT+9o8xiGw1n1aHX7MgLG8GjJnFWM=; b=qo8hwuNrgJfYkFwDLvYeqqqIcfESgMVbFYZCdmQnSu/h4PJqUZ5P0589fVxKOLzvVZGblZziTevvESh/c+Lpw45CeuAtGj6a3M+LbfjcT7Vw7xF5IPl+zl0ypwPe7TU5A/ViO6BiEgvYtYkvkE2N65M0a1eNHM7FgmCFvjkSVNc= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (52.135.55.87) by BYAPR10MB3000.namprd10.prod.outlook.com (20.177.228.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.27; Thu, 27 May 2021 23:12:36 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::4407:2ff6:c0a:5d90]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::4407:2ff6:c0a:5d90%8]) with mapi id 15.20.4173.021; Thu, 27 May 2021 23:12:36 +0000 From: Mike Kravetz To: Linux-MM , lkml Cc: Muchun Song , Michal Hocko , Oscar Salvador , David Hildenbrand , Naoya Horiguchi , Andrew Morton , Mike Kravetz Subject: [PATCH] mm: hugetlb: fix dissolve_free_huge_page use of tail/head page Date: Thu, 27 May 2021 16:12:25 -0700 Message-Id: <20210527231225.226987-1-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.31.1 X-Originating-IP: [50.38.35.18] X-ClientProxiedBy: MW4P220CA0002.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::7) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from monkey.oracle.com (50.38.35.18) by MW4P220CA0002.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Thu, 27 May 2021 23:12:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 33a64d04-ab32-42c9-cc35-08d92164ea1b X-MS-TrafficTypeDiagnostic: BYAPR10MB3000: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mE/0MzvQiymFDL5QmmIR1X5cLncItaoBXXOHgOQnNvnoP34yxIgSKoNxrvdGCg0O991JYgvjsmj7JFCdCewJGgI7k//4cIRTonCc6RUyhieA1RJ9JNH+9kldlHBeQVLaLOo+laXvIrNvTJ5B3yi5xgdi1c2JVbkAqwg8jF9gDO9pYtznDH+MvENWzWKY7nThNy+O9o7L+7oMlK+Mc058YKo9DFlIS0RmM9RzG3nay4E1zGkviYDvIDx8BY8IqOcSSn6n0/Rkfurs9HzlNx+NydzkkLrm2XoOkqxpiReIVS6gKlv5WDHPK07d+rcTpmDoCEw75fmvIbCp805zmNQf0dPAB7QJ3tAkVM6eBxZTCAhxWMITP4O+VTFweSwYZrS8pjNQJhItotCzLxV0pmmtv37J0p0QAxZUJMpBrn9adk/0Fn5H0ewdLfrOtsI9HMBYo0nhbCFku+W1y4ALJM95VgCtx458fibze8DbFaBXuSkRs4WYUiv1o0ry3TWc0ehebyvugKc26HDzqT4mwVW8YYcOLwXEL3IQtXhHVSjuaBJxw59l29IJSO6cVRxZrfPQFxh34LIXaoV2YAP8+M9c7O6fws/zABMwAwYyi8BbUwq+olVX0ZkZHb4pQEILNvEPJn/Xmx3KsM8oyHHKcSxP965aa5XGbnvICiTrBW7UARuTZOMi6uGZbsL44kE0pUeQ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4196.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(136003)(396003)(376002)(39860400002)(346002)(8936002)(66476007)(66556008)(6486002)(83380400001)(7696005)(44832011)(316002)(86362001)(66946007)(16526019)(186003)(1076003)(6666004)(8676002)(52116002)(5660300002)(107886003)(26005)(2906002)(956004)(2616005)(36756003)(4326008)(110136005)(38100700002)(38350700002)(54906003)(478600001)(14583001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: nC/MLbcA6GqP9YMxi2pvKvl127wYvbyo19qAQQ1vzjAlg84CDSrQ1P60pNnkiozgZKMgqqgSOKVyvEkL+T9rD5jbKQCIdIB06IxiYinBJpmLrNBXYD2DRlCRhsN7LTXBdSBjPKdRu8cXD50a9B0REvTQPt+DrkvHDgDKA546pq1VXsnbqGAvmvyacNRvgzQoiKb/KBUkZni8QTx0ttNlujN9kamrYKiRqmgMllL1L4/A8CMqhBLGAxkWV2mQpBM5a/MxzqLNwoEVD08g6Fc5KMzKVXqh6zqtDbuo3s5pbg1QG87S+pa8LJ22j06FzsPTNeLyLM9HUC5bttAyA6PECyQCIxLS/m5F+DFj3YxF46tvLHKSZKDwZWvofW9lkBYs/f6x7VtCw1cM1cUe+DsrDI4+8b7oFbdmsrU9czcd4Vu91hct7YhEO5NMXkeLt4011/qbHa4t9wyCzWTFt41qhOdwA52FQQFTCWYpaVmqBuUi7Ca7wz0X0laBvojrE3iT3o+idGtERAvSBx3haqqFKpUlH9alIKlZqK4JaVBgoWkD9rWkNWRuH1f4TTf4n+khazvQbEu+B+djduQnEGdckQr8BiHtwmlEogWedVHUs9DU8c0veuajeGAk7fLE1oN+BD7CyMP2r7Pf/sSa+ktC/ZDJl+Fr6UCbNnMd5H7OXxr0FP2WQw69Rk9jcODZTZrd7or6VlTMnixBLqy4WnYGXBkh9z2mnyMKkqIzznZJ7rljde3naUQ2PM6PSdxxA9tSVhxQPYcPi6hHbuArctGQNrK4qrA/Zn5hzOqfoKzuyVFNuOzuQ1t/dP8PVjVZfUgBEhPoCmXBYn0UZEuD1ttmNxEq3b1PCBwCsavVzZ1MUIb+dhpt9P9rkU1nWP+KGTzKtjf8qpWZA0W4JuU7Sm5GgHgz3Cd0ayOHEwGhlAF7TiBDvEmgULLz3pQk3skoZCjVMUnrgs3stFfh3gzRYlwSjj+LXDJMNwisWLONXPq08CjXB1jbcXMMPIlmKNvmDXtpBABQBeEAxdttRTBeuRoJFibVd/YQyhntblXrC1jENKhzCzCL3xTeBHHebIBuBg/toSYzqOmD+cSooNt1L26/7tU05ogmew2GDNj2ydM7PxBec7c61F6JmOACeOBnZiceJRO7SC7hyCgCxvKHjRhC8lLu1aL3wT4ZWmNZzKhyOu3CFyFO20cmvqrdOHMkLZG7UqHcOkObAm4f9mcjo+GzRTcmMHidCM58aHl9z2TJu9wLlZbpbjElaAL+gL+gWRdXCyYDCL6hAgRqN5nhSQ1BVgVurrx2l8hOGIWGMoXoJWdpH6KjlN7P7OPWdq/yjjAZ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33a64d04-ab32-42c9-cc35-08d92164ea1b X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2021 23:12:35.9265 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Z3xUPL/8lXu/e4asK/R2zBOmjsjPd1q1j7M+BDe3PfrJQKeGNCvWg4X3evrRgVsC1/J4o9IrWskF+SX+5SmZJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3000 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9997 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105270150 X-Proofpoint-ORIG-GUID: pZjKPc8MGpTCxDJm3R3iUCojW2VFdS_o X-Proofpoint-GUID: pZjKPc8MGpTCxDJm3R3iUCojW2VFdS_o X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9997 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105270150 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b=D1Mk234k; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qo8hwuNr; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf14.hostedemail.com: domain of mike.kravetz@oracle.com has no SPF policy when checking 141.146.126.79) smtp.mailfrom=mike.kravetz@oracle.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 356F1C00775B X-Stat-Signature: uxt4oerh71hzj9x8ya4zmmwo5pxqsgad X-HE-Tag: 1622157152-141308 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: The routine dissolve_free_huge_page can be passed the tail page of a hugetlb page. The tail page is incorrectly passed on to the routines alloc_huge_page_vmemmap and add_hugetlb_page which expect a hugetlb head page. Operating on a tail page instead of head page could result in addressing exceptions or vmemmap corruption. Signed-off-by: Mike Kravetz Reported-by: kernel test robot Reviewed-by: Muchun Song Reviewed-by: Oscar Salvador Acked-by: Michal Hocko --- The code with this issue is only in mmotm (and next). Specifically mm: hugetlb: alloc the vmemmap pages associated with each HugeTLB page Andrew, I assume you will fix in your tree. mm/hugetlb.c | 4 ++-- scripts/rust-version.sh | 0 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 scripts/rust-version.sh diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 69a4b551c157..d2461c1f32dd 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1954,7 +1954,7 @@ int dissolve_free_huge_page(struct page *page) * Attempt to allocate vmemmmap here so that we can take * appropriate action on failure. */ - rc = alloc_huge_page_vmemmap(h, page); + rc = alloc_huge_page_vmemmap(h, head); if (!rc) { /* * Move PageHWPoison flag from head page to the raw @@ -1968,7 +1968,7 @@ int dissolve_free_huge_page(struct page *page) update_and_free_page(h, head, false); } else { spin_lock_irq(&hugetlb_lock); - add_hugetlb_page(h, page, false); + add_hugetlb_page(h, head, false); h->max_huge_pages++; spin_unlock_irq(&hugetlb_lock); } diff --git a/scripts/rust-version.sh b/scripts/rust-version.sh old mode 100644 new mode 100755