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 X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70EE5C38A2A for ; Thu, 9 Apr 2020 13:05:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A5C4216FD for ; Thu, 9 Apr 2020 13:05:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586437525; bh=ENj9gyIpSdOm3HFxFqSOAiP74yf1INHrcxCTQAxSIvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=pYR0y+Y8IIWh4Sx88ik1OVGxV2Y9s7lhDBnuy4uCtqujg7OMm2k5DFA2kOI8btmid 8DaSes1I0MeKKTKR5uXy1KvZksPf/LH/e7c7sRwaKA9LIWylwe6HJd4wLWyt8wF1Gq rnuSliCqnBl6awQKRmOENd33QltdG7MKZcjCIYFM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726942AbgDINFX (ORCPT ); Thu, 9 Apr 2020 09:05:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:44130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbgDINFR (ORCPT ); Thu, 9 Apr 2020 09:05:17 -0400 Received: from e123331-lin.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr [109.210.65.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 199E820B1F; Thu, 9 Apr 2020 13:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586437517; bh=ENj9gyIpSdOm3HFxFqSOAiP74yf1INHrcxCTQAxSIvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MlGEIh4lVXQBNPeZ75l1plhLEDzJDaoZ5zHV3xV2OeL6DNR6/k2Tv3BLq+fdpHpzT UINzVsyZ19zzkfjlvxJ8PXf76PJ+yXReKS/Y+apLTWLt1iYAbWzgtcyOJb0TCOJJ41 5TJJEmsoMEDRyqEaJ3j2Iya7I0rSV1UbKEBgu7So= From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Arnd Bergmann , Arvind Sankar , Borislav Petkov , Colin Ian King , Gary Lin , Jiri Slaby , Sergey Shatunov , Takashi Iwai Subject: [PATCH 8/9] efi/x86: Fix the deletion of variables in mixed mode Date: Thu, 9 Apr 2020 15:04:33 +0200 Message-Id: <20200409130434.6736-9-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200409130434.6736-1-ardb@kernel.org> References: <20200409130434.6736-1-ardb@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gary Lin efi_thunk_set_variable() treated the NULL "data" pointer as an invalid parameter, and this broke the deletion of variables in mixed mode. This commit fixes the check of data so that the userspace program can delete a variable in mixed mode. Fixes: 8319e9d5ad98ffcc ("efi/x86: Handle by-ref arguments covering multiple pages in mixed mode") Cc: linux-efi@vger.kernel.org Cc: Ard Biesheuvel Cc: Ingo Molnar Cc: Thomas Gleixner Signed-off-by: Gary Lin Link: https://lore.kernel.org/r/20200408081606.1504-1-glin@suse.com Signed-off-by: Ard Biesheuvel --- arch/x86/platform/efi/efi_64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index 211bb9358b73..e0e2e8136cf5 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -638,7 +638,7 @@ efi_thunk_set_variable(efi_char16_t *name, efi_guid_t *vendor, phys_vendor = virt_to_phys_or_null(vnd); phys_data = virt_to_phys_or_null_size(data, data_size); - if (!phys_name || !phys_data) + if (!phys_name || (data && !phys_data)) status = EFI_INVALID_PARAMETER; else status = efi_thunk(set_variable, phys_name, phys_vendor, @@ -669,7 +669,7 @@ efi_thunk_set_variable_nonblocking(efi_char16_t *name, efi_guid_t *vendor, phys_vendor = virt_to_phys_or_null(vnd); phys_data = virt_to_phys_or_null_size(data, data_size); - if (!phys_name || !phys_data) + if (!phys_name || (data && !phys_data)) status = EFI_INVALID_PARAMETER; else status = efi_thunk(set_variable, phys_name, phys_vendor, -- 2.17.1