Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2495080rwb; Sat, 8 Oct 2022 08:45:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5bZGPGBrExr/DFHe57Tb725xm3ir//MwL//OcpkUXnsl70Q9yOYIolU/hNfqY5c1IOuvC1 X-Received: by 2002:a05:6402:2b85:b0:457:6216:d251 with SMTP id fj5-20020a0564022b8500b004576216d251mr9646526edb.56.1665243944166; Sat, 08 Oct 2022 08:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665243944; cv=none; d=google.com; s=arc-20160816; b=aP4KTxiOoPfHSNoYApxFxyRUZ9tN42SSzpbmSLSMJ31KDFd/eGejB1gojPyuftIyHq MK+Ith5FEI0VyA+uwA1gF8CXdlqUq4impI5NmRdS9Y7tFrr0twMQAJhxwxWly/j6TwpM GugEZyoCF9LpChw5gbOCGees6Wx+5kW9wpOK6TrCsRESfP1hmfs/4NmPJSxPQ8VfkZt0 4uVFdhdJzl4GE1bERVhJgypUQc88s/zTvbdnqB4DqWK+y8nI7ru2K1it0+luSHh3Ane2 3NHGRLcZydAxR2HO+F+j1gjznpFGdT2gWgQRsq1zqyu7DqyPSOyGBwtje5WuGr5o3eIN 54Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DYgRImUlP5sBAB0m+Fi/O5fIFHatVYNoMS9h40YOHco=; b=K0sfqd8hxZE1Rgi62miUvd6sR+lh80l4mMUkNK1zhD0DpClBhfosYMTfwJIev6G6xr qHgtQI/gnlGYPcZ9QSwxvJgBLlkexuDTBdOkV79HNvYeW5/vWrGfzxjpthN96iq/4wTF QZ3sy0QHWNgA4dUYh93ZRAV046M8F7TU3J023imN/HR+Smu1vtev3lEJbNTR76WfWLU+ IeC8VLgEchAunqBkAqygSgFmXOyxWMlCoIP4RUSm3VAjEPIHDWBlEETE7MlzR5sWoDhl M2EsppO4mUsn09G8gGtC1qfkvF6FKciJ/r6Inbbr1w6/cRYGC6lT/Klq15WzLZEaLa8I dDnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="NkOfR/aW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r14-20020a17090638ce00b0078badb3816dsi5115549ejd.952.2022.10.08.08.45.19; Sat, 08 Oct 2022 08:45:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="NkOfR/aW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229729AbiJHPMm (ORCPT + 99 others); Sat, 8 Oct 2022 11:12:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbiJHPMk (ORCPT ); Sat, 8 Oct 2022 11:12:40 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 175D12C12B for ; Sat, 8 Oct 2022 08:12:36 -0700 (PDT) Received: from nazgul.tnic (unknown [46.183.103.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 4DFE01EC05B0; Sat, 8 Oct 2022 17:12:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1665241950; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=DYgRImUlP5sBAB0m+Fi/O5fIFHatVYNoMS9h40YOHco=; b=NkOfR/aWMdEV1z9XGZ2/WEYAky35KX2YfStKR//x78sVUpXeyC+sGuu3T9Zh09vBWI1C/X A9AOyivIJDLtZgMOzooIcg120y6SnGXYZoWlzlWjzrevFMtmpWkjC/S7u2OSXlig/PKlIe DfUmPNUpd3yffSBvtxuHwT3ZtoOVU2E= Date: Sat, 8 Oct 2022 17:12:35 +0200 From: Borislav Petkov To: Ross Philipson Cc: linux-kernel@vger.kernel.org, x86@kernel.org, dpsmith@apertussolutions.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, luto@amacapital.net, dave.hansen@linux.intel.com, kanth.ghatraju@oracle.com, trenchboot-devel@googlegroups.com, Jan Kiszka , jailhouse-dev@googlegroups.com, xen-devel@lists.xenproject.org Subject: Re: [PATCH 1/2] x86: Check return values from early_memremap calls Message-ID: References: <1650035401-22855-1-git-send-email-ross.philipson@oracle.com> <1650035401-22855-2-git-send-email-ross.philipson@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1650035401-22855-2-git-send-email-ross.philipson@oracle.com> X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding Xen and Jailhouse people and MLs to Cc. Folks, thread starts here: https://lore.kernel.org/r/1650035401-22855-1-git-send-email-ross.philipson@oracle.com On Fri, Apr 15, 2022 at 11:10:00AM -0400, Ross Philipson wrote: > There are a number of places where early_memremap is called > but the return pointer is not checked for NULL. The call > can result in a NULL being returned so the checks must > be added. > > Signed-off-by: Ross Philipson > --- > arch/x86/kernel/devicetree.c | 10 ++++++++++ > arch/x86/kernel/e820.c | 5 +++++ > arch/x86/kernel/jailhouse.c | 6 ++++++ > arch/x86/kernel/mpparse.c | 23 +++++++++++++++++++++++ > arch/x86/kernel/setup.c | 5 +++++ > arch/x86/xen/enlighten_hvm.c | 2 ++ > arch/x86/xen/mmu_pv.c | 8 ++++++++ > arch/x86/xen/setup.c | 2 ++ > 8 files changed, 61 insertions(+) Ok, a couple of notes: 1. the pr_*(":" ... ) thing is done using pr_fmt() - grep the tree for examples. 2. I think you should not panic() the machine but issue a the warning/error and let the machine die a painful death anyway. But Xen folks will know better what would be the optimal thing to do. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette