tracing/filters: fix race between filter setting and module unload
authorLi Zefan <lizf@cn.fujitsu.com>
Tue, 16 Jun 2009 08:39:41 +0000 (16:39 +0800)
committerSteven Rostedt <rostedt@goodmis.org>
Tue, 16 Jun 2009 20:25:37 +0000 (16:25 -0400)
commit00e95830a4d6e49f764fdb19896a89199bc0aa3b
tree972a3872cb48474777da0f9e3121fcc6924e197d
parent57be88878e7aa38750384704d811485a607bbda4
tracing/filters: fix race between filter setting and module unload

Module unload is protected by event_mutex, while setting filter is
protected by filter_mutex. This leads to the race:

echo 'bar == 0 || bar == 10' \    |
> sample/filter   |
                                  |  insmod sample.ko
  add_pred("bar == 0")            |
    -> n_preds == 1               |
  add_pred("bar == 100")          |
    -> n_preds == 2               |
                                  |  rmmod sample.ko
                                  |  insmod sample.ko
  add_pred("&&")                  |
    -> n_preds == 1 (should be 3) |

Now event->filter->preds is corrupted. An then when filter_match_preds()
is called, the WARN_ON() in it will be triggered.

To avoid the race, we remove filter_mutex, and replace it with event_mutex.

[ Impact: prevent corruption of filters by module removing and loading ]

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A375A4D.6000205@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace_events_filter.c