* [PATCH] firewire:queue the right number of data [not found] <20080719153541.70eb7f17.jszhang3@mail.ustc.edu.cn> @ 2008-07-19 7:35 ` JiSheng Zhang 2008-07-20 14:00 ` Stefan Richter [not found] ` <416562490.30709@ustc.edu.cn> 0 siblings, 2 replies; 3+ messages in thread From: JiSheng Zhang @ 2008-07-19 7:35 UTC (permalink / raw) To: stefanr; +Cc: linux-kernel Hi, There will be 4 padding bytes in struct fw_cdev_event_response on some platforms The member:__u32 data will point to these padding bytes. While queue the response and data in complete_transaction in fw-cdev.c, it will queue like this: |response(excluding padding bytes)|4 padding bytes|4 padding bytes|data. It queue 4 extra bytes. That is to say it use "&response + sizeof(response)" while other place of kernel and userspace library use "&response + offsetof (typeof(response), data)". So it will lost the last 4 bytes of data.This patch can fix it while not changing the struct definition. Sorry for open a new ticket. Signed-off-by: JiSheng Zhang <jszhang3@mail.ustc.edu.cn> --- old/drivers/firewire/fw-cdev.c +++ new/drivers/firewire/fw-cdev.c @@ -382,9 +382,9 @@ response->response.type = FW_CDEV_EVENT_RESPONSE; response->response.rcode = rcode; - queue_event(client, &response->event, - &response->response, sizeof(response->response), - response->response.data, response->response.length); + queue_event(client, &response->event, &response->response, + sizeof(response->response) + response->response.length, + NULL, 0); } static int ioctl_send_request(struct client *client, void *buffer) ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] firewire:queue the right number of data 2008-07-19 7:35 ` [PATCH] firewire:queue the right number of data JiSheng Zhang @ 2008-07-20 14:00 ` Stefan Richter [not found] ` <416562490.30709@ustc.edu.cn> 1 sibling, 0 replies; 3+ messages in thread From: Stefan Richter @ 2008-07-20 14:00 UTC (permalink / raw) To: JiSheng Zhang Cc: linux1394-devel, linux-kernel, Mikael Pettersson, Kristian Høgsberg JiSheng Zhang wrote at LKML: > Hi, > > There will be 4 padding bytes in struct fw_cdev_event_response on some platforms > The member:__u32 data will point to these padding bytes. While queue the > response and data in complete_transaction in fw-cdev.c, it will queue like this: > |response(excluding padding bytes)|4 padding bytes|4 padding bytes|data. > It queue 4 extra bytes. That is to say it use "&response + sizeof(response)" > while other place of kernel and userspace library use "&response + offsetof > (typeof(response), data)". So it will lost the last 4 bytes of data.This patch > can fix it while not changing the struct definition. > > Sorry for open a new ticket. > > Signed-off-by: JiSheng Zhang <jszhang3@mail.ustc.edu.cn> > > --- old/drivers/firewire/fw-cdev.c > +++ new/drivers/firewire/fw-cdev.c > @@ -382,9 +382,9 @@ > > response->response.type = FW_CDEV_EVENT_RESPONSE; > response->response.rcode = rcode; > - queue_event(client, &response->event, > - &response->response, sizeof(response->response), > - response->response.data, response->response.length); > + queue_event(client, &response->event, &response->response, > + sizeof(response->response) + response->response.length, > + NULL, 0); > } > > static int ioctl_send_request(struct client *client, void *buffer) I tested it now on i686, x86-64, and x86-64 with i686 userland, using firecontrol and gscanbus. As discussed, they got corrupted block read responses on x86-64 and on x86-64 with i686 userland. The patch fixes this. I committed it to linux1394-2.6.git#fixes and intend to send it upstream at the end of the week or so. Thanks for spotting this bug. One point about which I am not sure about yet is what happens if there are multiple events queued up before the client can read() them. The tests which I did so far involved only a single event queued and dequeued at a time. PS: I removed a rule from linux1394-devel's header filters which matched your previous posts. (Message has priority, but no X-Mailer/User-Agent) -- Stefan Richter -=====-==--- -=== =-=-- http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <416562490.30709@ustc.edu.cn>]
[parent not found: <20080721144842.0b64f821@debian>]
* Re: [PATCH] firewire:queue the right number of data [not found] ` <20080721144842.0b64f821@debian> @ 2008-07-21 6:48 ` JiSheng Zhang 0 siblings, 0 replies; 3+ messages in thread From: JiSheng Zhang @ 2008-07-21 6:48 UTC (permalink / raw) To: Stefan Richter Cc: linux1394-devel, linux-kernel, Mikael Pettersson, Kristian Høgsberg on Sun, 20 Jul 2008 16:00:32 +0200 Stefan Richter <stefanr@s5r6.in-berlin.de> wrote: > JiSheng Zhang wrote at LKML: > > Hi, > > > > There will be 4 padding bytes in struct fw_cdev_event_response on some platforms > > The member:__u32 data will point to these padding bytes. While queue the > > response and data in complete_transaction in fw-cdev.c, it will queue like this: > > |response(excluding padding bytes)|4 padding bytes|4 padding bytes|data. > > It queue 4 extra bytes. That is to say it use "&response + sizeof(response)" > > while other place of kernel and userspace library use "&response + offsetof > > (typeof(response), data)". So it will lost the last 4 bytes of data.This patch > > can fix it while not changing the struct definition. > > > > Sorry for open a new ticket. > > > > Signed-off-by: JiSheng Zhang <jszhang3@mail.ustc.edu.cn> > > > > --- old/drivers/firewire/fw-cdev.c > > +++ new/drivers/firewire/fw-cdev.c > > @@ -382,9 +382,9 @@ > > > > response->response.type = FW_CDEV_EVENT_RESPONSE; > > response->response.rcode = rcode; > > - queue_event(client, &response->event, > > - &response->response, sizeof(response->response), > > - response->response.data, response->response.length); > > + queue_event(client, &response->event, &response->response, > > + sizeof(response->response) + response->response.length, > > + NULL, 0); > > } > > > > static int ioctl_send_request(struct client *client, void *buffer) > > I tested it now on i686, x86-64, and x86-64 with i686 userland, using > firecontrol and gscanbus. As discussed, they got corrupted block read > responses on x86-64 and on x86-64 with i686 userland. The patch fixes this. > > I committed it to linux1394-2.6.git#fixes and intend to send it upstream > at the end of the week or so. Thanks for spotting this bug. Thanks for committing. > > One point about which I am not sure about yet is what happens if there > are multiple events queued up before the client can read() them. The > tests which I did so far involved only a single event queued and > dequeued at a time. IMHO, even there are multiple events queued, it should work OK because events are put into event_list rather than a ring buffer, there is no padding bytes problem between events. > > > PS: > I removed a rule from linux1394-devel's header filters which matched > your previous posts. (Message has priority, but no X-Mailer/User-Agent) Thanks very much Regards, JiSheng ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-07-21 6:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20080719153541.70eb7f17.jszhang3@mail.ustc.edu.cn>
2008-07-19 7:35 ` [PATCH] firewire:queue the right number of data JiSheng Zhang
2008-07-20 14:00 ` Stefan Richter
[not found] ` <416562490.30709@ustc.edu.cn>
[not found] ` <20080721144842.0b64f821@debian>
2008-07-21 6:48 ` JiSheng Zhang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox