From: Felipe Balbi <felipe.balbi@linux.intel.com>
To: "Du\, Changbin" <changbin.du@intel.com>,
Al Viro <viro@zeniv.linux.org.uk>
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 13:14:34 +0300 [thread overview]
Message-ID: <87shxneg6t.fsf@linux.intel.com> (raw)
In-Reply-To: <0C18FE92A7765D4EB9EE5D38D86A563A05D2F2C8@SHSMSX103.ccr.corp.intel.com>
Hi,
"Du, Changbin" <changbin.du@intel.com> writes:
>> >> > These all can lead host send more than device wanted bytes. For sure
>> >> > it wrong at host side, but device side don't know.
>> >>
>> >> but none of this means we have a bug at device side. In fact, by
>> >> allowing these extra bytes to reach userspace, we could be creating a
>> >> possible attack vector.
>> >>
>> >> Your explanation is unsatisfactory, so I won't apply your patch, sorry.
>> >>
>> >> --
>> >> balbi
>> > It is fine. Then need userspace take care of all the data it received. Because
>> > Kernel may drop some data for it. Kernel ffs driver is unauthentic
>> sometimes.
>>
>> I really cannot understand what you mean sometimes. You're saying that
>> userspace needs to take care of all the data it received because kernel
>> can drop data. If kernel is dropping data, there's no extra data
>> reaching userspace, right?
>>
> For sure, maybe I didn't describe it well so let you confused. :)
okay
>> Is the problem that we *are* giving more data than expected to
>> userspace? Are we overflowing some userspace buffer? If that's the case,
>> then below should be enough for the time being:
>>
> No, the problem is we drop data but silently. We cannot give more data to
okay, but does that create any problems for device side userspace? What
problem is that?
> userspace since buffer is limited.
right, and that was my point: if we copy more to userspace, then we have
a real big problem.
>> @@ -811,7 +815,12 @@ static ssize_t ffs_epfile_io(struct file *file, struct
>> ffs_io_data *io_data)
>> */
>> ret = interrupted ? -EINTR : ep->status;
>> if (io_data->read && ret > 0) {
>> - ret = copy_to_iter(data, ret, &io_data->data);
>> + if (ret > io_data->expected_len)
>> + pr_debug("FFS: size mismatch: %zd for %zd",
>> + ret, io_data->expected_len);
>> +
>> + ret = copy_to_iter(data, io_data->expected_len,
>> + &io_data->data);
>> if (!ret)
>> ret = -EFAULT;
>> }
>>
>> that we can get merged during v4.7-rc and Cc stable and backport this to
>> anything containing Al's commit c993c39b8639 ("gadget/function/f_fs.c:
>> use put iov_iter into io_data").
>>
>
> The different for this code is just give warning but not return
> error. It is also fine for me that at least this let development can
> find some key message to find What happed under kernel. But the
> message should be *error* I think.
I'm fine with pr_error()
> And this missed AIO path. This is identify to my patch after remove the
right, it's more of a debug patch since I don't have the setup to
trigger this (I'm assuming you're using adb?)
> "return -EOVERFLOW;" line.
there's one key difference, see below
> Byw, we not need add the field "expected_len", we can get it from the
> struct ffs_io_data.
without expected_len we can copy more data to userspace, right ? If
req->actual > data_len_before_aligning_to_maxpacket, then we will copy
more data then we should to userspace and this was a regression caused
by Al's commit, AFAICT.
> If this is fine for you, I can publish a new patch.
>
>> --
>> Balbi
>
> Best Regards,
> Du, Changbin
--
balbi
next prev parent reply other threads:[~2016-05-12 10:19 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
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 [this message]
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=87shxneg6t.fsf@linux.intel.com \
--to=felipe.balbi@linux.intel.com \
--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 \
--cc=viro@zeniv.linux.org.uk \
/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).