From patchwork Wed May 22 21:36:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13671106 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (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 2A3CF442F; Wed, 22 May 2024 21:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716413822; cv=none; b=r+avmcUC2LRNNy8ynPOpZ3fE90tl0JbFSgz47qTp8xaGliXb3oj0PRYCX32XyCLT5mndos0DMhu0RQqUh8Ff2AK5tJ/YR0m1hBCuEBcxABtiBouD4I5/sodwkWJS6zxGLXJRNRD+0nZ5m1svST2/2ROt2WDC0OCCwAt2OY26hag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716413822; c=relaxed/simple; bh=B/bfstJr1D26BrJSu7bzyn6j6rpSF3AtWWAFZXs804s=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=svcJbbxPfVetnvWh30+YEwCJ9+kS9TdOZOylN7vD7PL7GAY+arT4c/ceJsAX/+ODUhUX0WW1VKjzjxLmLXwMmRX3PBH+/muRG10hWQBJ0wY+iZFAyKmeoKSW1Sd7Zqb5N+hlWBGlNl+u3m7sFWT76lYLRb0v5CpsYKZDkGJcDrQ= 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=ZZxz4Z4p; arc=none smtp.client-ip=212.227.15.15 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b="ZZxz4Z4p" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1716413813; x=1717018613; i=w_armin@gmx.de; bh=+qZGyBSKRKms8oRgIzNvT2oPRilnHMhSmLVziRMEnJU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id: MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=ZZxz4Z4pg4KxnLE8ppQ/OIz6BSzuygEYzI9uumNwQrXnwT+Jmaqc8IFKU+n16Bqg X3v/qofJz/LJnKLxjHkHstr4qxVMcZi3SXR8M4nbfZdScRPLwAGR7DXaOyRW4+6SK MCEcpf3P/bxlzLBurWCTd/UTC9dJ3pbBE5ciT6uE2bXeruYfyo8qjZKkjZ5rGvKTw NTpDGtH9pM0ZtETY/49GX8a3IL/4LP7uc/1moJavbTZR2MePir2YdSAAwgcOlAiFW aF5qzrzFdjC1UQwZV1VYA3G9c/2f+X7WAGFWN+XcZwl963FygYQX2iblRNdsyRBts UBZWXXMi4Emj8ofHNA== 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 1N8GMk-1sekJp1wCe-017TPq; Wed, 22 May 2024 23:36:53 +0200 From: Armin Wolf To: rafael@kernel.org, lenb@kernel.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] ACPI: EC: Abort address space access upon error Date: Wed, 22 May 2024 23:36:48 +0200 Message-Id: <20240522213649.2860-1-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:Pf05s5OeKaqGiFxz2tzwR0caLoFhrL14Eg3phLjV/WWUDLIVGjg Qm+6AE6XZ57Bn/O/Yxfz0Q0ErXwI+rOKOLlGaUTeA/B7XtQRB6388FX4wjKgfdmbW/AAkUr hyoakBt9/gpJqvb/WcS+dKKeK6RL/su0B3fxJhA/6sccKuj9eBNprXanxMMXp7YABpE3L8m +QcG6g4vw4NivWafVydrA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:wGvHOcVoVow=;xXrCdUGZuv91I14nLlAQifWtP+w ZuEdifo5kzPJCMoCiS4eoG1spfsbiUewYx1BHG0ueqwBhgQwaKifBWn7ehpfAz7yglB7IgooY vsb0kaQlfioOaOa7ZHtk4Hj0ZE2jVNoTLZEKqOdx8H9GBWwlRC4IBSdncGt1sqytIdUId9UPT Fk4S09TIN1dFSAh+K0HK1e7PVNbvUBf91uRrKi/jQhzr72kdwRUbiCYphAFDSICTfg1uL+bRR D+7PkF4hTyiqsrBeB9YMZTkRBZDVNMXVZVni70OsU83FGwdx3A4F3iJstppWX7OypD2EbfOqP Zpv2j2rMM7fmcphmkiQVUX7HhEVhx2YrzPk6YNP1DLIPkVUxdaLPDX3fXtHLl+bWAyEQG9OWI qDOlUcLgUB4ssl1pI9bHmkF/Um+zuThOER+oIWnSewXeXTKfnVT9opRPtxV1fHAYACuEvY9Xv +ysiFLnCyYUf3bh3QNqvT+5A7UTAQZyJct35P22ZmDZ1Y4Icyq63vOll9gfMjx+aAE9ZSyZp1 w/b3j0TnZSMk+C/P7+casGZJuUHw8ZIJ7xFk9oFgqN+Ah4aOBuTjSSjghab1T4wI45SpYePuh sNBtvksyPGCtOPiWSWgCuCvDOhbyc2XTr1q1bdxV5EaUq9Bl8EuNJbxc1kTC76RnM6FdFqXva MvpAj+Vskn5NXJMmevUFQrPWqZ6IiQVADcQSArwYyhRApV9P7PjI9Cotzkua7EbZDON9l1DMu iEaOf1xy4/J7Qn5OOwyi3sGiELukY+7h2NOGvca1WWQpZy0XMUfNkQvPKzAYUWXvJxVyIi97v 6EUmCMH5C+LOKPPXXZYP/atnCjHwpzEdSr+ovD/BbTbZg= Then a multi-byte address space access is requested, acpi_ec_read()/ acpi_ec_write() is being called multiple times. Abort such operations if a single call to acpi_ec_read()/ acpi_ec_write() fails, as the data read from/written to the EC might be incomplete. Signed-off-by: Armin Wolf --- drivers/acpi/ec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.39.2 diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index e7793ee9e649..a68dce2147a4 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -1333,10 +1333,13 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address, if (ec->busy_polling || bits > 8) acpi_ec_burst_enable(ec); - for (i = 0; i < bytes; ++i, ++address, ++value) + for (i = 0; i < bytes; ++i, ++address, ++value) { result = (function == ACPI_READ) ? acpi_ec_read(ec, address, value) : acpi_ec_write(ec, address, *value); + if (result < 0) + break; + } if (ec->busy_polling || bits > 8) acpi_ec_burst_disable(ec); From patchwork Wed May 22 21:36:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13671107 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (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 C1FFD7FBCF; Wed, 22 May 2024 21:37:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716413823; cv=none; b=jDD3j+zre+cWQJlFPWPe4FQoFSoVmCWbuYaMB0cw8PZh99j1L61FV3Bic2huuGnEG3t8cXiiZwqpfopJxQ13VmlwJhv42msBexAIC1ux5n7/zvsyNTaboDfHz2Due8q+/NSLVliNsg0sd2clc2vH1XPAcHrAuHxpFt7hMb1tUXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716413823; c=relaxed/simple; bh=+aI/IRjah/lsTblI2//u7vmxvM6d/MYv/JtHH8kkYvU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ouN9okYpFx+4F6IKUa3PXNtkTHfdcw2kr2Jc4VFnL4HWxqMkGPGCQhc77tzWHCDknLJ5wB8XpncKwbSMUtNq8+H0faRXGIBCB7IpmIcyVAHO0Mf/Nq3cxSPtrChQPKa/7wT4zk4is5CcoJv5vKkF817tzHFEDycT8V9drn/iDpw= 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=cstvXarK; arc=none smtp.client-ip=212.227.17.22 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b="cstvXarK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1716413815; x=1717018615; i=w_armin@gmx.de; bh=2D8nAm4MctRuFF1pGWD5+lc7xhTXQPBA8z6v1wGk//c=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=cstvXarKTVlJPquh8eOTr/XZCVDVA97gOjpAmwi6EJgDakeIVSfuvKnHvLNx98oW 8OO3FPYYv2ihkLyvG4Jt2e86x1kGc6zuHPuMzZ2lTHh6r8TxJt2XPK8Te/nMXl0rn nWPD3RFxbz6ecrO6atwCrLrNpDaVG/Q+b4+3o6mQ+vIJbXlSz5pjYLqURAToDvbm6 EWUo6/njgl2s9tdy/1kWpHWabMUtCVAKZ2Y/yev6E07mdKgF4NGCNiPKWRJiNsPtw mnjfYUZ5IKVvE7wKYroXiikRjC2DQ+M8vdX4Uq5T2w1r5cEv+QQRx1iWwNtoEMTjO uAWodBGLJK71jck/1A== 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 1M4axq-1s8FDF2XAc-0034QO; Wed, 22 May 2024 23:36:55 +0200 From: Armin Wolf To: rafael@kernel.org, lenb@kernel.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] ACPI: EC: Avoid returning AE_OK upon unknown error Date: Wed, 22 May 2024 23:36:49 +0200 Message-Id: <20240522213649.2860-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240522213649.2860-1-W_Armin@gmx.de> References: <20240522213649.2860-1-W_Armin@gmx.de> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:oS/SFcZwqPRcZmsAO7DxxSBH3yt6wc74l/TbPeiaibL7fPURIn/ ACDwX0Wvug8VXeNOxHuSBh1rEEdW7ZnPjjSwck4NBn+mROV47gjN/XDbjLhVFQfhjZ1rU34 AxAbG3qw3krjUa2rgtFIJVSy6FE88XU3J1kcKj/nBOtGnpiEwBn+OLw9TaxVFQKoRhxRiDo fz5f+6jPh6to1+LLYWx0w== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:uoA38NJva0I=;uO5++yFAdl61e8qKV386s3mNyA5 gNpU0FHkt+//OyPa6y+x9ONAPQCYduKSHwbc0LJtB9QslJZj96e7OzI4u839YMkgIEfwHvINu UQfqPNHpkxthwDvhrDW+QfPrU5f7FA6hU3rCERHTnTO2qj7DMcFk+tIOYcViUjDj+rdKVG0+6 qv3+KkDtte7XNU8CUsrc0nMQejf6NOdIZ9j22BaWKF+s5byuTtR9hzdcMjtRg4tBBpRli4TjB w+YE8Hvkaxch+IwHmJUi5swRFXNo6FdtqLITjCr0rruZtw4IMtJ2aILnUGAUpv12nnHnjh+V/ HBAONo0xTQnryXeBXNEku9+X/IGzGk2T69OfhhtPDAhs/w6PLTK135OgHG9ARQhTPE70+1op6 MazIhprkZ15TUJ5ymix0EbWhRESL70l/2sziuDV3E1tH68SFjsJOc4dJvx8YNQtrMmP4qYdHZ qsPvCIz5xOiM8C3qgbn1uJpQtHjKnFleM29/ylLdsBFthNBsX0AWL7aPfo4RQ4ZY+t3Mdfu+E oLhmdaJFpehOW5hdRRrF/Q4tQkzUM0g9hJNSLVAgb/2r1vuKPh106eihBNt6r4PuanrHuD4S4 EX+Ee4cttQFtc4i7OkYtKCJAbH/SUUbIIWEXefQhQNwe78e3VfBmBEXzWm/BBTO916SbSuBZz J2M+ZyOyLDx2txkn+r/5KSOy9azA+tyjiaZc1/EfTsSq1AIEOWNzBOgobYixGC0CsPIOS/QjK W067iA2O2gc+0kuBfwZxTlfOu6ktVpbXwUGxpgCwXjRs+cTM+AUvXD7nFqM/M7UWY5CBcXkTx vI7Gw6lh5cZmDtXhP2NpceYutCArLchIDIgYpeimL5Zck= If an error code other than EINVAL, ENODEV or ETIME is returned by acpi_ec_read()/acpi_ec_write(), then AE_OK is wrongly returned. Fix this by only returning AE_OK if the return code is 0, and return AE_ERROR otherwise. Signed-off-by: Armin Wolf --- drivers/acpi/ec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.39.2 diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index a68dce2147a4..68dd17f96f63 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -1351,8 +1351,10 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address, return AE_NOT_FOUND; case -ETIME: return AE_TIME; - default: + case 0: return AE_OK; + default: + return AE_ERROR; } }