public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Serial buffer memory leak
@ 2007-08-08  9:58 Laurent Pinchart
  2007-08-08 13:45 ` Alan Cox
  2007-08-08 14:13 ` Paul Fulghum
  0 siblings, 2 replies; 10+ messages in thread
From: Laurent Pinchart @ 2007-08-08  9:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: paulkf

Hi everybody.

Patch c5c34d4862e18ef07c1276d233507f540fb5a532 (tty: flush flip buffer on 
ldisc input queue flush) introduces a race condition which can lead to memory 
leaks.

The problem can be triggered when tcflush() is called when data are being 
pushed to the line discipline driver by flush_to_ldisc().

flush_to_ldisc() releases tty->buf.lock when calling the line discipline 
receive_buf function. At that poing tty_buffer_flush() kicks in and sets both 
tty->buf.head and tty->buf.tail to NULL. When flush_to_ldisc() finishes, it 
restores tty->buf.head but doesn't touch tty->buf.tail. This corrups the 
buffer queue, and the next call to tty_buffer_request_room() will allocate a 
new buffer and overwrite tty->buf.head. The previous buffer is then lost 
forever without being released.

I'm not familiar enough with the tty code to decide what the proper fix should 
be. I'll try to write a patch if someone could point me in the right 
direction.

Please CC me when answering, as I'm not subscribed to the list.

Regards,

-- 
Laurent Pinchart
CSE Semaphore Belgium

Chaussée de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-08-08 17:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-08  9:58 Serial buffer memory leak Laurent Pinchart
2007-08-08 13:45 ` Alan Cox
2007-08-08 14:11   ` Paul Fulghum
2007-08-08 14:28     ` Laurent Pinchart
2007-08-08 14:52       ` Paul Fulghum
2007-08-08 15:16         ` Alan Cox
2007-08-08 15:32           ` Alan Cox
2007-08-08 17:35             ` Paul Fulghum
2007-08-08 14:26   ` Frederik Deweerdt
2007-08-08 14:13 ` Paul Fulghum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox