PERFORCE change 141999 for review
Vincenzo Iozzo
snagg at FreeBSD.org
Wed May 21 23:15:40 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=141999
Change 141999 by snagg at snagg_macosx on 2008/05/21 23:14:42
avoid a panic caused by a malloc WAITOK within a lock acquired. Some style fixes also
Reviewed by: attilio
Affected files ...
.. //depot/projects/soc2008/snagg-audit/sys/security/audit/audit_pipe.c#15 edit
Differences ...
==== //depot/projects/soc2008/snagg-audit/sys/security/audit/audit_pipe.c#15 (text) ====
@@ -255,12 +255,10 @@
{
struct audit_pipe_preselect *app;
struct audit_pipe_preselect_event *event;
- struct audit_pipe_preselect_event *ev_a;
+ struct audit_pipe_preselect_event ev_a;
- ev_a = malloc(sizeof(struct audit_pipe_preselect_event),
- M_AUDIT_PIPE_PRESELECT_EVENT, M_WAITOK);
- ev_a->app_event = app_event;
- ev_a->app_flag = event_flag;
+ ev_a.app_event = app_event;
+ ev_a.app_flag = event_flag;
mtx_assert(&audit_pipe_mtx, MA_OWNED);
@@ -268,9 +266,9 @@
if(app->app_pid == app_pid) {
/* Just skip if we are interested only in the pid. */
if(app_event != -1) {
- event = bsearch(ev_a, (app->app_auevents), app->app_event_len,
- sizeof(struct audit_pipe_preselect_event),
- audit_pipe_compare_preselect_event);
+ event = bsearch(&ev_a, (app->app_auevents), app->app_event_len,
+ sizeof(struct audit_pipe_preselect_event),
+ audit_pipe_compare_preselect_event);
if(event != NULL) {
if(event_flag != -1)
if (event->app_flag != event_flag)
@@ -280,7 +278,6 @@
}
}
}
- free(ev_a, M_AUDIT_PIPE_PRESELECT_EVENT);
return (app);
}
@@ -306,7 +303,7 @@
*/
static int
audit_pipe_preselect_get_events_list(struct audit_pipe *ap,
- pid_t app_pid, struct audit_pipe_preselect_event *app_events)
+ pid_t app_pid, struct audit_pipe_preselect_event *app_events)
{
struct audit_pipe_preselect *app;
int error;
@@ -371,12 +368,15 @@
app = audit_pipe_preselect_find_event(ap, -1, app_pid, -1);
found = (app != NULL) ? 1: 0;
if(found) {
- KASSERT(num <= app->app_event_len, ("Number of events is out of range"));
+ KASSERT(num <= app->app_event_len,
+ ("Number of events is out of range"));
for (i = 0; i < num; i++) {
(app->app_auevents + i)->app_event = (events + i)->app_event;
(app->app_auevents + i)->app_flag = (events + i)->app_flag;
}
- qsort((app->app_auevents), app->app_event_len, sizeof(struct audit_pipe_preselect_event), audit_pipe_compare_preselect_event);
+ qsort((app->app_auevents), app->app_event_len,
+ sizeof(struct audit_pipe_preselect_event),
+ audit_pipe_compare_preselect_event);
} else {
app = app_new;
app_new = NULL;
@@ -386,7 +386,9 @@
(app->app_auevents + i)->app_event = (events + i)->app_event;
(app->app_auevents + i)->app_flag = (events + i)->app_flag;
}
- qsort((app->app_auevents), app->app_event_len, sizeof(struct audit_pipe_preselect_event), audit_pipe_compare_preselect_event);
+ qsort((app->app_auevents), app->app_event_len,
+ sizeof(struct audit_pipe_preselect_event),
+ audit_pipe_compare_preselect_event);
TAILQ_INSERT_TAIL(&ap->ap_preselect_list, app, app_list);
}
More information about the p4-projects
mailing list