summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-03-13 16:22:04 -0700
committerJosh Stone <jistone@redhat.com>2009-03-13 16:22:04 -0700
commit436b47f678c2fc5397ed66a1eddf6b419cc6585b (patch)
tree372c838479af953282cc03ce6cc0f3801a629168
parent52aeb26b8d83c26e00adaf70bbf5a3a828689fb2 (diff)
downloadsystemtap-steved-436b47f678c2fc5397ed66a1eddf6b419cc6585b.tar.gz
systemtap-steved-436b47f678c2fc5397ed66a1eddf6b419cc6585b.tar.xz
systemtap-steved-436b47f678c2fc5397ed66a1eddf6b419cc6585b.zip
Move lookup_bad_addr call in STAPCONF_PROBE_KERNEL
With most of the implementations, kread/kwrite call deref/store_deref, and so it makes sense to have lookup_bad_addr in the latter as an underlying address check. However, in the STAPCONF_PROBE_KERNEL case that uses probe_kernel_read and probe_kernel_write, the roles are reversed, so lookup_bad_addr needs to be in kread/kwrite. Also note that __deref_bad and __store_deref_bad should only be used in cases that can be determined at compile time. These turn into invalid symbols which prevent the module from loading. (They might be better replaced with compile-time assertions.)
-rw-r--r--runtime/loc2c-runtime.h14
1 files changed, 6 insertions, 8 deletions
diff --git a/runtime/loc2c-runtime.h b/runtime/loc2c-runtime.h
index 0af19edc..92c017d3 100644
--- a/runtime/loc2c-runtime.h
+++ b/runtime/loc2c-runtime.h
@@ -187,22 +187,22 @@
#define kread(ptr) ({ \
typeof(*(ptr)) _v; \
- if (probe_kernel_read((void *)&_v, (void *)(ptr), sizeof(*(ptr)))) \
- DEREF_FAULT(ptr); \
+ if (lookup_bad_addr((unsigned long)(ptr)) || \
+ probe_kernel_read((void *)&_v, (void *)(ptr), sizeof(*(ptr)))) \
+ DEREF_FAULT(ptr); \
_v; \
})
#define kwrite(ptr, value) ({ \
typeof(*(ptr)) _v; \
_v = (typeof(*(ptr)))(value); \
- if (probe_kernel_write((void *)(ptr), (void *)&_v, sizeof(*(ptr)))) \
- STORE_DEREF_FAULT(ptr); \
+ if (lookup_bad_addr((unsigned long)addr) || \
+ probe_kernel_write((void *)(ptr), (void *)&_v, sizeof(*(ptr)))) \
+ STORE_DEREF_FAULT(ptr); \
})
#define deref(size, addr) ({ \
intptr_t _i; \
- if (lookup_bad_addr((unsigned long)addr)) \
- __deref_bad(); \
switch (size) { \
case 1: _i = kread((u8 *)(addr)); break; \
case 2: _i = kread((u16 *)(addr)); break; \
@@ -215,8 +215,6 @@
})
#define store_deref(size, addr, value) ({ \
- if (lookup_bad_addr((unsigned long)addr)) \
- __store_deref_bad(); \
switch (size) { \
case 1: kwrite((u8 *)(addr), (value)); break; \
case 2: kwrite((u16 *)(addr), (value)); break; \