Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1027004yba; Thu, 4 Apr 2019 02:44:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1DM8LH4Dnmlk6kGD8maum1Va12kdkMCi5HZHr5wRxSxLHjJS4hQ2VjDmJ/e3Y/f5if9s7 X-Received: by 2002:a63:c23:: with SMTP id b35mr4786592pgl.298.1554371091300; Thu, 04 Apr 2019 02:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554371091; cv=none; d=google.com; s=arc-20160816; b=xmYM4gTro0CARAHeZDbo10iHHLwGTv3jl2AeHwvjX2tGS1LEIrhju2Agh838oe4Ia8 HnFWM/9rEtriU4HBv2NQrlZdTvzynu7W9VrImnGHjRRBjw3JFBELqqHi3P8F9BXT69Mn kn32VOSJacuWU6BgDipQFn3JO+12Zv6Ganh+qqEgWA6sP24pAFpNgB+j3qFyvylw6Sib XvR9fxDxKZ2M40b2c1fLpw9mbUttpgL5SwaBOVS/4yyGVIS3rzWdXHTwSUR1Rg47stUz vSFsHlAj4tOtUGH26Rv0OBuM2U1MrOln8jfl0hbUYh+PH4ikjn4UVpMjdothknz28x07 kvJg== 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=/pTAKY6I6YI5vdESt6Gql3azSWsQ7PvcNNjrzttYI44=; b=wcnSKxlkm9bnZLFO+/9Y8UlmxcRk6KuO1i8TehdC3DXt2ntYDSfQTEoNET7PFArVS2 xde9Pa+6VUMOGae6EcNgBoSGANsO2NvROrwoh7bWdybZ1TtVhwlDUnCNoiMs9Xo7nigp 44G2QN4qMnsK+CS5MgT+UQTDtzbaCRx6sJFeSAsNoAJr9hUjNrDFC/S27H9kohDU5s1F zRC3xFKu84aKveAlMItqUR+EtA0dh6On+eI1RI//1QBlK/taBJhHme7r26uX1egis+dk HWJL7JqcrA1YV3RjirP45tLTzCefOMbZjiWvh8AC184oxXrpCo89OiSpzP52HHeCQUuL 1v0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Iy5lQk87; 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 h8si527534pgg.573.2019.04.04.02.44.36; Thu, 04 Apr 2019 02:44:51 -0700 (PDT) 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=Iy5lQk87; 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 S1731198AbfDDJoE (ORCPT + 99 others); Thu, 4 Apr 2019 05:44:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:36848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728762AbfDDJAN (ORCPT ); Thu, 4 Apr 2019 05:00:13 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 5C5112147C; Thu, 4 Apr 2019 09:00:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368412; bh=iCC2c2TnpMmrHOv7WxKjcmPeorV1/9+mSTjlYmYwPIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Iy5lQk87Okk+NZBfakyXlYBBVDNKSC7xfua8vLnLixDUnJGusSKxIc9f1+s9zjDrj 6SLWOdnV00qVN2aDZdY+xqBPDYuxn/M18HKvw+Jxz9UekAS8ObKVrhEwS02h/vfaMs xygHaa0k15fxQgN78KZDF51+KJ200t7GdTkzpTvg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Uladzislau Rezki (Sony)" , Andrew Morton , Ingo Molnar , Joel Fernandes , Matthew Wilcox , Michal Hocko , Oleksiy Avramchenko , Steven Rostedt , Tejun Heo , Thomas Garnier , Thomas Gleixner , Linus Torvalds , Sasha Levin Subject: [PATCH 4.19 030/187] mm/vmalloc.c: fix kernel BUG at mm/vmalloc.c:512! Date: Thu, 4 Apr 2019 10:46:07 +0200 Message-Id: <20190404084604.490478147@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@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.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit afd07389d3f4933c7f7817a92fb5e053d59a3182 ] One of the vmalloc stress test case triggers the kernel BUG(): [60.562151] ------------[ cut here ]------------ [60.562154] kernel BUG at mm/vmalloc.c:512! [60.562206] invalid opcode: 0000 [#1] PREEMPT SMP PTI [60.562247] CPU: 0 PID: 430 Comm: vmalloc_test/0 Not tainted 4.20.0+ #161 [60.562293] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 [60.562351] RIP: 0010:alloc_vmap_area+0x36f/0x390 it can happen due to big align request resulting in overflowing of calculated address, i.e. it becomes 0 after ALIGN()'s fixup. Fix it by checking if calculated address is within vstart/vend range. Link: http://lkml.kernel.org/r/20190124115648.9433-2-urezki@gmail.com Signed-off-by: Uladzislau Rezki (Sony) Reviewed-by: Andrew Morton Cc: Ingo Molnar Cc: Joel Fernandes Cc: Matthew Wilcox Cc: Michal Hocko Cc: Oleksiy Avramchenko Cc: Steven Rostedt Cc: Tejun Heo Cc: Thomas Garnier Cc: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/vmalloc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 91a789a46b12..a46ec261a44e 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -498,7 +498,11 @@ nocache: } found: - if (addr + size > vend) + /* + * Check also calculated address against the vstart, + * because it can be 0 because of big align request. + */ + if (addr + size > vend || addr < vstart) goto overflow; va->va_start = addr; -- 2.19.1