From patchwork Mon Oct 2 13:46:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 147311 Return-Path: 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 + 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 ); 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 To: Andy Shevchenko , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown 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 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: 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 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 --- 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; switch (proptype) { case DEV_PROP_U8: From patchwork Mon Oct 2 13:46:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 147392 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1577649vqb; Mon, 2 Oct 2023 10:25:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMPR8MxCgLAsUaHNfeutKUPVctn1ZgDA39nw/vkpFojiYRNUFIwOHwMAuEeT/qN/YVrPFd X-Received: by 2002:a05:6a20:12cd:b0:151:35ad:f327 with SMTP id v13-20020a056a2012cd00b0015135adf327mr12408278pzg.17.1696267538402; Mon, 02 Oct 2023 10:25:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696267538; cv=none; d=google.com; s=arc-20160816; b=k1Ey+lxI5eOAREwE1FHJJ8sTvqzRTjawZl9H5bHPLsuB0wq1zdtihRSyq0f6FTZU7U YIYeBltRdiRrm4Y95hkSOOynBD3/6vpep7ibjQUBj28gmJsvPtvfpQB/vl0lFDpp5NTY 4ja1hbwuSMF6UY8Ip56TWyyJYa6NwESo20JEuzB8niq3b8kKkk545AWabZ8SYRaEjb3A PEsBKx6tWp5O3oZs5sY9FfojbnznU5mgb83gMLSJ3ADh+679gifaEbj9Sh3tMyF61rO2 +yL5qmT/9sqGql5WWp55qAIABLEKBroPQFhUURGOV5ii4JyDqlcyheHxgWhzrKaNxsWH Ia8A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=F3u6BNANhWKBJiYD5hdL2TK7v76VzIOE/hpjAmMirx0=; fh=mc5eN6NpPXlNdmS+rCx3NDxVhwjvWkKk2n0WXJda3Xs=; b=ilvx2VqsW/CkZJFVqSD5A8f+n06k0Hn92/GFcMg1e41gDzc5AyknVhKxkKd9u1NKeb yIJbygQwRXajjv1RLL9ZjG63R2xGpGRowDEnOfE4sQv2aASuwbVl17NQxBOc0wEl0nhG TpEY66DIqXTdd2+D4z8w9zY/NrVYnAT7Fn+3rVG4CAbb+PlZ9TXU7ztNC5votcRUkJxz Jr4bgMp99Nm4i+RdyUc8w2+akpbiKkI8TG7JIb6rorrSJSIbTyPAySJENFMv10KxoVW+ zJ212xjGkp44oGOcF2NUMkjhDQDySGXQ57MFisYKdY7dKsMIEyh7kGoUVaG4KO45AjLf YW4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gNq37D21; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a36-20020a056a001d2400b0068ff0235e09si26733992pfx.61.2023.10.02.10.25.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 10:25:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gNq37D21; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id B61038030B6F; Mon, 2 Oct 2023 06:46:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237490AbjJBNql (ORCPT + 18 others); Mon, 2 Oct 2023 09:46:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236736AbjJBNqi (ORCPT ); Mon, 2 Oct 2023 09:46:38 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 388EDB4; 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:in-reply-to: references:mime-version:content-transfer-encoding; bh=fKsmYxDNJP3z4B97CHI1LWKlpncnoj+xMxMwB4r88HA=; b=gNq37D21mMZdN4RE1zDjmNEnpEYgzlnitBZKj+kWiaxotQVWBWZ2NfvX 9XzbsKCmR0pPO3FCF5vjc0KAb7xkFNjL74WhlLfuNhFznHnrR06VjK9m5 0p/HDwXDiSKaZtbaYMm5bqvsxSDD4W9JOtCS22ocMNTLUzb1A9fhuTawd /cxZ5n/c8HmLHZdoV9lXiPaaY3WYwECm2x0GGqGbiJV+jEQWaXMlLLkF3 C8uyHI04zs5ffV5IhPn7+SVUxcs11zxTW9IFJkHMwpblBd+LVPhI11J7d IO0hk4B8w9/9AFzCkNBzvPlFuHOQgCg5x+9PgoZRttOOeTWcOzlgXR9+l A==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="382551430" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="382551430" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.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="997622359" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="997622359" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 02 Oct 2023 06:46:33 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C196B65; Mon, 2 Oct 2023 16:46:31 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown Subject: [PATCH v1 2/2] ACPI: property: Document the _DSD data buffer GUID Date: Mon, 2 Oct 2023 16:46:30 +0300 Message-Id: <20231002134630.2601294-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231002134630.2601294-1-andriy.shevchenko@linux.intel.com> References: <20231002134630.2601294-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 06:46:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778665429994964452 X-GMAIL-MSGID: 1778665429994964452 As the rest of the GUIDs document one for _DSD data buffer so it will be eaisier to search for on internet or documentation. Signed-off-by: Andy Shevchenko --- drivers/acpi/property.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 06550d8c619d..92f017cc897a 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -55,6 +55,7 @@ static const guid_t ads_guid = GUID_INIT(0xdbb8e3e6, 0x5886, 0x4ba6, 0x87, 0x95, 0x13, 0x19, 0xf5, 0x2a, 0x96, 0x6b); +/* ACPI _DSD data buffer GUID: edb12dd0-363d-4085-a3d2-49522ca160c4 */ static const guid_t buffer_prop_guid = GUID_INIT(0xedb12dd0, 0x363d, 0x4085, 0xa3, 0xd2, 0x49, 0x52, 0x2c, 0xa1, 0x60, 0xc4);