From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19456C433F5 for ; Tue, 4 Oct 2022 22:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229790AbiJDWVf (ORCPT ); Tue, 4 Oct 2022 18:21:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbiJDWVe (ORCPT ); Tue, 4 Oct 2022 18:21:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 565036566D; Tue, 4 Oct 2022 15:21:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id ECF40B81A73; Tue, 4 Oct 2022 22:21:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 431A7C433C1; Tue, 4 Oct 2022 22:21:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664922090; bh=nknUvIAw3621/tczw7v+m61cTYHmFty9sDG6DzZ78d8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uWMt3y03P/j1JOOlgSis3tO6Gzh1RhdevMCIG60B6K7Vwu4iLNZThVC+ao5FsNxbS 5vHD1DjrjvbAMQGy1wmcx3REvn46VdNp05uxBZ/d/aiqaR2ynW3hkH3Byxa0NMttr2 rbSdHhhILgPXoW73VctZvKABjYpAkZPKAkXNVH0FDeznV7pmIddifzS+Tm3WMOq02H JT3Nlr1u+1goAbHcbQaTzSETaBrbjUswHFIsJyMkp+HS02uB6LtUQzvZtV/SVFXFFB OMon4MZ1DMR45CBBP0t4JNsqg5AwYA2+VuYJ0ft0hUHEczRy8HndPtRJyY8ojQ2P7O hEJ610/ciBU1A== Date: Wed, 5 Oct 2022 01:21:27 +0300 From: Jarkko Sakkinen To: Kai Huang , dave.hansen@linux.intel.com Cc: linux-sgx@vger.kernel.org, tony.luck@intel.com, linux-kernel@vger.kernel.org, reinette.chatre@intel.com Subject: Re: [RESEND PATCH 3/3] x86/sgx: Add xa_store_range() return value check in sgx_setup_epc_section() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org On Tue, Oct 04, 2022 at 11:04:29AM +1300, Kai Huang wrote: > In sgx_setup_epc_section(), xa_store_range() is called to store EPC > pages' owner section to an Xarray using physical addresses of those EPC > pages as index. Currently, the return value of xa_store_range() is not > checked, but actually it can fail (i.e. due to -ENOMEM). > > Not checking the return value of xa_store_range() would result in the > EPC section being used by SGX driver (and KVM SGX guests), but part or > all of its EPC pages not being handled by the memory failure handling of > EPC page. Such inconsistency should be avoided, even at the cost that > this section won't be used by the kernel. > > Add the missing check of the return value of xa_store_range(), and when > it fails, clean up and fail to initialize the EPC section. > > Fixes: 40e0e7843e23 ("x86/sgx: Add infrastructure to identify SGX EPC pages") > Signed-off-by: Kai Huang Reviewed-by: Jarkko Sakkinen This needs: Cc: stable@vger.kernel.org # v5.17+ Dave, can you pick this independently of rest of the patch set (unless ofc you have change suggestions)? BR, Jarkko