Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10792093imu; Thu, 6 Dec 2018 06:54:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/WfV1sXBiq9F1UxEbtxRl7Knu0MskplAbDc50mprkzSe8BKZ1Vc9KVWTUZUe1FTqF84+tmW X-Received: by 2002:a62:7504:: with SMTP id q4mr28301849pfc.180.1544108069274; Thu, 06 Dec 2018 06:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544108069; cv=none; d=google.com; s=arc-20160816; b=EJLXKfOcNJrQ8IrOIVCpOHylDa53Yon0xKkLu3hT8HOoFW4mcvGcSB2+EyLupBregA 59YRQ0/tZXysCRBAqt4438PGehZDTJAV6xMcgRIXIw9bD2cdPq9VtzbeVGc3JYLJXFsG QPRfziDmEXsUYJ+skIRFXmWja/3B6AWSJuEoXtZytAjowhEhlEgoQ5olmD2vV80gR7MZ VgKePRk9dgjQrEHXhKj7ajy4nIyUe2KCjlzZYDASRHbCYENjXOE2WIgNtP6MSZ+NBWgo M/jmMSwzYeQZuV3dOqk+3kWO+vtgc+B9Clp4bjOO1i5yJOD6wV71JzboB+x8+lSMpA7c Lwsw== 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=Xs7HDl+fPyDp+HZPG10drhc+7WtZG2eMEbeW2FPo3gE=; b=iWWFogO6Bkyp0nWAWxZd6qGTc+oqeiBd7kAph+AhNydSA0GtZDfSBVcm/wB90XXPDh gb/WfuCUjiRHUK+NqXnvBYDROlNU8YD+do6bOo2UoD3neR4ZSdF8UkK8SIuQvOGieofl NdJ/MbKnXTZ0SdF1BEe8plMlYIH5IJKy/ciHGAEmWyeuCWkVtX4WycWq9h991PMKEpPu Yy1D/jPZP14Ps2bCxt1BWVRunu2YuBUofIa1lm5h9JNMrVRkRwgYfgHpjnrzv3/SDAxo IzTYhW92Vg4Gkc7LsylchWCVyxG8/vwEUWaXqVIA+zi7fYptlKRKi3lC4oidDhb0aa3L dKCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M3UImsNt; 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 y5si358014pgs.588.2018.12.06.06.54.13; Thu, 06 Dec 2018 06:54:29 -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=M3UImsNt; 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 S1726044AbeLFOv6 (ORCPT + 99 others); Thu, 6 Dec 2018 09:51:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:51218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731250AbeLFOq2 (ORCPT ); Thu, 6 Dec 2018 09:46:28 -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 E716421479; Thu, 6 Dec 2018 14:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544107587; bh=O7TC8EftALK3d30GHslNvFmseALI6fgmVU09LMfsDhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M3UImsNtQLPltgHJzZMvraUK8So5uU6GpYg2Mk2gxEoKFx/xv7EBfhCXcYtJIlCWk NmeAyr4oBEA9NWtuxGIlUj5o0GOkMmoLwRGdcxKnOUE/7kDkc+3qFJrqDFQxQsHUql Z1viE/3kq6W4zInUa5g+D/icbs9ANmhx2JXLdgwo= 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.9 062/101] mm/hugetlb.c: dont call region_abort if region_chg fails Date: Thu, 6 Dec 2018 15:39:01 +0100 Message-Id: <20181206143015.213389051@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206143011.174892052@linuxfoundation.org> References: <20181206143011.174892052@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.9-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 @@ -4259,7 +4259,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;