mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Newall <davidn@davidnewall.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Xmit buffer overflow in pl2303
Date: Fri, 01 Feb 2008 16:10:47 +1030	[thread overview]
Message-ID: <47A2B0DF.1050504@davidnewall.com> (raw)

I've been working on a buffer overflow problem in pl2303.  Admittedly
I'm using a 2.4 kernel, but I've back-ported the latest pl2303.c. 
(Please make no unnecessary fuss over that.)  For the record, the
pl2303.c from 2.6.23 is substantially identical to that from 2.4.  The
significant change, other than addition of some extra product ids, is
the inclusion of a couple of 1k circular buffers, which hide the
problem; but buffers are finite and when sufficiently motivated, the
problem reappears.

The problem relates to hardware handshaking.  When CTS is off, the
userspace application can continue to write to the device, eventually
filling all buffers, both kernel and hardware, after which data is
dropped and pl2303_write returns 0.  Loading the module with debug=1, I
see each user write of n bytes reflected in the log as a sequence of
writes of length n, n-1, ..., 0.  I guess something above the module is
catching the 0 return from pl2303_write and repeating with one less byte
each time, perhaps on the basis that a smaller count might succeed where
the larger doesn't.  At no point does the user application block until
CTS is re-asserted.  The driver correctly records CTS (and other line)
state transitions, but nothing seems to care.

I have inserted code in pl2303_write which sleeps while CTS is off (if
it's being monitored), and likewise DSR.  That works nicely, but it
seems to me that this is a common requirement that should be handled
elsewhere.  I don't see it in char/tty, either in usbserial.  I don't
even see it in any other driver.  Where should I be looking?

                 reply	other threads:[~2008-02-01  5:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=47A2B0DF.1050504@davidnewall.com \
    --to=davidn@davidnewall.com \
    --cc=linux-kernel@vger.kernel.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

Powered by JetHome