From: Felipe Balbi <balbi@kernel.org>
To: "Du\, Changbin" <changbin.du@intel.com>
Cc: "gregkh\@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"mina86\@mina86.com" <mina86@mina86.com>,
"rui.silva\@linaro.org" <rui.silva@linaro.org>,
"k.opasiak\@samsung.com" <k.opasiak@samsung.com>,
"lars\@metafoo.de" <lars@metafoo.de>,
"linux-usb\@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] usb: gadget: f_fs: report error if excess data received
Date: Thu, 12 May 2016 09:52:41 +0300 [thread overview]
Message-ID: <87a8jvg43q.fsf@linux.intel.com> (raw)
In-Reply-To: <0C18FE92A7765D4EB9EE5D38D86A563A05D2F01F@SHSMSX103.ccr.corp.intel.com>
Hi,
"Du, Changbin" <changbin.du@intel.com> writes:
>> > If it happen, we can keep the excess data for next i/o, or
>> > report an error. But we cannot silently drop data, because
>> > USB layer should ensure the data integrality it has transferred,
>> > otherwise applications may get corrupt data if it doesn't
>> > detect this case.
>>
>> and when has this actually happened ? Host should not send more data in
>> this case, if it does, it's an error on the host side. Also, returning
>> -EOVERFLOW is not exactly correct here, because you'd violate POSIX
>> specification of read(), right ?
>>
> This can happen if the host side app force kill-restart, not taking care of this
> special condition(and we are not documented), or even it is a bug. Usually APPs
> may has a protocol to control the packet size, but protocol mismatch can happen
> if either side encounter an error.
>
> Anyway, this is real. If kernel return success and drop data, the error may
> explosion later, or its totally hided (but why some data lost in kernel?
> Kernel cannot tell userspace we cannot be trusted sometimes, right?).
> so IMO, if this is an error, we need report an error or fix it, not hide it.
>
> The POSIX didn't say read cannot return "-EOVERFLOW", it says:
> " Other errors may occur, depending on the object connected to fd."
>
> If "-EOVERFLOW" is not suitable, EFAULT, or any suggestions?
>
>> > Here, we simply report an error to userspace to let userspace
>> > proccess. Actually, userspace applications should negotiate
>>
>> no, this violates POSIX. Care to explain what problem are you actually
>> facing ?
>>
> Why this violates POSIX? Could you give more details?
read(5) should return at mode 5 bytes. If there are more, than 5 bytes,
we don't error out, we just return the requested 5 bytes and wait for a
further read.
What I'm more concerned, however, is why we received more than expected
data. What's on the extra bytes ? Can you capture dwc3 traces ? Perhaps
add a few traces doing a hexdump (using __print_hex()) of the data in
req->buf.
> The problem is device side app sometimes received incorrect data caused
> by the dropping. Most times the error can be detected by APP itself, but
why ? app did e.g. read(5), that caused driver to queue a usb_request
with length set to 512. Host sent more data than the expected 5 bytes,
why did host do that ? And if that data was needed, why didn't userspace
read() more than 5 ?
--
balbi
next prev parent reply other threads:[~2016-05-12 6:54 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-11 10:19 [PATCH] usb: gadget: f_fs: report error if excess data received changbin.du
2016-05-11 10:59 ` Felipe Balbi
2016-05-11 12:30 ` Michal Nazarewicz
2016-05-12 4:25 ` Du, Changbin
2016-05-12 4:21 ` Du, Changbin
2016-05-12 6:52 ` Felipe Balbi [this message]
2016-05-12 7:30 ` Du, Changbin
2016-05-12 7:46 ` Felipe Balbi
2016-05-12 8:16 ` Du, Changbin
2016-05-12 9:15 ` Felipe Balbi
2016-05-12 9:22 ` Felipe Balbi
2016-05-12 9:51 ` Du, Changbin
2016-05-12 9:39 ` Du, Changbin
2016-05-12 10:13 ` Felipe Balbi
2016-05-12 10:14 ` Felipe Balbi
2016-05-12 10:45 ` Du, Changbin
2016-05-12 11:22 ` Felipe Balbi
2016-05-13 5:52 ` Du, Changbin
2016-05-13 6:36 ` Felipe Balbi
2016-05-13 10:32 ` Du, Changbin
2016-05-13 14:29 ` Alan Stern
2016-05-14 20:39 ` Michal Nazarewicz
2016-05-16 12:57 ` Felipe Balbi
2016-05-16 13:08 ` Michal Nazarewicz
2016-05-16 13:16 ` Felipe Balbi
2016-05-16 19:09 ` Michal Nazarewicz
2016-05-17 2:53 ` Du, Changbin
2016-05-18 9:45 ` Michal Nazarewicz
2016-05-18 10:15 ` Felipe Balbi
2016-05-18 13:39 ` Michal Nazarewicz
2016-05-19 2:54 ` Du, Changbin
2016-05-19 7:34 ` Michal Nazarewicz
2016-05-19 8:49 ` Du, Changbin
2016-05-19 2:31 ` Du, Changbin
2016-05-16 16:05 ` Michal Nazarewicz
2016-05-16 16:27 ` Lars-Peter Clausen
2016-05-16 16:48 ` Michal Nazarewicz
2016-05-16 16:35 ` Krzysztof Opasiak
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=87a8jvg43q.fsf@linux.intel.com \
--to=balbi@kernel.org \
--cc=changbin.du@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=k.opasiak@samsung.com \
--cc=lars@metafoo.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mina86@mina86.com \
--cc=rui.silva@linaro.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;
as well as URLs for NNTP newsgroup(s).