Merge lp:~jamesodhunt/libnih/inotify-overflow-fix into lp:libnih/1.0

Proposed by James Hunt
Status: Needs review
Proposed branch: lp:~jamesodhunt/libnih/inotify-overflow-fix
Merge into: lp:libnih/1.0
Diff against target: 41 lines (+16/-0)
2 files modified
ChangeLog (+8/-0)
nih/watch.c (+8/-0)
To merge this branch: bzr merge lp:~jamesodhunt/libnih/inotify-overflow-fix
Reviewer Review Type Date Requested Status
Scott James Remnant (Canonical) Pending
Review via email: mp+59094@code.launchpad.net

Description of the change

* nih/watch.c: nih_watch_reader(): Handle situation where kernel
  is generating events faster than can be consumed by simply
  ignoring them. Failure to do so results in an assertion failure in
  nih_watch_handle_by_wd() since the inotify_event object will
  contain an invalid watch descriptor (-1).

Note that running the shell script below will cause Upstart to crash (generally within 60 seconds with a reasonable system) as a result of this bug:

  while [ : ]
  do
    touch /etc/init/*
  done

To post a comment you must log in.

Unmerged revisions

1049. By James Hunt

* nih/watch.c: nih_watch_reader(): Handle situation where kernel
  is generating events faster than can be consumed by simply
  ignoring them. Failure to do so results in an assertion failure in
  nih_watch_handle_by_wd() since the inotify_event object will
  contain an invalid watch descriptor (-1).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2010-12-23 22:06:15 +0000
+++ ChangeLog 2011-04-26 15:51:42 +0000
@@ -1,3 +1,11 @@
12011-04-26 James Hunt <james.hunt@ubuntu.com>
2
3 * nih/watch.c: nih_watch_reader(): Handle situation where kernel
4 is generating events faster than can be consumed by simply
5 ignoring them. Failure to do so results in an assertion failure in
6 nih_watch_handle_by_wd() since the inotify_event object will
7 contain an invalid watch descriptor (-1).
8
12010-12-23 Scott James Remnant <scott@netsplit.com>92010-12-23 Scott James Remnant <scott@netsplit.com>
210
3 * configure.ac: Bump version to 1.0.411 * configure.ac: Bump version to 1.0.4
412
=== modified file 'nih/watch.c'
--- nih/watch.c 2011-01-06 09:28:39 +0000
+++ nih/watch.c 2011-04-26 15:51:42 +0000
@@ -424,6 +424,13 @@
424 if (len < sz)424 if (len < sz)
425 goto finish;425 goto finish;
426426
427 /* Handle situation where kernel is generating events faster
428 * than can be consumed. Inotify will (somewhat ironically)
429 * generate an event to signify this, so ignore it.
430 */
431 if (event->mask & IN_Q_OVERFLOW)
432 goto consume;
433
427 /* Find the handle for this watch */434 /* Find the handle for this watch */
428 handle = nih_watch_handle_by_wd (watch, event->wd);435 handle = nih_watch_handle_by_wd (watch, event->wd);
429 if (handle)436 if (handle)
@@ -437,6 +444,7 @@
437 if (caught_free)444 if (caught_free)
438 return;445 return;
439446
447consume:
440 /* Remove the event from the front of the buffer, and448 /* Remove the event from the front of the buffer, and
441 * decrease our own length counter.449 * decrease our own length counter.
442 */450 */

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: