Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9042436pxu; Mon, 28 Dec 2020 05:13:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9gPj3JW8VYI+5WyAG0/4KeoJ51cuHOg9iuWrngKuu1j1sjoc5dGOwpwO8zRG7XQJEzHws X-Received: by 2002:a17:907:9614:: with SMTP id gb20mr29930766ejc.406.1609161210204; Mon, 28 Dec 2020 05:13:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161210; cv=none; d=google.com; s=arc-20160816; b=kN02cYSDeecqVtVzU8oNl8EiXnIkKXAIA9XsaEdwsxhaXbw0kVs7advUdgEopzMcCF rjYL6rlVMSM/na2/GBZbTkC/6WkFY9N2xVGG0CaScnEf5W/clqDnwvO7m/We1DOzA4v8 1i7UgMw7qEZVdjIOHxAL5QTsv/dwfJS45jLy2Ky6ID/bKXfxI+MIMoi+l5MTjf9mLqfJ vj8wlHD3EWIN2BHGEgU/DM7EWuh+QIy653ButvupUVroTXayHP2LEx3yhBwcyeyyn30U AdjJU0WL8RYb7lYUu0bd889z+nxXehdCiRwLlkogn7aRgBAs4vuFHQgtIeup7JxDtG59 SB4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HOR9N8nFhjy8nkZ9vCTUsRJEVzlc9ZdMjnyqHYusJI4=; b=K73rjsMwBrmhRiilJxde03jwkvhxZBzMhkO0grDkErMqHS2Trt+newlOzmh+Qq173L VDPe3K348/Fnqrx0Ayn+CL85Ue07p7y1829O3webIGjB4wd5JR6wS4IV62ORDKUNsyD8 yDBZSCisSdaiMS7HeYgTjmdp54pN+mMSuWxZ9Pd3EkYABiBZrWxL11oHPhuaXslpQTYe 2AYRS0A6Pjvn+hxKsWD/2225+EeVxuLZrXg3/5yeon0f9Zu+I70qBQZIfpRTrBYjLZ0/ Easxpdbt8QePju6dHnSFQusETGTbliuEpQM8qYjKo6HLq1tixmrv+FbZcwnsGRYlrA2V wDlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Kg6TNZDN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w2si25848682edi.59.2020.12.28.05.13.07; Mon, 28 Dec 2020 05:13:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Kg6TNZDN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729542AbgL1NLc (ORCPT + 99 others); Mon, 28 Dec 2020 08:11:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:38780 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729306AbgL1NK7 (ORCPT ); Mon, 28 Dec 2020 08:10:59 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2026E20776; Mon, 28 Dec 2020 13:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161018; bh=86qds71fKIrh4v443M8klqe1trdf8jo/UXyg5vOeq6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kg6TNZDNQFyGLR/OP92xKCmAfrc8kj2vN8GshIXzSPBXbOyRYhmbPoDUwGd5lY4bt mDIAru0353BBZHEL76/mtluvjF/PPnZdthZF+3q3PuV5Ez0hJ2YhPx4+N/oYbfcSQo EFKWpFd1BBAwafj7sKm1DZhiyRq4neARq+Zd3Hc8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arvind Sankar , Borislav Petkov , Joerg Roedel , "Kirill A. Shutemov" , Sasha Levin Subject: [PATCH 4.14 071/242] x86/mm/ident_map: Check for errors from ident_pud_init() Date: Mon, 28 Dec 2020 13:47:56 +0100 Message-Id: <20201228124908.178659795@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arvind Sankar [ Upstream commit 1fcd009102ee02e217f2e7635ab65517d785da8e ] Commit ea3b5e60ce80 ("x86/mm/ident_map: Add 5-level paging support") added ident_p4d_init() to support 5-level paging, but this function doesn't check and return errors from ident_pud_init(). For example, the decompressor stub uses this code to create an identity mapping. If it runs out of pages while trying to allocate a PMD pagetable, the error will be currently ignored. Fix this to propagate errors. [ bp: Space out statements for better readability. ] Fixes: ea3b5e60ce80 ("x86/mm/ident_map: Add 5-level paging support") Signed-off-by: Arvind Sankar Signed-off-by: Borislav Petkov Reviewed-by: Joerg Roedel Acked-by: Kirill A. Shutemov Link: https://lkml.kernel.org/r/20201027230648.1885111-1-nivedita@alum.mit.edu Signed-off-by: Sasha Levin --- arch/x86/mm/ident_map.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/ident_map.c b/arch/x86/mm/ident_map.c index ab33a32df2a8e..407fa1df470e0 100644 --- a/arch/x86/mm/ident_map.c +++ b/arch/x86/mm/ident_map.c @@ -62,6 +62,7 @@ static int ident_p4d_init(struct x86_mapping_info *info, p4d_t *p4d_page, unsigned long addr, unsigned long end) { unsigned long next; + int result; for (; addr < end; addr = next) { p4d_t *p4d = p4d_page + p4d_index(addr); @@ -73,13 +74,20 @@ static int ident_p4d_init(struct x86_mapping_info *info, p4d_t *p4d_page, if (p4d_present(*p4d)) { pud = pud_offset(p4d, 0); - ident_pud_init(info, pud, addr, next); + result = ident_pud_init(info, pud, addr, next); + if (result) + return result; + continue; } pud = (pud_t *)info->alloc_pgt_page(info->context); if (!pud) return -ENOMEM; - ident_pud_init(info, pud, addr, next); + + result = ident_pud_init(info, pud, addr, next); + if (result) + return result; + set_p4d(p4d, __p4d(__pa(pud) | info->kernpg_flag)); } -- 2.27.0