From: Philip L. <ph...@ov...> - 2017-11-16 22:55:23
|
On Thu, 16 Nov 2017 14:03:26 -0800 Jerry Zhang <zha...@go...> wrote: > Hi all, > > It looks like the behavior would be caused by this line in the kernel > mtp driver. The offset itself is not sanitized before being passed to > > ret = vfs_read(filp, req->buf + hdr_size, xfer - hdr_size, &offset); > > vfs_read does not perform the same checks as a read() syscall, which > would explain the weird behavior. > > However, we're switching over to using a functionfs interface instead. > Currently, only Pixel and Pixel 2 phones have made the switch since it > is up to oems to do it themselves. So for these phones, we have > > if (TEMP_FAILURE_RETRY(pread(mfr.fd, mIobuf[0].bufs.data() + > sizeof(mtp_data_header), init_read_len, offset)) > != init_read_len) return -1; > > Since this uses pread, which will have posix semantics, it makes sense > that pixel and pixel 2 will not have this error. Any other phone, no > matter what OS, will probably run into this error so its a good idea > to have workaround for backwards compatibility. > > Thanks, > Jerry Hi Jerry, Thanks for the explanation - the only pixel device in our tested set was mine, so it all lines up. We'll go ahead and apply the workaround. --phil |