From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751517AbcEMFw6 (ORCPT ); Fri, 13 May 2016 01:52:58 -0400 Received: from mga14.intel.com ([192.55.52.115]:25575 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751081AbcEMFw4 convert rfc822-to-8bit (ORCPT ); Fri, 13 May 2016 01:52:56 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,612,1455004800"; d="scan'208";a="975515835" From: "Du, Changbin" To: Felipe Balbi , Al Viro CC: "gregkh@linuxfoundation.org" , "mina86@mina86.com" , "rui.silva@linaro.org" , "k.opasiak@samsung.com" , "lars@metafoo.de" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] usb: gadget: f_fs: report error if excess data received Thread-Topic: [PATCH] usb: gadget: f_fs: report error if excess data received Thread-Index: AQHRq3BkOTyP65TD/EyOGR5aoZlhp5+zC1+AgAGg+eD//6xsgIAAiP0A//+GGYCAAIkPQP//j6UAABFEzND//4Z3AP//dChAgACe5AD//nhXAA== Date: Fri, 13 May 2016 05:52:52 +0000 Message-ID: <0C18FE92A7765D4EB9EE5D38D86A563A05D2F5C3@SHSMSX103.ccr.corp.intel.com> References: <1462961970-2001-1-git-send-email-changbin.du@intel.com> <87twi4g8s2.fsf@linux.intel.com> <0C18FE92A7765D4EB9EE5D38D86A563A05D2F01F@SHSMSX103.ccr.corp.intel.com> <87a8jvg43q.fsf@linux.intel.com> <0C18FE92A7765D4EB9EE5D38D86A563A05D2F156@SHSMSX103.ccr.corp.intel.com> <874ma3g1lq.fsf@linux.intel.com> <0C18FE92A7765D4EB9EE5D38D86A563A05D2F183@SHSMSX103.ccr.corp.intel.com> <87zirveixx.fsf@linux.intel.com> <0C18FE92A7765D4EB9EE5D38D86A563A05D2F2C8@SHSMSX103.ccr.corp.intel.com> <87shxneg6t.fsf@linux.intel.com> <0C18FE92A7765D4EB9EE5D38D86A563A05D2F35C@SHSMSX103.ccr.corp.intel.com> <878tzfed17.fsf@linux.intel.com> In-Reply-To: <878tzfed17.fsf@linux.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjI4OTNiNjEtNjIzOC00N2FjLWE4YTEtNDFmNjY3ODJhZjBmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IitCUFI5Mm4zbHVaV3RyNWg3ZkRpc2lSdjNVSnVzcHltQ1JcLyt6ZVRRU1lFPSJ9 x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Hi, > > "Du, Changbin" writes: > >> right, and that was my point: if we copy more to userspace, then we have > >> a real big problem. > >> > > Yes, we drop the data because we userspace buffer is not enough this time. > > The problem here is that really can we just drop it silently? Maybe not. > > Yeah, it probably deserves a pr_err() or pr_debug(), but host sending > more data than it should, is another problem altogether which needs to > be addressed at the host. > > Adding a print to aid debugging is a good idea, but bailing out on the > peripheral side is not :-s > Ok, if we think this is a problem at host side that the transfer is not device expected, then device side should not accept the data or deliver the transferred data to userspace. But now we take part of the data to userspace and says it is ok. Do you agree with this point? IMO, we expose usb transfer as a file on device side. But file read() doesn't have a requirement that "sorry, you cannot read so little! you need read all once, else we may drop data for you. :) ". And some library that may retry read() until get enough data (which is normal For a general read). Then sometimes the buffer size for sys_read may not as expected. This is why I think ioctl approach is more appropriate for usb transfer. > -- > Balbi Best Regards, Du, Changbin