Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2003718imu; Fri, 14 Dec 2018 04:21:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/WWY6vPxgEl0kpsS3mwzzlbq2XFA1zJSfqjeJJ1bCmGCvWyZKw3K0hDWUkQGHB/VnxQQjH3 X-Received: by 2002:a17:902:8f83:: with SMTP id z3mr2606288plo.328.1544790070327; Fri, 14 Dec 2018 04:21:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544790070; cv=none; d=google.com; s=arc-20160816; b=KeqHR0te0R1BJaod+j82Eh/4ibdm28pVqv4vW3NpzjlX2HWqMZmNy5oiSrkiVtg2Co lXH7a/PHqjiPGGOqjY0TcnUsTJ/NHCcE26QSy1hoBUlMsXDYJ9tBKGZQQ2WT8U+qDsja mH/Q34rbj74yqOZ7d7BSx6fCKFVk/Ht2gAyzAd/VoSyH+Ytii5gr1lbiaMTolBD5Ocrw Pr8VxsGvRqnGS3Jldkt2D8eiyynXEsGBJPu9AbZu1/17B3BtzS1vXqQlYL90HWhu6K6H lwobYJdZnOPJoTypH8PGTIWaGRCG+1PQdj6qFZimR+1oHhbQjIi8XJwnnfqOSVZkwIRr SVjQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sEM7VQRoQcK9X5YIuSA20cVQPsYXJj00PMWp/twiF3M=; b=yiDQyubVNDesoYITIH039vVYXjrET7uku2uUfKsd94ANwsLBTCC6GgM29pC3e4F2EA QgCDMvMKRO9WAupGVHYoRDPBeJ+ErVaphMzHYJJb16flFpr+VtiVBXJhBXtjDCbB5/A+ t0ZcFueoRVmEMO639o4WlfyDYnUSNi64zBa9HVI/beNFIofaaDB5dzT8kWEDACQDuIOX Ck18vfWTZx9pEoCnF8tDAwO+YSQZNvr9VJ5RnUIxZjNxPa5gaONCDyc3UkZJO9t3mOk/ fYFIdeUaGa6BWdWBucXEg7OTYRGxpeR6dSoGL6sxQUJQS46rkfK3uC0Ro8R4OJanNBf6 Uadg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a+GdqC15; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h31si4054033pgl.482.2018.12.14.04.20.55; Fri, 14 Dec 2018 04:21:10 -0800 (PST) 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=a+GdqC15; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732736AbeLNMTC (ORCPT + 99 others); Fri, 14 Dec 2018 07:19:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:36176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732675AbeLNMQE (ORCPT ); Fri, 14 Dec 2018 07:16:04 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D6E3C2148E; Fri, 14 Dec 2018 12:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789763; bh=Vdf+RUGqfdB55Yba842auQRtheODbv0aK35uQQOS8UE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a+GdqC15rwBMlXRj2Dt4mi4CpGCVfVFDy7/OkfHIGVnI2tyJfvhsmrq3qAfFI/LKe mOIQy1PU79XoFhy/eerqWBQ+qbOKaRxq8EgjJUa+Bcojnay4E6Bpp2Xmj7+eJX/vP7 +dYcs4mJIt0H87PR2EKMKjWkvdoKioniIaGqne5I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Kravetz , Dmitry Vyukov , Hillf Danton , Andrew Morton , Linus Torvalds , Ben Hutchings Subject: [PATCH 4.4 68/88] mm/hugetlb.c: dont call region_abort if region_chg fails Date: Fri, 14 Dec 2018 13:00:42 +0100 Message-Id: <20181214115707.890165060@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115702.151309521@linuxfoundation.org> References: <20181214115702.151309521@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mike Kravetz commit ff8c0c53c47530ffea82c22a0a6df6332b56c957 upstream. Changes to hugetlbfs reservation maps is a two step process. The first step is a call to region_chg to determine what needs to be changed, and prepare that change. This should be followed by a call to call to region_add to commit the change, or region_abort to abort the change. The error path in hugetlb_reserve_pages called region_abort after a failed call to region_chg. As a result, the adds_in_progress counter in the reservation map is off by 1. This is caught by a VM_BUG_ON in resv_map_release when the reservation map is freed. syzkaller fuzzer (when using an injected kmalloc failure) found this bug, that resulted in the following: kernel BUG at mm/hugetlb.c:742! Call Trace: hugetlbfs_evict_inode+0x7b/0xa0 fs/hugetlbfs/inode.c:493 evict+0x481/0x920 fs/inode.c:553 iput_final fs/inode.c:1515 [inline] iput+0x62b/0xa20 fs/inode.c:1542 hugetlb_file_setup+0x593/0x9f0 fs/hugetlbfs/inode.c:1306 newseg+0x422/0xd30 ipc/shm.c:575 ipcget_new ipc/util.c:285 [inline] ipcget+0x21e/0x580 ipc/util.c:639 SYSC_shmget ipc/shm.c:673 [inline] SyS_shmget+0x158/0x230 ipc/shm.c:657 entry_SYSCALL_64_fastpath+0x1f/0xc2 RIP: resv_map_release+0x265/0x330 mm/hugetlb.c:742 Link: http://lkml.kernel.org/r/1490821682-23228-1-git-send-email-mike.kravetz@oracle.com Signed-off-by: Mike Kravetz Reported-by: Dmitry Vyukov Acked-by: Hillf Danton Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- mm/hugetlb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4142,7 +4142,9 @@ int hugetlb_reserve_pages(struct inode * return 0; out_err: if (!vma || vma->vm_flags & VM_MAYSHARE) - region_abort(resv_map, from, to); + /* Don't call region_abort if region_chg failed */ + if (chg >= 0) + region_abort(resv_map, from, to); if (vma && is_vma_resv_set(vma, HPAGE_RESV_OWNER)) kref_put(&resv_map->refs, resv_map_release); return ret;