Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9241959pxu; Mon, 28 Dec 2020 10:12:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzilW4mE2HDytE8RmtGXR+RhzqWOOD6ujx+O+sdrx8u6V//+kyNhCfdpucH76yJXIydJS2V X-Received: by 2002:a17:906:d10f:: with SMTP id b15mr42120320ejz.268.1609179165752; Mon, 28 Dec 2020 10:12:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609179165; cv=none; d=google.com; s=arc-20160816; b=F9orvwuYF6uEE0SW4I6u5W9PJ1Qtp3OQCqNaUt427WXJyO2PjcGPyHnAX9Gw+FkmTb CpKa69JcsNkyc2h2IGlh6W6WYQ9Ovhs9VmGr6hJKbIg16fmWRhZ8tv0WBRvmnAJozGsI TbH4MtqcaoutzsYVPsSUzyyrbZuPSqjluECIasBqAuOeoihfjCVXwVd1xtOJhgtpHu/7 hsCEZs6xiefzJj1sg68CcOs+IrdTKPEkfzwdHR5oWsPGELWDzmrLYJpOpqPY6oD4iyBA CTsc61FQ/RrAohWbOF6Mg7R5rcRs7vj0o7Oywsx9qhUyMqB99gXPR2la6q2tZo/nc9Tz lKjw== 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=WEaP+8rgiCR02GvtfhJv4o2Y2Mn03y+tdGhz1cDlbzs=; b=mmFbfVxtmWqXfgj5o2AasGUL0E+ceGU7X8Lg7972asmdyoSdEvXKJPdZAI7+Q66Em6 v753sMhs3rsGxmSDcIHKoLO3bt+bi4yoyEGvKQB2UmURv2dBbNdCmixbGn1fl4GbrkXi vNXyM8n0zrELbCCtaXueilV6fHhgh1oyjQRarCKnwLZpaY6NveMVkM1zvY+VZL+V/dCT n3e/c4xV+DHDhBU7OjDEIfWFJ7V0r0KRf5aRdh/Sy5OENqxYMGMyI4ljChwgMMyLLZo7 y3L2Y6NEFH3CliAiXpc34YjhxU9zTlOO3K3udbcaTfKsCSdtH0xIAw+aw1Z4zsYcdml9 bn1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=w2KrN+YC; 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 15si20503789ejg.14.2020.12.28.10.12.23; Mon, 28 Dec 2020 10:12:45 -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=w2KrN+YC; 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 S2388883AbgL1NZS (ORCPT + 99 others); Mon, 28 Dec 2020 08:25:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:53766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388835AbgL1NZD (ORCPT ); Mon, 28 Dec 2020 08:25:03 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 96F3F22A84; Mon, 28 Dec 2020 13:24:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161862; bh=16ofqNDOtTdD+Nbw3rTnBhytlvP13deUuWsiMlij8zo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w2KrN+YC1QCi+M1+KmayJaiaKFL95Rb1aMpx5Q3zt+jc1cnJ/UX5C6/nFzPF6gM1b sbGePG5YNJm9pOBjDCuOJ0iIatoUjL1ewNmMyqab8LIc8tsThOwUnsCRZ34z3LaTLk wGzmuUNnzvAAOMBSecEG81GfFbjdhAlTgR/XfvCY= 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.19 107/346] x86/mm/ident_map: Check for errors from ident_pud_init() Date: Mon, 28 Dec 2020 13:47:06 +0100 Message-Id: <20201228124924.958176082@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124919.745526410@linuxfoundation.org> References: <20201228124919.745526410@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 fe7a12599d8eb..968d7005f4a72 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