All of lore.kernel.org
 help / color / mirror / Atom feed
From: Doug Dumitru <doug@easyco.com>
To: jdike@addtoit.com, user-mode-linux-devel@lists.sourceforge.net
Subject: [uml-devel] Patch for buffer overrun in serial/console device logic
Date: Tue, 07 Oct 2003 11:55:40 -0700	[thread overview]
Message-ID: <3F830C2C.8010308@easyco.com> (raw)

I have been having trouble with buffer overruns when talking to pty 
devices.  My boot config directs serial device with syntax like:

   ... ssl0=tty:/dev/pty/pty1009 ...

This sets up a serial line to talk with a pty device.  We don't use the 
ptmx interface so that we can definitavely know which device to talk to 
from the outside.

The problem we are seeing is that outbound data gets overrun.  If you 
send 100K out the stream, you tend to see the first 28K or so followed 
by a big gap followed by the last 3K or so of the stream.  We have 
tested this with the ptmx syntax/logic and the problem still seems to be 
there.  Also, if you test this with a very fast consumer (such as a 
local cat from the device), the problem does not manifest itself.  UML 
must be able to produce data faster than the outside world can consume it.

After a lot of looking, it appears that the line_write routine in line.c 
does not check to see if the buffer has enough room.  The 
buffer_data(...) routine does not appear to check for available space at 
all and just overwrites old data.

Here is the patch that appears to correct the issue:




--- ../linux-2.4.22/arch/um/drivers/line.c      Tue Oct  7 10:25:20 2003
+++ arch/um/drivers/line.c      Tue Oct  7 10:27:06 2003
@@ -97,6 +97,7 @@
         char *new;
         unsigned long flags;
         int n, err, i;
+       int room;

         if(tty->stopped) return 0;

@@ -115,6 +116,10 @@
         i = minor(tty->device) - tty->driver.minor_start;
         line = &lines[i];

+       room = line_write_room(tty);
+       if ( !room ) return -EAGAIN;
+       if ( room < len ) len = room;
+
         down(&line->sem);
         if(line->head != line->tail){
                 local_irq_save(flags);




We have this running in our 2.4.22 build, but would like to see it (or 
something equivelent) in the release so that we can take patches cleanly.

We also have a much messier, in-house patch that we apply to hostfs.c so 
that root mounts will correctly honor ownerships and rights.  Is anyone 
else working on this.  The 2.4.20-5um release appears to have a lot of 
missing stuff in this area, but if someone else is re-working this, I 
will put my patch down for a while and wait.  Otherwise, I will clean it 
up and submit it.

--------------------------------------------------------------------
Doug Dumitru     800-470-2756     (610-237-2000)
EasyCo LLC       doug@easyco.com  http://easyco.com
--------------------------------------------------------------------
D3, U2, jBase Virtual Servers.    Off-site backup over the internet.
Develop/test/deploy from $20/mo.  Fast, secure, cheaper than tape.
http://mirroredservers.com        http://mirroredbackup.com



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

             reply	other threads:[~2003-10-07 18:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-07 18:55 Doug Dumitru [this message]
2003-10-07 21:51 ` [uml-devel] Re: Patch for buffer overrun in serial/console device logic Jeff Dike
2003-10-07 22:31   ` Doug Dumitru
2003-10-11  1:49     ` Jeff Dike
2003-10-12  3:39       ` Doug Dumitru
2003-10-13 20:43       ` BlaisorBlade
     [not found] ` <p05111b00bba97b88a68d@[10.96.96.13]>
2003-10-08 16:25   ` [uml-devel] " Doug Dumitru
2003-11-09  1:53 ` [uml-devel] " Jeff Dike

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=3F830C2C.8010308@easyco.com \
    --to=doug@easyco.com \
    --cc=jdike@addtoit.com \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.