/usr/share/systemtap/runtime/uprobes-inode.c is in systemtap-common 1.7-1+deb7u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | /* -*- linux-c -*-
* Common functions for using inode-based uprobes
* Copyright (C) 2011 Red Hat Inc.
*
* This file is part of systemtap, and is free software. You can
* redistribute it and/or modify it under the terms of the GNU General
* Public License (GPL); either version 2, or (at your option) any
* later version.
*/
#ifndef _UPROBES_INODE_C_
#define _UPROBES_INODE_C_
#include <linux/fs.h>
#include <linux/namei.h>
#include <linux/uprobes.h>
// PR13489, inodes-uprobes export kludge
#if !defined(CONFIG_UPROBES)
#error "not to be built without CONFIG_UPROBES"
#endif
#if !defined(STAPCONF_REGISTER_UPROBE_EXPORTED)
typedef int (*register_uprobe_fn)(struct inode *inode, loff_t offset,
struct uprobe_consumer *consumer);
#define register_uprobe (* (register_uprobe_fn)kallsyms_register_uprobe)
#endif
#if !defined(STAPCONF_UNREGISTER_UPROBE_EXPORTED)
typedef void (*unregister_uprobe_fn)(struct inode *inode, loff_t offset,
struct uprobe_consumer *consumer);
#define unregister_uprobe (* (unregister_uprobe_fn)kallsyms_unregister_uprobe)
#endif
struct stp_inode_uprobe_target {
const char * const filename;
struct inode *inode;
};
struct stp_inode_uprobe_consumer {
struct uprobe_consumer consumer;
struct stp_inode_uprobe_target * const target;
loff_t offset;
/* XXX sdt_sem_offset support? */
struct stap_probe * const probe;
};
static void
stp_inode_uprobes_put(struct stp_inode_uprobe_target *targets,
size_t ntargets)
{
size_t i;
for (i = 0; i < ntargets; ++i) {
struct stp_inode_uprobe_target *ut = &targets[i];
iput(ut->inode);
ut->inode = NULL;
}
}
static int
stp_inode_uprobes_get(struct stp_inode_uprobe_target *targets,
size_t ntargets)
{
int ret = 0;
size_t i;
for (i = 0; i < ntargets; ++i) {
struct path path;
struct stp_inode_uprobe_target *ut = &targets[i];
ret = kern_path(ut->filename, LOOKUP_FOLLOW, &path);
if (!ret) {
ut->inode = igrab(path.dentry->d_inode);
if (!ut->inode)
ret = -EINVAL;
}
if (ret)
break;
}
if (ret)
stp_inode_uprobes_put(targets, i);
return ret;
}
static void
stp_inode_uprobes_unreg(struct stp_inode_uprobe_consumer *consumers,
size_t nconsumers)
{
size_t i;
for (i = 0; i < nconsumers; ++i) {
struct stp_inode_uprobe_consumer *uc = &consumers[i];
unregister_uprobe(uc->target->inode, uc->offset,
&uc->consumer);
}
}
static int
stp_inode_uprobes_reg(struct stp_inode_uprobe_consumer *consumers,
size_t nconsumers)
{
int ret = 0;
size_t i;
for (i = 0; i < nconsumers; ++i) {
struct stp_inode_uprobe_consumer *uc = &consumers[i];
ret = register_uprobe(uc->target->inode, uc->offset,
&uc->consumer);
if (ret)
break;
}
if (ret)
stp_inode_uprobes_unreg(consumers, i);
return ret;
}
static int
stp_inode_uprobes_init(struct stp_inode_uprobe_target *targets, size_t ntargets,
struct stp_inode_uprobe_consumer *consumers, size_t nconsumers)
{
int ret = stp_inode_uprobes_get(targets, ntargets);
if (!ret) {
ret = stp_inode_uprobes_reg(consumers, nconsumers);
if (ret)
stp_inode_uprobes_put(targets, ntargets);
}
return ret;
}
static void
stp_inode_uprobes_exit(struct stp_inode_uprobe_target *targets, size_t ntargets,
struct stp_inode_uprobe_consumer *consumers, size_t nconsumers)
{
stp_inode_uprobes_unreg(consumers, nconsumers);
stp_inode_uprobes_put(targets, ntargets);
}
#endif /* _UPROBES_INODE_C_ */
|