Message ID | 20231002134630.2601294-1-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1453558vqb; Mon, 2 Oct 2023 07:09:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFFqCIvjGExmVhz+z3MZ9IK95AKJqp6SoJsSsJaG9L6bIb9QqxUDe2ugrnaYMyL43wPvtpY X-Received: by 2002:a05:6870:14c6:b0:1bb:83e9:6277 with SMTP id l6-20020a05687014c600b001bb83e96277mr4460054oab.33.1696255797650; Mon, 02 Oct 2023 07:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696255797; cv=none; d=google.com; s=arc-20160816; b=u8P7RudizoR3V3GhcVehxJhMIMMnpQHNwb0K2CRWM09+wvAT25a0acLDA99NjHubFj XdngsICwCMLzK3/4U0fVKgLG4YsFIHAQDs0OnSv1R+Ef15IyzHf4yIWmGjmp0GSAzCnR Wkf5QPAr9He7lNdC4sqEcvOdtXSx5wZg+ip1giV3TMbcRODtTDXVnYJTk41YJDt+0FWU KKmAGcWEuHDemu1DZQUzrEzDVKOOu6WUsEqmHrPPHzzhwwsGR2XL4eIv6TS39w3cAECa SxSJ4E2446I8bSQBvLDDi0R9hyFqhl+IcdhwpCOoDLmNjvEclJPHg6u695rO/RwCmcOe /wlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2aEnPrBZjbI84KT7ApHJevHqftWZr525jPCf+nlduk0=; fh=mc5eN6NpPXlNdmS+rCx3NDxVhwjvWkKk2n0WXJda3Xs=; b=ghL/GyFFzbkLgEtsvxz5tJXvUeXLstvAMNaEpEEc4+K/Yo+DsYLpcNcaVaj29tElfd f7MONBTRr3PDqjVHRN+B9xfiNxeQOK1RdMa7mUq/tImr5yvy2dqlT6ThAdu+G0TExvmz KrEWSykEgKMI8ONP4OxwcIOSzc/wisDdZjfYSqGjoovEoVOLFakSQW2GigLkWzajeyae YRmaFpTaGPJ6r46L+vQa40cfIC//1Jtjntag8ETmyREJCqHsojhaI/eMntWtfeliF5W2 P5a1JhOvf83f9gyAhH+6xlfKsU56YjcXR7tbhNr8/6EyzHHabd4d0JVW2cnVjT0otIoM RxFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XFj33Xhl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id a17-20020a637051000000b00563de199314si8448490pgn.896.2023.10.02.07.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 07:09:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XFj33Xhl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id EDF5E80811C2; Mon, 2 Oct 2023 06:47:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237484AbjJBNqj (ORCPT <rfc822;pusanteemu@gmail.com> + 18 others); Mon, 2 Oct 2023 09:46:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237460AbjJBNqi (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 2 Oct 2023 09:46:38 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1786DB0; Mon, 2 Oct 2023 06:46:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696254395; x=1727790395; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=AwCB0JAqzDDtRO3CENNhM7InAKHdngeC3934G7S/Ok0=; b=XFj33XhlDvoY2MNL2MT37zWTqqrAJ49CwpC+5A3SZGNqP9FwMz/chY3A WkabLVuK81xfVDgrqR7lFJ/gTva31d4vRy12pWLMLBI6pBtOpYdh1tza3 IF7mRCYkYqNg+fbJ9dU3Bnl5mdp2E9f0f/rzfEOf8SG5puCuCAo/bphIV DiNlzRHibxAxlFfpkJb+yXFt07QnShctrUMxWWJED53NaMq6Aym6ZbLSV o8T78a28QtWFEeW4+UzHhic4QoeXKnXL19V6E3isf98Kak/B/BTQGb0ls Din0SWfeLOkKd37tBgbfTFMx8apSa8ES92WxO716ck6miFACT3zkYTooD g==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="468919050" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="468919050" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 06:46:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="894138443" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="894138443" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Oct 2023 06:45:12 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B84ED1A7; Mon, 2 Oct 2023 16:46:31 +0300 (EEST) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" <rafael@kernel.org>, Len Brown <lenb@kernel.org> Subject: [PATCH v1 1/2] ACPI: property: Allow _DSD buffer data only for byte accessors Date: Mon, 2 Oct 2023 16:46:29 +0300 Message-Id: <20231002134630.2601294-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 02 Oct 2023 06:47:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778653118956957010 X-GMAIL-MSGID: 1778653118956957010 |
Series |
[v1,1/2] ACPI: property: Allow _DSD buffer data only for byte accessors
|
|
Commit Message
Andy Shevchenko
Oct. 2, 2023, 1:46 p.m. UTC
In accordance with ACPI specificication and _DSD data buffer
representation the data there is an array of bytes. Hence,
accessing it with something longer will create a sparse data
which is against of how device property APIs work in general
and also not defined in the ACPI specification (see [1]).
Fix the code to emit an error if non-byte accessor is used to
retrieve _DSD buffer data.
Fixes: 369af6bf2c28 ("ACPI: property: Read buffer properties as integers")
Link: https://uefi.org/specs/ACPI/6.5/19_ASL_Reference.html#buffer-declare-buffer-object [1]
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/acpi/property.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
Comments
On Mon, Oct 2, 2023 at 3:46 PM Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > In accordance with ACPI specificication and _DSD data buffer > representation the data there is an array of bytes. Hence, > accessing it with something longer will create a sparse data > which is against of how device property APIs work in general > and also not defined in the ACPI specification (see [1]). > Fix the code to emit an error if non-byte accessor is used to > retrieve _DSD buffer data. > > Fixes: 369af6bf2c28 ("ACPI: property: Read buffer properties as integers") > Link: https://uefi.org/specs/ACPI/6.5/19_ASL_Reference.html#buffer-declare-buffer-object [1] > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Applied along with the [2/2] as 6.7 material. > --- > drivers/acpi/property.c | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c > index 413e4fcadcaf..06550d8c619d 100644 > --- a/drivers/acpi/property.c > +++ b/drivers/acpi/property.c > @@ -1102,25 +1102,25 @@ static int acpi_data_prop_read(const struct acpi_device_data *data, > switch (proptype) { > case DEV_PROP_STRING: > break; > - case DEV_PROP_U8 ... DEV_PROP_U64: > + default: > if (obj->type == ACPI_TYPE_BUFFER) { > if (nval > obj->buffer.length) > return -EOVERFLOW; > - break; > + } else { > + if (nval > obj->package.count) > + return -EOVERFLOW; > } > - fallthrough; > - default: > - if (nval > obj->package.count) > - return -EOVERFLOW; > break; > } > if (nval == 0) > return -EINVAL; > > - if (obj->type != ACPI_TYPE_BUFFER) > - items = obj->package.elements; > - else > + if (obj->type == ACPI_TYPE_BUFFER) { > + if (proptype != DEV_PROP_U8) > + return -EPROTO; > items = obj; > + } else > + items = obj->package.elements; The braces that are missing here (as per the coding style) were added while applying the patch. > > switch (proptype) { > case DEV_PROP_U8: > -- Thanks!
On Tue, Oct 03, 2023 at 03:59:26PM +0200, Rafael J. Wysocki wrote: > On Mon, Oct 2, 2023 at 3:46 PM Andy Shevchenko > <andriy.shevchenko@linux.intel.com> wrote: ... > > + if (obj->type == ACPI_TYPE_BUFFER) { > > + if (proptype != DEV_PROP_U8) > > + return -EPROTO; > > items = obj; > > + } else > > + items = obj->package.elements; > > The braces that are missing here (as per the coding style) were added > while applying the patch. Thank you!
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 413e4fcadcaf..06550d8c619d 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1102,25 +1102,25 @@ static int acpi_data_prop_read(const struct acpi_device_data *data, switch (proptype) { case DEV_PROP_STRING: break; - case DEV_PROP_U8 ... DEV_PROP_U64: + default: if (obj->type == ACPI_TYPE_BUFFER) { if (nval > obj->buffer.length) return -EOVERFLOW; - break; + } else { + if (nval > obj->package.count) + return -EOVERFLOW; } - fallthrough; - default: - if (nval > obj->package.count) - return -EOVERFLOW; break; } if (nval == 0) return -EINVAL; - if (obj->type != ACPI_TYPE_BUFFER) - items = obj->package.elements; - else + if (obj->type == ACPI_TYPE_BUFFER) { + if (proptype != DEV_PROP_U8) + return -EPROTO; items = obj; + } else + items = obj->package.elements; switch (proptype) { case DEV_PROP_U8: