From: Gertjan van Wingerde <gwingerde@gmail.com>
To: Ivo Van Doorn <ivdoorn@gmail.com>
Cc: "John W. Linville" <linville@tuxdriver.com>,
linux-wireless@vger.kernel.org, users@rt2x00.serialmonkey.com
Subject: Re: [PATCH 2/9] rt2x00: Fix beacon descriptor writing for rt61pci.
Date: Wed, 12 May 2010 20:42:57 +0200 [thread overview]
Message-ID: <4BEAF6B1.3000200@gmail.com> (raw)
In-Reply-To: <AANLkTimubF1UWmzLwhJ7vhquBHmRywJQTvJciU3D3SNx@mail.gmail.com>
On 05/12/10 19:43, Ivo Van Doorn wrote:
> On Wed, May 12, 2010 at 11:46 AM, Gertjan van Wingerde
> <gwingerde@gmail.com> wrote:
>> On Wed, May 12, 2010 at 8:59 AM, Ivo Van Doorn <ivdoorn@gmail.com> wrote:
>>> On Tue, May 11, 2010 at 11:51 PM, Gertjan van Wingerde
>>> <gwingerde@gmail.com> wrote:
>>>> The buffer address descriptor word is not part of the TXINFO structure
>>>> needed for beacons. The current writing of that word for beacons is
>>>> therefore an out-of-bounds write.
>>>> Fix this by only writing the buffer address descriptor word for TX
>>>> queues.
>>>>
>>>> Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
>>>> ---
>>>> drivers/net/wireless/rt2x00/rt61pci.c | 10 +++++-----
>>>> 1 files changed, 5 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
>>>> index 2436363..99c2981 100644
>>>> --- a/drivers/net/wireless/rt2x00/rt61pci.c
>>>> +++ b/drivers/net/wireless/rt2x00/rt61pci.c
>>>> @@ -1801,12 +1801,12 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
>>>> rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1);
>>>> rt2x00_desc_write(txd, 5, word);
>>>>
>>>> - rt2x00_desc_read(txd, 6, &word);
>>>> - rt2x00_set_field32(&word, TXD_W6_BUFFER_PHYSICAL_ADDRESS,
>>>> - skbdesc->skb_dma);
>>>> - rt2x00_desc_write(txd, 6, word);
>>>> + if (txdesc->queue != QID_BEACON) {
>>>> + rt2x00_desc_read(txd, 6, &word);
>>>> + rt2x00_set_field32(&word, TXD_W6_BUFFER_PHYSICAL_ADDRESS,
>>>> + skbdesc->skb_dma);
>>>> + rt2x00_desc_write(txd, 6, word);
>>>>
>>>> - if (skbdesc->desc_len > TXINFO_SIZE) {
>>>> rt2x00_desc_read(txd, 11, &word);
>>>> rt2x00_set_field32(&word, TXD_W11_BUFFER_LENGTH0,
>>>> txdesc->length);
>>>
>>> Shouldn't the check for TXINFO_SIZE be used rather than explicitly
>>> checking for the QID?
>>>
>>
>> I agree that this is a change that didn't have to be made in this patch.
>> However, after patch 4 of the series we cannot depend on the
>> skbdesc->desc_len being set anymore, and we would have to depend on
>> checking the QID anyway.
>> Note that in reality these two checks are completely equivalent with
>> respect to the result.
>
> Hmm, is that a good idea? I mean we are using the skbdesc inside the
> function, but we can't be sure that one of the basic values contains the right
> value?
>
To be honest, the chipset drivers don't need the skbdesc->desc and skbdesc->desc_len
at all. Based on the queue ID they already have everything they need to know to write
a descriptor. As far as I can tell the only code that really needs those two fields is
the rt2x00debug code, to dump a frame to userspace via debugfs.
As the dumping through debugfs is done after writing the TX descriptor, with this patch
I changed the desc and desc_len fields of the skbdesc to be output of the write_tx_desc
function (for the generic parts of the rt2x00 code) rather than being input.
Note that originally my plan was to get rid of the desc and desc_len field altogether,
but for now I refrained from doing that.
---
Gertjan.
next prev parent reply other threads:[~2010-05-12 18:43 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-11 21:51 [PATCH 0/9] rt2x00: Further fixes and cleanups Gertjan van Wingerde
2010-05-11 21:51 ` [PATCH 1/9] rt2x00: Consistently name skb frame descriptor skbdesc Gertjan van Wingerde
2010-05-12 6:59 ` Ivo Van Doorn
2010-05-11 21:51 ` [PATCH 2/9] rt2x00: Fix beacon descriptor writing for rt61pci Gertjan van Wingerde
2010-05-12 6:59 ` Ivo Van Doorn
2010-05-12 9:46 ` Gertjan van Wingerde
2010-05-12 17:43 ` Ivo Van Doorn
2010-05-12 18:42 ` Gertjan van Wingerde [this message]
2010-05-12 18:46 ` Ivo Van Doorn
2010-05-12 18:47 ` Ivo Van Doorn
2010-05-11 21:51 ` [PATCH 3/9] rt2x00: Re-order tx descriptor writing code in drivers Gertjan van Wingerde
2010-05-12 7:00 ` Ivo Van Doorn
2010-05-11 21:51 ` [PATCH 4/9] rt2x00: Simplify TXD handling of beacons Gertjan van Wingerde
2010-05-12 7:11 ` Ivo Van Doorn
2010-05-11 21:51 ` [PATCH 5/9] rt2x00: Dump beacons under a different identifier than TX frames Gertjan van Wingerde
2010-05-12 7:00 ` Ivo Van Doorn
2010-05-11 21:51 ` [PATCH 6/9] rt2x00: Push beacon TX descriptor writing to drivers Gertjan van Wingerde
2010-05-12 7:06 ` Ivo Van Doorn
2010-05-12 9:53 ` Gertjan van Wingerde
2010-05-12 17:45 ` Ivo Van Doorn
2010-05-12 19:03 ` Gertjan van Wingerde
2010-05-12 19:10 ` Ivo Van Doorn
2010-05-12 19:22 ` Gertjan van Wingerde
2010-05-11 21:51 ` [PATCH 7/9] rt2x00: In debugfs frame dumping allow the TX descriptor to be part of the skb Gertjan van Wingerde
2010-05-12 7:12 ` Ivo Van Doorn
2010-05-11 21:51 ` [PATCH 8/9] rt2x00: Reverse calling order of bus write_tx_desc and driver write_tx_desc Gertjan van Wingerde
2010-05-12 7:02 ` Ivo Van Doorn
2010-05-12 9:55 ` Gertjan van Wingerde
2010-05-12 17:47 ` Ivo Van Doorn
2010-05-12 19:02 ` Gertjan van Wingerde
2010-05-11 21:51 ` [PATCH 9/9] rt2x00: Properly reserve room for descriptors in skbs Gertjan van Wingerde
2010-05-12 7:08 ` Ivo Van Doorn
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=4BEAF6B1.3000200@gmail.com \
--to=gwingerde@gmail.com \
--cc=ivdoorn@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=users@rt2x00.serialmonkey.com \
/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;
as well as URLs for NNTP newsgroup(s).