From: Hans de Goede <hdegoede@redhat.com>
To: Armin Wolf <W_Armin@gmx.de>, markgross@kernel.org
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] platform/x86: dell-ddv: Improve buffer handling
Date: Mon, 7 Nov 2022 15:39:58 +0100 [thread overview]
Message-ID: <30f78533-45f3-e1b6-44b1-f349b8c9bea6@redhat.com> (raw)
In-Reply-To: <20221102212336.380257-1-W_Armin@gmx.de>
Hi,
On 11/2/22 22:23, Armin Wolf wrote:
> When the DDV interface returns a buffer, it actually
> returns a acpi buffer containing an integer (buffer size)
> and another acpi buffer (buffer content).
> The size of the buffer may be smaller than the size of
> the buffer content, which is perfectly valid and should not
> be treated as an error.
> Also use the buffer size instead of the buffer content size
> when accessing the buffer to prevent accessing bogus data.
>
> Tested on a Dell Inspiron 3505.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Thank you for your patch-series, I've applied the series to my
review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.
Regards,
Hans
> ---
> drivers/platform/x86/dell/dell-wmi-ddv.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c b/drivers/platform/x86/dell/dell-wmi-ddv.c
> index 699feae3c435..1a001296e8c6 100644
> --- a/drivers/platform/x86/dell/dell-wmi-ddv.c
> +++ b/drivers/platform/x86/dell/dell-wmi-ddv.c
> @@ -129,9 +129,9 @@ static int dell_wmi_ddv_query_buffer(struct wmi_device *wdev, enum dell_ddv_meth
> if (obj->package.elements[1].type != ACPI_TYPE_BUFFER)
> goto err_free;
>
> - if (buffer_size != obj->package.elements[1].buffer.length) {
> + if (buffer_size > obj->package.elements[1].buffer.length) {
> dev_warn(&wdev->dev,
> - FW_WARN "ACPI buffer size (%llu) does not match WMI buffer size (%d)\n",
> + FW_WARN "WMI buffer size (%llu) exceeds ACPI buffer size (%d)\n",
> buffer_size, obj->package.elements[1].buffer.length);
>
> goto err_free;
> @@ -271,15 +271,17 @@ static int dell_wmi_ddv_buffer_read(struct seq_file *seq, enum dell_ddv_method m
> struct device *dev = seq->private;
> struct dell_wmi_ddv_data *data = dev_get_drvdata(dev);
> union acpi_object *obj;
> - union acpi_object buf;
> + u64 size;
> + u8 *buf;
> int ret;
>
> ret = dell_wmi_ddv_query_buffer(data->wdev, method, 0, &obj);
> if (ret < 0)
> return ret;
>
> - buf = obj->package.elements[1];
> - ret = seq_write(seq, buf.buffer.pointer, buf.buffer.length);
> + size = obj->package.elements[0].integer.value;
> + buf = obj->package.elements[1].buffer.pointer;
> + ret = seq_write(seq, buf, size);
> kfree(obj);
>
> return ret;
> --
> 2.30.2
>
next prev parent reply other threads:[~2022-11-07 14:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-02 21:23 Armin Wolf
2022-11-02 21:23 ` [PATCH 2/2] platform/x86: dell-ddv: Warn if ePPID has a suspicious length Armin Wolf
2022-11-07 14:39 ` Hans de Goede [this message]
2022-11-07 18:54 ` [PATCH 1/2] platform/x86: dell-ddv: Improve buffer handling David E. Box
2022-11-07 19:49 ` Hans de Goede
2022-11-07 21:23 ` Armin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=30f78533-45f3-e1b6-44b1-f349b8c9bea6@redhat.com \
--to=hdegoede@redhat.com \
--cc=W_Armin@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®