* [ECOS] Serial Driver imrpovement
@ 2012-06-22 16:10 Graves, Daniel (GE Healthcare)
2012-07-01 2:37 ` Jonathan Larmour
0 siblings, 1 reply; 2+ messages in thread
From: Graves, Daniel (GE Healthcare) @ 2012-06-22 16:10 UTC (permalink / raw)
To: ecos-discuss
Hello,
Note that this might have been fixed already but just in case:
I found that the following code in Serial.c will cause a buffer overflow if there is garbage data on the wire before a thread has started reading from the serial port:
------------------------------------------------
static rcv_req_reply_t
serial_data_rcv_req(serial_channel *chan, int avail,
int* space_avail, unsigned char** space)
{
cbuf_t *cbuf = &chan->in_cbuf;
int gap;
#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE
// When there is software flow-control, force the serial device
// driver to use the single-char xmt/rcv functions, since these
// have to make policy decision based on the data. Rcv function
// may also have to transmit data to throttle the xmitter.
If (chan->config.flags & (CYGNUM_SERIAL_FLOW_XONXOFF_TX|CYGNUM_SERIAL_FLOW_XONXOFF_RX))
return CYG_RCV_DISABLED;
#endif
CYG_ASSERT(false == cbuf->block_mode_xfer_running,
"Attempting new block transfer while another is running");
// Check for space
gap = cbuf->nb;
if (gap == cbuf->len)
return CYG_RCV_FULL;
----------------------
The line gap == cbuf->len will not always evaluate to true if garbage data is received. This will cause the put variable to shoot way past len.
Thanks,
Daniel P Graves
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [ECOS] Serial Driver imrpovement
2012-06-22 16:10 [ECOS] Serial Driver imrpovement Graves, Daniel (GE Healthcare)
@ 2012-07-01 2:37 ` Jonathan Larmour
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Larmour @ 2012-07-01 2:37 UTC (permalink / raw)
To: Graves, Daniel (GE Healthcare); +Cc: ecos-discuss
On 22/06/12 17:10, Graves, Daniel (GE Healthcare) wrote:
> I found that the following code in Serial.c will cause a buffer overflow
> if there is garbage data on the wire before a thread has started reading
> from the serial port:
>
> ------------------------------------------------
> static rcv_req_reply_t
> serial_data_rcv_req(serial_channel *chan, int avail,
> int* space_avail, unsigned char** space)
> {
[snip]
> // Check for space
> gap = cbuf->nb;
> if (gap == cbuf->len)
> return CYG_RCV_FULL;
>
> ----------------------
>
> The line gap == cbuf->len will not always evaluate to true if garbage data
> is received. This will cause the put variable to shoot way past len.
I don't yet follow the situation you are concerned about. This generic layer
doesn't know about garbage data. Garbage data is just data, and whether before
or after a thread has started reading from the serial port, the underlying
hardware serial driver needs to call serial_data_rcv_req() when data is
received and act accordingly based on the return code.
Based on what you're saying, you are implying that cbuf->nb > cbuf->len ? If
so, then something has gone wrong... I imagine that the hardware driver is not
respecting space_avail on return from serial_data_rcv_req().
Are you using an eCos serial driver or something you wrote yourself?
Jifl
--
eCosCentric Limited http://www.eCosCentric.com/ The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------ Opinions==mine
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-01 2:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-22 16:10 [ECOS] Serial Driver imrpovement Graves, Daniel (GE Healthcare)
2012-07-01 2:37 ` Jonathan Larmour
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 read-only IMAP folder(s) and NNTP newsgroup(s).