summaryrefslogtreecommitdiffstats
path: root/runtime/transport/symbols.c
diff options
context:
space:
mode:
authordsmith <dsmith>2007-08-14 15:27:58 +0000
committerdsmith <dsmith>2007-08-14 15:27:58 +0000
commitb79aff3684e02d6f83a2fa2a2fcfe53d5c9d6d14 (patch)
treebb872eed2c44fbca889e0a068ecd964e86938f87 /runtime/transport/symbols.c
parent5eddf13b73a01f3b334e5be80fc3cc1b312d1fea (diff)
downloadsystemtap-steved-b79aff3684e02d6f83a2fa2a2fcfe53d5c9d6d14.tar.gz
systemtap-steved-b79aff3684e02d6f83a2fa2a2fcfe53d5c9d6d14.tar.xz
systemtap-steved-b79aff3684e02d6f83a2fa2a2fcfe53d5c9d6d14.zip
2007-08-14 David Smith <dsmith@redhat.com>
Merge from setuid-branch. Changes also by Martin Hunt <hunt@redhat.com>. * control.c (_stp_ctl_write): Make sure we don't overflow. (_stp_ctl_open_cmd): Do not allow multiple opens of the control file. (_stp_ctl_write_cmd): Once STP_START is received, ignore everything except STP_EXIT. Create another state variable "initialized". Don't respond to STP_SYMBOLS or STP_MODULES unless initialized is 0. Also check that current pid is the same as the pid that did insmod. (_stp_register_ctl_channel): Bug fix - sets owner/group after checking for NULL. * procfs.c (_stp_ctl_write): Make sure we don't overflow. (_stp_ctl_open_cmd): Do not allow multiple opens of the control file. (_stp_ctl_write_cmd): Once STP_START is received, ignore everything except STP_EXIT. Create another state variable "initialized". Don't respond to STP_SYMBOLS or STP_MODULES unless initialized is 0. Also check that current pid is the same as the pid that did insmod. (_stp_register_ctl_channel): Set ownership of cmd file and percpu files for bulkmode. * relayfs.c (utt_trace_setup): Set ownership of percpu files. Improved error handling. (utt_trace_remove): Improved error checking. * utt.c (utt_remove_tree): Improved error checking. (utt_trace_cleanup): Ditto. (utt_create_buf_file_callback): Set file ownership. (utt_create_global_buf_file_callback): Set file ownership. * transport.h: Delcare _stp_uid, _stp_gid, and _stp_init_pid. * transport.c (_stp_transport_init): Set _stp_uid, _stp_gid, and _stp_init_pid.
Diffstat (limited to 'runtime/transport/symbols.c')
-rw-r--r--runtime/transport/symbols.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/runtime/transport/symbols.c b/runtime/transport/symbols.c
index 323b4872..1d930183 100644
--- a/runtime/transport/symbols.c
+++ b/runtime/transport/symbols.c
@@ -104,6 +104,26 @@ static struct _stp_module * _stp_alloc_module_from_module (struct module *m)
return _stp_alloc_module(num, datasize);
}
+static void _stp_free_module(struct _stp_module *mod)
+{
+ /* free symbol memory */
+ if (mod->num_symbols) {
+ if (mod->allocated & 1)
+ vfree(mod->symbols);
+ else
+ kfree(mod->symbols);
+ if (mod->allocated & 2)
+ vfree(mod->symbol_data);
+ else
+ kfree(mod->symbol_data);
+ }
+ if (mod->sections)
+ kfree(mod->sections);
+
+ /* free module memory */
+ kfree(mod);
+}
+
/* Delete a module and free its memory. */
/* The lock should already be held before calling this. */
static void _stp_del_module(struct _stp_module *mod)
@@ -134,23 +154,8 @@ static void _stp_del_module(struct _stp_module *mod)
_stp_modules_by_addr[i] = _stp_modules_by_addr[i+1];
_stp_num_modules--;
-
- /* free symbol memory */
- if (mod->num_symbols) {
- if (mod->allocated & 1)
- vfree(mod->symbols);
- else
- kfree(mod->symbols);
- if (mod->allocated & 2)
- vfree(mod->symbol_data);
- else
- kfree(mod->symbol_data);
- }
- if (mod->sections)
- kfree(mod->sections);
- /* free module memory */
- kfree(mod);
+ _stp_free_module(mod);
}
static void _stp_free_modules(void)
@@ -471,8 +476,10 @@ static int _stp_do_module(const char __user *buf, int count)
return 0;
}
- if (_stp_ins_module(mod) < 0)
+ if (_stp_ins_module(mod) < 0) {
+ _stp_free_module(mod);
return -ENOMEM;
+ }
return count;
}