Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 322265 - sys-block/mbuffer-20090113 potential race condition
Summary: sys-block/mbuffer-20090113 potential race condition
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-31 16:53 UTC by John R. Graham
Modified: 2023-06-12 20:59 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Source patch corrects the reported issue. (mbuffer-20090113-race-condition.patch,697 bytes, patch)
2010-05-31 19:36 UTC, John R. Graham
Details | Diff
Patch to the ebuild to apply the race condtion patch. (mbuffer-20090113-r1.patch,766 bytes, patch)
2010-05-31 19:38 UTC, John R. Graham
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John R. Graham gentoo-dev 2010-05-31 16:53:53 UTC
A race condition can occur under corner case conditions because of the interaction between the buffer high watermark management code and the threads that handle the input and output from the managed ring buffer.  If the input data is extremely short, the input thread can signal "buffer filled to the high watermark" before the output thread is fully initialized and waiting on that semaphore.  A very small delay (1ms) between starting the output thread and the input thread addresses the race condition.

Patch coming.

- John
Comment 1 John R. Graham gentoo-dev 2010-05-31 19:34:32 UTC
Correction.  Version 20091227 is from my local overlay but the latest in-tree version (20090113) also exhibits the issue.

I'll also report this upstream.

- John
Comment 2 John R. Graham gentoo-dev 2010-05-31 19:36:52 UTC
Created attachment 233717 [details, diff]
Source patch corrects the reported issue.
Comment 3 John R. Graham gentoo-dev 2010-05-31 19:38:37 UTC
Created attachment 233719 [details, diff]
Patch to the ebuild to apply the race condtion patch.
Comment 4 SpanKY gentoo-dev 2010-06-04 18:13:08 UTC
does this apply to 20100526 ?  have you reported this upstream ?  the mbuffer author is pretty responsive to e-mail.
Comment 5 John R. Graham gentoo-dev 2010-06-08 18:21:13 UTC
Yes it does, and yes I did.  Upstream is working with me on a more robust modification, so my patch can be considered just a smoking gun proof and not what we should put into the tree.

In addition, 20100526 has a bug with its autoloader support which 20091227 doesn't have so it's not time to just bump to the latest version.
Comment 6 SpanKY gentoo-dev 2010-06-08 19:28:55 UTC
ive already bumped it :p

once a new release has been made, let us know and i'll bump it in the tree
Comment 7 Wolfram Schlich (RETIRED) gentoo-dev 2012-02-21 14:44:42 UTC
is this still relevant for mbuffer-20110724? I'm about to bump it...
Comment 8 John R. Graham gentoo-dev 2017-02-21 20:17:38 UTC
This is still relevant with all versions of mbuffer that have been in the tree since the version I reported 7 years ago. Upstream couldn't reproduce the error on his Solaris system with my Linux-developed test case, but I intend to try again. Meanwhile, I continue to apply my patch.
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-05-27 08:12:19 UTC
(In reply to John R. Graham from comment #8)
> This is still relevant with all versions of mbuffer that have been in the
> tree since the version I reported 7 years ago. Upstream couldn't reproduce
> the error on his Solaris system with my Linux-developed test case, but I
> intend to try again. Meanwhile, I continue to apply my patch.

So what happened with upstream, given they were working on something with you?
Comment 10 John R. Graham gentoo-dev 2023-06-12 20:55:58 UTC
Upstream eventually said "works for me" and "I don't even use tape anymore so I can't verify your test case properly". I even offered to /give/ him a tape drive but apparently my drive wasn't attractive enough to him for him to even consider paying customs.

I think it's obvious that my patch is a kludge and that refactoring of the initialization code so that the race condition can't occur is the correct solution. Alas, I haven't made the time to do that either.
Comment 11 John R. Graham gentoo-dev 2023-06-12 20:59:14 UTC
I will test out the current in-tree versions and report back.