/
usr
/
share
/
systemtap
/
runtime
/
linux
/
/usr/share/systemtap/runtime/linux
mkdir
upload
Name
Size
Mode
Actions
uprobes/
-
0755
rm
uprobes2/
-
0755
rm
access_process_vm.h
4311
0644
edit
dl
rm
addr-map.c
9749
0644
edit
dl
rm
alloc.c
15900
0644
edit
dl
rm
arith.c
16799
0644
edit
dl
rm
autoconf-514-panic.c
68
0644
edit
dl
rm
autoconf-access_ok_2args.c
90
0644
edit
dl
rm
autoconf-alloc-percpu-align.c
118
0644
edit
dl
rm
autoconf-asm-syscall.c
51
0644
edit
dl
rm
autoconf-atomic_fetch_add_unless.c
94
0644
edit
dl
rm
autoconf-bio-bi_opf.c
824
0644
edit
dl
rm
autoconf-blk-types.c
359
0644
edit
dl
rm
autoconf-compat-utimbuf.c
53
0644
edit
dl
rm
autoconf-compat_sigaction.c
448
0644
edit
dl
rm
autoconf-constant-tsc.c
63
0644
edit
dl
rm
autoconf-cpu-clock.c
1277
0644
edit
dl
rm
autoconf-dpath-path.c
121
0644
edit
dl
rm
autoconf-files_lookup_fd_raw.c
136
0644
edit
dl
rm
autoconf-from_kuid_munged.c
191
0644
edit
dl
rm
autoconf-fs_supers-hlist.c
354
0644
edit
dl
rm
autoconf-generated-compile.c
56
0644
edit
dl
rm
autoconf-genhd.c
201
0644
edit
dl
rm
autoconf-get-kretprobe.c
107
0644
edit
dl
rm
autoconf-get_user_pages-flags.c
1549
0644
edit
dl
rm
autoconf-get_user_pages-notask_struct.c
1301
0644
edit
dl
rm
autoconf-get_user_pages_remote-flags.c
1550
0644
edit
dl
rm
autoconf-get_user_pages_remote-flags_locked.c
1331
0644
edit
dl
rm
autoconf-get_user_pages_remote-notask_struct.c
1438
0644
edit
dl
rm
autoconf-grsecurity.c
219
0644
edit
dl
rm
autoconf-hlist-4args.c
296
0644
edit
dl
rm
autoconf-hlist_add_tail_rcu.c
112
0644
edit
dl
rm
autoconf-hrtimer-getset-expires.c
126
0644
edit
dl
rm
autoconf-hrtimer-rel.c
87
0644
edit
dl
rm
autoconf-hw_breakpoint_context.c
315
0644
edit
dl
rm
autoconf-inode-private.c
173
0644
edit
dl
rm
autoconf-inode-rwsem.c
172
0644
edit
dl
rm
autoconf-inode-uretprobes.c
264
0644
edit
dl
rm
autoconf-kernel_read-new-args.c
1030
0644
edit
dl
rm
autoconf-kprobe-symbol-name.c
90
0644
edit
dl
rm
autoconf-ktime-get-real.c
98
0644
edit
dl
rm
autoconf-linux-sched_headers.c
1678
0644
edit
dl
rm
autoconf-local-clock.c
1282
0644
edit
dl
rm
autoconf-lockdown-debugfs.c
102
0644
edit
dl
rm
autoconf-lockdown-kernel.c
90
0644
edit
dl
rm
autoconf-mm-context-vdso-base.c
117
0644
edit
dl
rm
autoconf-mm-context-vdso.c
114
0644
edit
dl
rm
autoconf-mm-shmempages.c
72
0644
edit
dl
rm
autoconf-mmap_lock.c
175
0644
edit
dl
rm
autoconf-module-sect-attrs.c
158
0644
edit
dl
rm
autoconf-module_layout.c
52
0644
edit
dl
rm
autoconf-mod_kallsyms.c
51
0644
edit
dl
rm
autoconf-nameidata.c
96
0644
edit
dl
rm
autoconf-netfilter-4_1.c
769
0644
edit
dl
rm
autoconf-netfilter-4_4.c
1460
0644
edit
dl
rm
autoconf-netfilter-313b.c
602
0644
edit
dl
rm
autoconf-netfilter.c
422
0644
edit
dl
rm
autoconf-old-inode-uprobes.c
357
0644
edit
dl
rm
autoconf-oneachcpu-retry.c
957
0644
edit
dl
rm
autoconf-pagefault_disable.c
137
0644
edit
dl
rm
autoconf-pde_data.c
226
0644
edit
dl
rm
autoconf-perf-structpid.c
444
0644
edit
dl
rm
autoconf-procfs-owner.c
158
0644
edit
dl
rm
autoconf-proc_ops.c
566
0644
edit
dl
rm
autoconf-rcu_is_watching.c
385
0644
edit
dl
rm
autoconf-real-parent.c
427
0644
edit
dl
rm
autoconf-regset.c
239
0644
edit
dl
rm
autoconf-relay-umode_t.c
730
0644
edit
dl
rm
autoconf-relay_buf-per_cpu_ptr.c
920
0644
edit
dl
rm
autoconf-ring_buffer-flags.c
112
0644
edit
dl
rm
autoconf-ring_buffer_lost_events.c
296
0644
edit
dl
rm
autoconf-ring_buffer_read_prepare.c
181
0644
edit
dl
rm
autoconf-save-stack-trace-no-bp.c
498
0644
edit
dl
rm
autoconf-save-stack-trace.c
501
0644
edit
dl
rm
autoconf-set_fs.c
221
0644
edit
dl
rm
autoconf-smpcall-4args.c
166
0644
edit
dl
rm
autoconf-smpcall-5args.c
169
0644
edit
dl
rm
autoconf-stack-trace-save-regs.c
176
0644
edit
dl
rm
autoconf-stacktrace_ops-int-address.c
409
0644
edit
dl
rm
autoconf-stacktrace_ops-warning.c
188
0644
edit
dl
rm
autoconf-syscall_get_args_3args.c
239
0644
edit
dl
rm
autoconf-task-state.c
550
0644
edit
dl
rm
autoconf-task-uid.c
152
0644
edit
dl
rm
autoconf-task_work-struct.c
219
0644
edit
dl
rm
autoconf-time32-old.c
52
0644
edit
dl
rm
autoconf-time32.c
53
0644
edit
dl
rm
autoconf-timerfd.c
232
0644
edit
dl
rm
autoconf-trace-printk.c
151
0644
edit
dl
rm
autoconf-tracepoint-has-data.c
493
0644
edit
dl
rm
autoconf-tracepoint-strings.c
233
0644
edit
dl
rm
autoconf-uaccess.c
28
0644
edit
dl
rm
autoconf-uapi-mount.c
52
0644
edit
dl
rm
autoconf-udelay_simple.c
90
0644
edit
dl
rm
autoconf-uidgid.c
50
0644
edit
dl
rm
autoconf-unwind-stack-trace.c
326
0644
edit
dl
rm
autoconf-uprobe-get-pc.c
374
0644
edit
dl
rm
autoconf-utrace-regset.c
273
0644
edit
dl
rm
autoconf-utrace-via-tracepoints.c
1712
0644
edit
dl
rm
autoconf-vm-area-pte.c
141
0644
edit
dl
rm
autoconf-walk-stack.c
217
0644
edit
dl
rm
autoconf-x86-fs.c
90
0644
edit
dl
rm
autoconf-x86-gs.c
90
0644
edit
dl
rm
autoconf-x86-uniregs.c
140
0644
edit
dl
rm
autoconf-x86-xfs.c
91
0644
edit
dl
rm
common_session_state.h
3249
0644
edit
dl
rm
compat_net.h
858
0644
edit
dl
rm
compat_structs.h
4409
0644
edit
dl
rm
compat_unistd.h
68384
0644
edit
dl
rm
copy.c
2717
0644
edit
dl
rm
debug.h
2978
0644
edit
dl
rm
io.c
5291
0644
edit
dl
rm
itrace.c
14874
0644
edit
dl
rm
kprobes.c
25126
0644
edit
dl
rm
loc2c-runtime.h
29874
0644
edit
dl
rm
map_list.h
1220
0644
edit
dl
rm
map_runtime.h
5266
0644
edit
dl
rm
namespaces.h
7128
0644
edit
dl
rm
netfilter.c
1410
0644
edit
dl
rm
perf.c
7596
0644
edit
dl
rm
perf.h
1272
0644
edit
dl
rm
perf_event_counter_context.c
336
0644
edit
dl
rm
perf_probe_handler_nmi.c
278
0644
edit
dl
rm
perf_read.h
959
0644
edit
dl
rm
print.c
11402
0644
edit
dl
rm
probe_lock.h
1807
0644
edit
dl
rm
regs-ia64.c
3741
0644
edit
dl
rm
regs.c
13490
0644
edit
dl
rm
runtime.h
12591
0644
edit
dl
rm
runtime_context.h
6089
0644
edit
dl
rm
runtime_defines.h
1041
0644
edit
dl
rm
stap_mmap_lock.h
343
0644
edit
dl
rm
stat_runtime.h
1774
0644
edit
dl
rm
stp_tls.h
1181
0644
edit
dl
rm
stp_tracepoint.c
11481
0644
edit
dl
rm
stp_tracepoint.h
2270
0644
edit
dl
rm
syscalls-common.h
976
0644
edit
dl
rm
task_finder.c
53860
0644
edit
dl
rm
task_finder2.c
57640
0644
edit
dl
rm
task_finder_map.c
5194
0644
edit
dl
rm
task_finder_stubs.c
2442
0644
edit
dl
rm
task_work_compatibility.h
1283
0644
edit
dl
rm
timer.c
2200
0644
edit
dl
rm
timer.h
1383
0644
edit
dl
rm
timer_compatibility.h
2317
0644
edit
dl
rm
uprobes-common.c
15573
0644
edit
dl
rm
uprobes-common.h
1653
0644
edit
dl
rm
uprobes-inc.h
484
0644
edit
dl
rm
uprobes-inode.c
34086
0644
edit
dl
rm
Edit:
/usr/share/systemtap/runtime/linux/addr-map.c
(9749B)
/* -*- linux-c -*- * Map of addresses to disallow. * Copyright (C) 2005-2019 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 _STAPLINUX_ADDR_MAP_C_ #define _STAPLINUX_ADDR_MAP_C_ 1 /** @file addr-map * @brief Implements functions used by the deref macro to blocklist * certain addresses. */ // PR12970 (populate runtime/bad-addr database) hasn't been // fixed. Until we're ready to populate the bad address database, // let's provide a "junior" version of lookup_bad_addr(), since that // will allow us to skip grabbing the lock and searching the empty // list. // // See <https://sourceware.org/bugzilla/show_bug.cgi?id=12970> for // more details. #include <linux/uaccess.h> #ifndef PR12970 #if ! STP_PRIVILEGE_CONTAINS (STP_PRIVILEGE, STP_PR_STAPDEV) && \ ! STP_PRIVILEGE_CONTAINS (STP_PRIVILEGE, STP_PR_STAPSYS) #include <asm/processor.h> /* For TASK_SIZE */ #endif #ifdef STAPCONF_ACCESS_OK_2ARGS #define stp_access_ok(x,y,z) access_ok(y,z) #else #define stp_access_ok(x,y,z) access_ok(x,y,z) #endif static int lookup_bad_addr_user(const int type, const unsigned long addr, const size_t size) { /* Is this a valid memory access? * * Note we're using stp_access_ok() here. This is only supposed to be * called when we're in task context. Occasionally lookup_bad_addr() * gets called when not in task context. If in_task() exists, only * call stp_access_ok() when we're in task context (otherwise we'll get * a kernel warning). If we aren't in task context, we'll just do a * range check. */ #if !defined(in_task) if (size == 0 || ULONG_MAX - addr < size - 1 || !stp_access_ok(type, (void *)addr, size)) return 1; #else if (size == 0 || ULONG_MAX - addr < size - 1 || (in_task() && !stp_access_ok(type, (void *)addr, size)) || (!in_task() #if defined(user_addr_max) && ((user_addr_max() - size) < addr) #endif )) return 1; #endif #if ! STP_PRIVILEGE_CONTAINS (STP_PRIVILEGE, STP_PR_STAPDEV) && \ ! STP_PRIVILEGE_CONTAINS (STP_PRIVILEGE, STP_PR_STAPSYS) /* Unprivileged users must not access memory while the context does not refer to their own process. */ if (! is_myproc ()) return 1; /* Unprivileged users must not access kernel space memory. */ if (addr + size > TASK_SIZE) return 1; #endif return 0; } static int lookup_bad_addr(const int type, const unsigned long addr, const size_t size, const stp_mm_segment_t seg) { #ifndef STAPCONF_SET_FS /* Is this a valid memory access? * * PR26811: Since kernel 5.10 due to set_fs() removal we need to * distinguish kernel- and user-space addresses when asking this * question. */ if (!MM_SEG_IS_KERNEL(seg)) return lookup_bad_addr_user(type, addr, size); /* For kernel addr, skip the in_task() portion of the address checks: */ if (size == 0 || ULONG_MAX - addr < size - 1) return 1; /* XXX: Kernel reads call copy_from_kernel_nofault() which also checks copy_from_kernel_fault_allowed(), currently a stub function returning true -- not worth invoking ourselves through kallsyms. Keep an eye on this, though. */ #if ! STP_PRIVILEGE_CONTAINS (STP_PRIVILEGE, STP_PR_STAPDEV) && \ ! STP_PRIVILEGE_CONTAINS (STP_PRIVILEGE, STP_PR_STAPSYS) /* Unprivileged users must not access memory while the context does not refer to their own process. */ if (! is_myproc ()) return 1; /* Unprivileged users must not access kernel space memory. */ if (addr + size > TASK_SIZE) return 1; #endif return 0; #else /* XXX: On earlier kernels the same logic works for kernel-space: */ return lookup_bad_addr_user(type, addr, size); #endif } #else /* PR12970 */ struct addr_map_entry { unsigned long min; unsigned long max; }; struct addr_map { size_t size; struct addr_map_entry entries[0]; }; static STP_DEFINE_RWLOCK(addr_map_lock); static struct addr_map* blockmap; /* Find address of entry where we can insert a new one. */ static size_t upper_bound(unsigned long addr, struct addr_map* map) { size_t start = 0; size_t end = map->size; struct addr_map_entry *entry = 0; if (end == 0) return 0; do { size_t new_idx; if (addr < map->entries[start].min) return start; if (addr >= map->entries[end-1].max) return end; new_idx = (end + start) / 2; entry = &map->entries[new_idx]; if (addr < entry->min) end = new_idx; else start = new_idx + 1; } while (end != start); return entry - &map->entries[0]; } /* Search for an entry in the given map which overlaps the range specified by addr and size. */ static struct addr_map_entry* lookup_addr_aux(unsigned long addr, size_t size, struct addr_map* map) { size_t start = 0; size_t end; /* No map? No matching entry. */ if (!map) return 0; /* Empty map? No matching entry. */ if (map->size == 0) return 0; /* Use binary search on the sorted map entries. */ end = map->size; do { int entry_idx; struct addr_map_entry *entry = 0; /* If the target range is beyond those of the remaining entries in the map, then a matching entry will not be found */ if (addr + size <= map->entries[start].min || addr >= map->entries[end - 1].max) return 0; /* Choose the map entry at the mid point of the remaining entries. */ entry_idx = (end + start) / 2; entry = &map->entries[entry_idx]; /* If our range overlaps the range of this entry, then we have a match. */ if (addr + size > entry->min && addr < entry->max) return entry; /* If our range is below the range of this entry, then cull the entries above this entry, otherwise cull the entries below it. */ if (addr + size <= entry->min) end = entry_idx; else start = entry_idx + 1; } while (start < end); return 0; } #if ! STP_PRIVILEGE_CONTAINS (STP_PRIVILEGE, STP_PR_STAPDEV) && \ ! STP_PRIVILEGE_CONTAINS (STP_PRIVILEGE, STP_PR_STAPSYS) #include <asm/processor.h> /* For TASK_SIZE */ #endif static int lookup_bad_addr(const int type, const unsigned long addr, const size_t size) { struct addr_map_entry* result = 0; unsigned long flags; /* Is this a valid memory access? */ if (size == 0 || ULONG_MAX - addr < size - 1 || !stp_access_ok(type, (void *)addr, size)) return 1; #if ! STP_PRIVILEGE_CONTAINS (STP_PRIVILEGE, STP_PR_STAPDEV) && \ ! STP_PRIVILEGE_CONTAINS (STP_PRIVILEGE, STP_PR_STAPSYS) /* Unprivileged users must not access memory while the context does not refer to their own process. */ if (! is_myproc ()) return 1; /* Unprivileged users must not access kernel space memory. */ if (addr + size > TASK_SIZE) return 1; #endif /* Search for the given range in the block-listed map. */ stp_read_lock_irqsave(&addr_map_lock, flags); result = lookup_addr_aux(addr, size, blockmap); stp_read_unlock_irqrestore(&addr_map_lock, flags); if (result) return 1; else return 0; } static int add_bad_addr_entry(unsigned long min_addr, unsigned long max_addr, struct addr_map_entry** existing_min, struct addr_map_entry** existing_max) { struct addr_map* new_map = 0; struct addr_map* old_map = 0; struct addr_map_entry* min_entry = 0; struct addr_map_entry* max_entry = 0; struct addr_map_entry* new_entry = 0; size_t existing = 0; unsigned long flags; /* Loop allocating memory for a new entry in the map. */ while (1) { size_t old_size = 0; stp_write_lock_irqsave(&addr_map_lock, flags); old_map = blockmap; if (old_map) old_size = old_map->size; /* Either this is the first time through the loop, or we allocated a map previous time, but someone has come in and added an entry while we were sleeping. */ if (!new_map || (new_map && new_map->size < old_size + 1)) { stp_write_unlock_irqrestore(&addr_map_lock, flags); if (new_map) { _stp_kfree(new_map); new_map = 0; } new_map = _stp_kmalloc(sizeof(*new_map) + sizeof(*new_entry) * (old_size + 1)); if (!new_map) return -ENOMEM; new_map->size = old_size + 1; } else break; } if (!blockmap) { existing = 0; } else { min_entry = lookup_addr_aux(min_addr, 1, blockmap); max_entry = lookup_addr_aux(max_addr, 1, blockmap); if (min_entry || max_entry) { if (existing_min) *existing_min = min_entry; if (existing_max) *existing_max = max_entry; stp_write_unlock_irqrestore(&addr_map_lock, flags); _stp_kfree(new_map); return 1; } existing = upper_bound(min_addr, old_map); } new_entry = &new_map->entries[existing]; new_entry->min = min_addr; new_entry->max = max_addr; if (old_map) { memcpy(&new_map->entries, old_map->entries, existing * sizeof(*new_entry)); if (old_map->size > existing) memcpy(new_entry + 1, &old_map->entries[existing], (old_map->size - existing) * sizeof(*new_entry)); } blockmap = new_map; stp_write_unlock_irqrestore(&addr_map_lock, flags); if (old_map) _stp_kfree(old_map); return 0; } static void delete_bad_addr_entry(struct addr_map_entry* entry) { } #endif /* PR12970 */ #endif /* _STAPLINUX_ADDR_MAP_C_ */
Save
cmd:
run