From patchwork Tue Feb 27 14:04:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 207236 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2722873dyb; Tue, 27 Feb 2024 06:15:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXoPFC4a6H8trKqthQzepFrF1qaX2k1TUNMITBfZudYu4p4s+Fln1rr0y7xlvpZbjEOekZcX/AAO94Lu2JBNSvnhs/lFw== X-Google-Smtp-Source: AGHT+IGjJFHgW7O/Fn4184R3izxIfKudjzDd2OuNjF9V/IIe8pxHkFzf90hSbdt1NizeKwjMcylW X-Received: by 2002:a17:902:ec85:b0:1dc:7845:537c with SMTP id x5-20020a170902ec8500b001dc7845537cmr11104021plg.1.1709043315428; Tue, 27 Feb 2024 06:15:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709043315; cv=pass; d=google.com; s=arc-20160816; b=vxNPG8OVpsGd4Uob0gDa4ezp1uTrZv+ZYKQOpQwfXL48L/r9tf7nrvDLeiYqAGs6JA eUFK+bMHNdIGUNpQkbvB7WJLhrTCuPjzWUeGChPX1g19gaf6Ce29yk2gtawDAVAD3V8v tzqgOUWjIntbZRd6cJnbf0fniP9qt9VySkpLOD0KX/utFz5VMoCbkeY0HPTqqI6sbDe+ maf1rhdLHTgE1LquvPp6kNC1Yxhrs/sjWF5EhsJQsfDzndPOxPaj6mlK7sj1JesOASTD CkbkdEFTcPVpZos3CsfZU27zDTMY+wuFWjGWznsCzgaA8QUElWe7crw9Fw9vErCx32G0 G/Mg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=0D1BijnrnxtriSO7yJcKAd0RfreEyrQNsga9+rFa89s=; fh=Iw0cdpf9yN87ufu137c7ThcNR/cLOoX+JIMwqQQfbho=; b=j73U1T+7fLvrMTB5m9YY7pgDNOs8gz1Gk9hdwADR8Ks+tz3YMXDQZQQ7q7oFeXyvGm RRPpL2q7Fq0FHhmKLgvH9zH4tjCIIFzQWs0Ios+yibP2IEaGLGCBpUj90t2LS/dZ16KA 7+alqUgL6VE5+OOBVBlsQwt0Y/BSMNq+Fu/5bBRgxd9gxXACpKUedAhHWs2gNcBxcFUy VhhXLsqUIQHRD4tLiaBithP1AOt64LtfRiIfj8QACIE735bv6CRC+nCuWVTUr3SRkwZR 6wxuOiXcCEbbGPa6HBD7OFpFJvuVdPRdNGm0SeIPFCU/ls1QUmMDIc3L616RqJcL24Np 5vZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=c0MEvqrL; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-83369-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83369-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k16-20020a628410000000b006e508074d91si4538307pfd.107.2024.02.27.06.15.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:15:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83369-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=c0MEvqrL; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-83369-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83369-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 78B8D289129 for ; Tue, 27 Feb 2024 14:05:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5BF61143C46; Tue, 27 Feb 2024 14:05:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b="c0MEvqrL" Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69E831420B3; Tue, 27 Feb 2024 14:05:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709042714; cv=none; b=INTEF96AEvgIYobPj4csHHaD7Y5NpGz2XlVsxP7vkz/0E223W4knIwjOBMK51rfmK40fHcef4Msn9KMTZ5n4YnKG5kfoBIk5VmNFkPsaiMxnm99CnZRDb/gtVBxizEteAATYdW4/bJus7U8aAV3uQQxRHHvzH03M8RucD1lU0gA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709042714; c=relaxed/simple; bh=ROXC9XFT8HNDRbWxYhHY2D/L904usz1YVAl5inJlhGk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=iaoNciAwzidJ+1OyoG29xYPPSQN2APuChnYf0xfQnBu1LhdeM9I0rnO0PclprcNyA2i6GA/s5Uc/rsrodwwt0XYyXsOQ7GOBaSE7ylG8jWY7KfPT1zXH+bPQTW84bhm7a0y+t3dENjsueeckXJDmO3iPTpbq/YDttlRDLMSFDUE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b=c0MEvqrL; arc=none smtp.client-ip=212.227.15.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1709042702; x=1709647502; i=w_armin@gmx.de; bh=ROXC9XFT8HNDRbWxYhHY2D/L904usz1YVAl5inJlhGk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=c0MEvqrLpDu70Jk33JtQbIIL3fUa9sTy35IY8UOIk0VLjsJiCFQVGeXN3L+KyjDs jHkdtbcDSPswuytfPIhzI3ZZyar6B7SgdirnUFc2KTJ/LlDegphMZiPo31ExskrfG LnkvVXZiGy9UWKlVHjMuJ9nzcaN9W29uOSmcgaFXQlGgaSES/eg5oi1KeMQnNLDS7 XsueaguuGM59/SXCLgGWbYACaRzL6WFHGtkzgRAu4omW/NCbb/JHoIWWTxwiQbFKp NYV6eDYBZFPXBWhulxRzVCoRj0oyF44lPIyoe/OZQgWYpIeoUMGlmyMTgF4uXZpeb cZjWCctw5NJ8/P1ucw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MbAcs-1r3QOs2Sfw-00beWD; Tue, 27 Feb 2024 15:05:02 +0100 From: Armin Wolf To: Shyam-sundar.S-k@amd.com Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] platform/x86/amd/pmf: Do not use readl() for policy buffer access Date: Tue, 27 Feb 2024 15:04:59 +0100 Message-Id: <20240227140500.98077-1-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:C6aJtexdwYmUh9Ddv7QlNY/6bRDo3vx1aY3rneKfsYaNVPw/Plg JqNWbcFLJ8FcYdUI/IyCq3iNw57NBDmbNi0sSjbbDxopWqLVulKRm8L3fm5LeoMaYGV2Scg pTP8/rQGx/T1IqD0k/yZa7g2Ev0bGLyKOFQwJlELfOuoBqZ7nTgK1Pa09uDs7M1EqtYpO0H c2QlGTsmkAwpAB1ijInnw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:elZWmxoBk8Y=;CxMYko5Aj/lRL5QnnxQnlfAlxNu ViGcnuNGRP5uql0hSD4VvVnx7Q4z44KAFVsx3Eb8KnlH3+EP/O8uU3e2d2AW4Q2V2xSpxzE/E gyp1wZbVuC/OSt+VgQLvPYfXZnx/rsLXoo4zZQR1LKzjHZmVkSj2+jlPEAorHj9onsmOoOo94 YV3hmgl2jI1V+8W539C4yovoHGHWq2XRTd/eyVBOxcygpzMjT8feKmxEBUGO2J44WLXFEmdHT xBILXLLcAgtIZfMsmZfcti6DsJ+hnCs8n+Ix1Eh3glcvdnlNRR+pCnNt+dkwBU2ZLpqYBEMSI Sbb8MrtLZmAX/ydicobnURYz9R2HWfC8bdoiqykPcd/T3tvlq691bNZ87nTRYcjQml85l5BpN YlkhhMjjhyZQDbtQJRXBW1YpqscY0L5y/ckH98iu4jlXveFUxyAXu8wSAEbZL8QrcwWYkVl8d 9dU4s5DCqLO61HhCBRtr9caPDIgH4PDUMCqIuA9fgz2MRAQiv2uuo398ObP535Lxtn6c+TpsI vwgQcnEXLKC9EesbuvdLIIeeKmG8XTXH90xp7mzopIpMWz3afT2blRrYZ4qyKHPAQaJmuxOEm CRG1SgAU1OHBicVDBShf407zrPsXUo1HjNpa4pYhi8GLc7mnPQQK1xOaXLnUMGrPONdNxvcIm HR5WmcMWXoTFfWUC8dUwwj2WuS+v12UjpEByi9MUyjJeCTgAgvJdy32oIPn19Xckyc/wKuwd0 QpCJPj5S2so4cEKRMEPOUEZNPH3x4frWPkQI9fKgf1dJT9GEj9uWhNC9952msROp8w1rda1pC tORionmXDgUl998fi/xgtaVwbapabigUmax82zymLNDro= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792061803502136850 X-GMAIL-MSGID: 1792061803502136850 The policy buffer is allocated using normal memory allocation functions, so readl() should not be used on it. Compile-tested only. Signed-off-by: Armin Wolf --- drivers/platform/x86/amd/pmf/tee-if.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.39.2 diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c index 16973bebf55f..70d09103ab18 100644 --- a/drivers/platform/x86/amd/pmf/tee-if.c +++ b/drivers/platform/x86/amd/pmf/tee-if.c @@ -249,8 +249,8 @@ static int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev) u32 cookie, length; int res; - cookie = readl(dev->policy_buf + POLICY_COOKIE_OFFSET); - length = readl(dev->policy_buf + POLICY_COOKIE_LEN); + cookie = dev->policy_buf[POLICY_COOKIE_OFFSET]; + length = dev->policy_buf[POLICY_COOKIE_LEN]; if (cookie != POLICY_SIGN_COOKIE || !length) return -EINVAL; From patchwork Tue Feb 27 14:05:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 207234 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2715948dyb; Tue, 27 Feb 2024 06:06:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVn4dWkCO9Sx40f9roUDRpmPLDYwSktR7CtExXOZXowWwKi3n3bU6dcbmmctBqmRrpWLJSjF5Ka2CfOwKwCLWsg5l20Kg== X-Google-Smtp-Source: AGHT+IFSSfQ9DTRTueMT5Om5m6n0bYozCe7kiHIMjzm9uFgMw+JsncL24ZGwh5lVXl63Wo0bA1mJ X-Received: by 2002:a05:620a:1465:b0:787:bae4:247b with SMTP id j5-20020a05620a146500b00787bae4247bmr2067116qkl.18.1709042788207; Tue, 27 Feb 2024 06:06:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709042788; cv=pass; d=google.com; s=arc-20160816; b=wi8I0kLfaa9peUulKk+zLMWs3G5acLanM7IUr+haDyOq0j5Khl04nB/M5tEXsrDaOk 6e3wb6hiKp7XhYuVRyNFSB7ZYh3lYdl+5H8earwsqkGG/60PvGft2M5T6E5EbEb4kEO4 /hgeVZfXLil1rDNpYWPyVW7iwMJ/CflR3KcB66VAjXh3KFzCB9wh4d1SI4cWDKyjHFtb C6lhs6qWN25kD6HaQ5zHpgQjR0T/d8O+Qt/HZ1h5V6LfReNkWFB0RUspAlto1zVko3BV moasnTq5MuSReA3h9a4GHIa1dafafyAXsosIR+d9OJ3T5KFS2ewfLmLRWWOPAWsSAY5T 38Cg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=LDgA8BWK2Ps4kihEBRLLFQBCYO/UeH7UbWUVfXlIXas=; fh=Iw0cdpf9yN87ufu137c7ThcNR/cLOoX+JIMwqQQfbho=; b=z9G8+jbE3sIr0FUKH1/tqc0z8DVmg2OZ41LjhF7buGBIvvEm9MW6su4OTgJAeZig9K y58RkKed0mj2Jg7crvAB858pnwryD+Bpfqa7vAsxteAluziB79MVkJANawF7diR8mYBQ GPXSrFg9E3n+2shRnna7GNOkxAE+5RWr7RCu8HvQnaDhly4jrpOH76DHKbTBzwJVtwkv ESYEtsOwrM+ItbtP2KdwE4pB8XBM7SOhs3P9XkUqSl1wj0Mzz1lHTG+85cm8re/eTR/h y3rXiQndfC0RflVhGGmqpZyQONAqsA81abyfBxbBj0Bon+ZhIbeyQHppFHd2zMTEgbX6 9xMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Rts4oMyt; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-83370-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83370-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m10-20020a05620a220a00b00785d6b130dbsi7153047qkh.318.2024.02.27.06.06.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:06:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83370-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Rts4oMyt; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-83370-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83370-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 84E3B1C23240 for ; Tue, 27 Feb 2024 14:06:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 11CC714264A; Tue, 27 Feb 2024 14:05:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b="Rts4oMyt" Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3354213DBB3; Tue, 27 Feb 2024 14:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709042716; cv=none; b=aaW6X4XaZON5UnnD2wto85PnKa1+f1wXyFPChaXBsHGp57X97gAn6kHs4oNl0pR3QynCvyZZ650wUjUKM/REts64TKUjrdlNUVx9WnXp4rEyHuTxs4IdmuDfcwM3Ebp6BVCg/bFixxtrLUmoC3qwqWH98j32X92CJOgmsTKBgqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709042716; c=relaxed/simple; bh=xX2I1MKb6pDRYs2bp7Zf7ZhxShvaggxGHP0EN8JRI64=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H3zLYLY3F1HxX6derOecVxrSGZ/Zrp5OfdvZVBC452ENBCVYReM7C+Gn3rHmDAHgB7MbxFOzWlB4v4uChLbo3rBQ5W48+HT6pWGLJmT64EcbLusDDuChCqLSrdEgO0nRxwgFqXNodrD6vRjYo16PLjjXbcfLBozLcUaxdy2iqDQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b=Rts4oMyt; arc=none smtp.client-ip=212.227.17.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1709042704; x=1709647504; i=w_armin@gmx.de; bh=xX2I1MKb6pDRYs2bp7Zf7ZhxShvaggxGHP0EN8JRI64=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=Rts4oMytgLEJC4i0r9yHabZImMvVlWFY1rY0IqtybjaB3I5hb3RcNDAy+i9N9Ixo dAstM8OPZDXGxikJjZ8KeR5V0Dtsh3ziaKFKJDHZCDwnU6XjEePhCxVCJiRzvqSIM f3oMmuILYYM8TOFwiP3UUa96CVKCjivb0hSX83s0ktvvoFzd2z3MRWwxZDNJD1WXo 2YUGP7jYaOdvfoTbLxNgxl2/22PkAfD3t7p3XMgb8aX8Ch27LU/N4OO6WdjrsmTFH BPVNbqBJVnL/7Vhv6MGNwLB2by65PebVzxtaVDfCAHgLkUhRLlfvYOHg6PLugr+9h +UgU+nKzrGCKH2XYRw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MNbox-1rGzJD2dBb-00P2SH; Tue, 27 Feb 2024 15:05:04 +0100 From: Armin Wolf To: Shyam-sundar.S-k@amd.com Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] platform/x86/amd/pmf: Fix possible out-of-bound memory accesses Date: Tue, 27 Feb 2024 15:05:00 +0100 Message-Id: <20240227140500.98077-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240227140500.98077-1-W_Armin@gmx.de> References: <20240227140500.98077-1-W_Armin@gmx.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:jTFha4DE5UVuluwTxez9gJWlcTStg4nlPLWHYN5H20dNqMcKDtg sgqehJe9I+VoFfMEBHqsOlMuImr4i9GufkMFDRx1Y1tO276Hk/wWVlrOqjt8Sfl9HrlHHvJ RWCmJFAYcIfVKouXWFyxqztHIySuEs//kZq3CWrwit3xXMWAFhZwpnb/iLfhqYj62XtNxxW oJSLh6S6CW/DM6S7GDt5Q== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:9tVv3i1dTRo=;TY1sbJ9+jK9Iu4IsjEmYxohd2C2 Ub/plmOEOZc9Grc8iZBCXWKWwZ11Sd/eE7n4lwiMA4pSGppNvfV2n6UfMMy/CCBC1znh9da5E lb/w/GBoZ7RZmRscVWvDIuO6lOpVfxP0rUDXJx5sbfch6ncR0EgkF1mWKECpStA+KK2CK3JUL aVuyyffvQ1EdXKdNHD8izBy63HBqEtodh9bLFIJgZuBtztbni9ajpylwqmbX/rN2TGujA0uFJ 6JFkrb4c7BAoWwlY5j8NtdjpBkRtNMvVa/yKlr9sD2vo9vOVq/Ze+46NSKpPf6dcyu/0yPNNe kUp2Y+RXvlJ2qQazTpTezA5uDQgLBeOGudWq82S4chesRwJGfn631g41GvI/1IWFyo6vco3S+ gcDlHTPT3HCvpRoDdmssCb2Hgo9D+yVXDeT0RsnLEh2F5yoeSm+aMEc4G3AeaMCOyy5PJBqes +WuCfvEWQoVDPwbRleJJ1IQsWUmVWuYSiwXD1Xag5flfT1MSZU9FBqRXybQDjrtJUoZRf5LWy wtzKG97ZLFRkH9Zu60rhTPqFC2IaPIC8jSKU7Xh6OqG3wfyiee23Tp/863HYiwKkFMHaiIo7X yVTMsdnDyx83DsuLvrHcZ7QrkY4qb7IEuQ3mnmBlyYdyCwqfCikGCoxDgKuO6lJsDJGG2sHwj 5L9T7GPUCMeIfiWsO1FbX9EscV6uGvAFfvGOXO0Mc3JGWadiOafUG0uf+YJC5Q4kmkxhPsqaN /OzHdHXQ6q12CGXE9ca4YLjHq/sX7gAB+YF8Tl7m6jMM8KFl4pWnkUjihAZ7xbctG0IY2Pzfa NK+Qzh/RN8Hfp0wvwxmdrMDkUFRQoSndXKvqJM9c4Lgo0= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792061250519823599 X-GMAIL-MSGID: 1792061250519823599 The length of the policy buffer is not validated before accessing it, which means that multiple out-of-bounds memory accesses can occur. This is especially bad since userspace can load policy binaries over debugfs. Compile-tested only. Signed-off-by: Armin Wolf --- drivers/platform/x86/amd/pmf/tee-if.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.39.2 diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c index 70d09103ab18..f2f9204b3a11 100644 --- a/drivers/platform/x86/amd/pmf/tee-if.c +++ b/drivers/platform/x86/amd/pmf/tee-if.c @@ -249,12 +249,18 @@ static int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev) u32 cookie, length; int res; + if (dev->policy_sz < POLICY_COOKIE_LEN) + return -EINVAL; + cookie = dev->policy_buf[POLICY_COOKIE_OFFSET]; length = dev->policy_buf[POLICY_COOKIE_LEN]; if (cookie != POLICY_SIGN_COOKIE || !length) return -EINVAL; + if (dev->policy_sz < length + 512) + return -EINVAL; + /* Update the actual length */ dev->policy_sz = length + 512; res = amd_pmf_invoke_cmd_init(dev);