From: Szymon Heidrich <szymon.heidrich@gmail.com>
To: Marek Vasut <marex@denx.de>, festevam@gmail.com, lukma@denx.de
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH v2] usb: gadget: rndis: Prevent InformationBufferOffset manipulation
Date: Fri, 9 Dec 2022 12:48:21 +0100 [thread overview]
Message-ID: <09dd3c14-135f-812b-b4e0-df62241a0937@gmail.com> (raw)
In-Reply-To: <43bcabe9-eb46-9099-eec9-2e846f2c3ddf@denx.de>
On 09/12/2022 02:56, Marek Vasut wrote:
> On 12/5/22 10:28, Szymon Heidrich wrote:
>> Prevent access to arbitrary memory locations in gen_ndis_set_resp
>> via manipulation of buf->InformationBufferOffset. Original
>> implementation permits manipulation of InformationBufferOffset to
>> exploit OID_GEN_CURRENT_PACKET_FILTER to set arbitrary memory contents
>> within a 32byte offset as the devices packet filter. The packet filter
>> value may be next retrieved using gen_ndis_query_resp so it is possible
>> to extract specific memory regions two bytes a time.
>>
>> The rndis_query_response was not modified as neither the buffer offset
>> nor length passed to gen_ndis_query_resp is used.
>>
>> Signed-off-by: Szymon Heidrich <szymon.heidrich@gmail.com>
>> ---
>> V1 -> V2: Updated commit message
>>
>> drivers/usb/gadget/rndis.c | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
>> index 13c327ea38..3948f2cc9a 100644
>> --- a/drivers/usb/gadget/rndis.c
>> +++ b/drivers/usb/gadget/rndis.c
>> @@ -855,14 +855,17 @@ static int rndis_set_response(int configNr, rndis_set_msg_type *buf)
>> rndis_set_cmplt_type *resp;
>> rndis_resp_t *r;
>> + BufLength = get_unaligned_le32(&buf->InformationBufferLength);
>> + BufOffset = get_unaligned_le32(&buf->InformationBufferOffset);
>> + if ((BufOffset > RNDIS_MAX_TOTAL_SIZE - 8) ||
>> + (BufLength > RNDIS_MAX_TOTAL_SIZE - 8 - BufOffset))
>> + return -EINVAL;
>> +
>> r = rndis_add_response(configNr, sizeof(rndis_set_cmplt_type));
>> if (!r)
>> return -ENOMEM;
>> resp = (rndis_set_cmplt_type *) r->buf;
>> - BufLength = get_unaligned_le32(&buf->InformationBufferLength);
>> - BufOffset = get_unaligned_le32(&buf->InformationBufferOffset);
>> -
>> #ifdef VERBOSE
>> debug("%s: Length: %d\n", __func__, BufLength);
>> debug("%s: Offset: %d\n", __func__, BufOffset);
>
> Applied to usb/master, thanks
Thank you very much for your time and review.
prev parent reply other threads:[~2022-12-09 11:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 19:44 [PATCH] Enforce buffer boundaries on RNDIS USB Gadget Szymon Heidrich
2022-11-20 15:02 ` Fabio Estevam
2022-12-03 14:59 ` Szymon Heidrich
2022-12-04 19:12 ` Marek Vasut
2022-12-04 20:36 ` Szymon Heidrich
2022-12-05 0:41 ` Marek Vasut
2022-12-05 9:28 ` [PATCH v2] usb: gadget: rndis: Prevent InformationBufferOffset manipulation Szymon Heidrich
2022-12-09 1:56 ` Marek Vasut
2022-12-09 11:48 ` Szymon Heidrich [this message]
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=09dd3c14-135f-812b-b4e0-df62241a0937@gmail.com \
--to=szymon.heidrich@gmail.com \
--cc=festevam@gmail.com \
--cc=lukma@denx.de \
--cc=marex@denx.de \
--cc=u-boot@lists.denx.de \
/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