}
/* kernel 4.17+ */
-probe nd2_syscall.close = kprobe.function("__*_sys_close") /* _x64_ etc. */
+probe nd2_syscall.close = kprobe.function(@arch_syscall_prefix "sys_close") ?
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_CLOSE_NAME
}
/* kernel 4.17+ */
-probe nd2_syscall.close.return = kprobe.function("__*_sys_close").return /* _x64_ etc. */
+probe nd2_syscall.close.return = kprobe.function(@arch_syscall_prefix "sys_close").return ?
{
@_SYSCALL_CLOSE_NAME
retstr = returnstr(1) /* NB: not in the $regs */
@_SYSCALL_CREAT_ARGSTR
}
-probe nd2_syscall.creat = kprobe.function("__*_sys_creat") /* _x64_ etc. */
+probe nd2_syscall.creat = kprobe.function(@arch_syscall_prefix "sys_creat") ?
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_CREAT_NAME
}
/* kernel 4.17+ */
-probe nd2_syscall.creat.return = kprobe.function("__*_sys_creat").return /* _x64_ etc. */
+probe nd2_syscall.creat.return = kprobe.function(@arch_syscall_prefix "sys_creat").return ?
{
@_SYSCALL_CREAT_NAME
retstr = returnstr(1) /* NB: not in the $regs */
@_SYSCALL_OPEN_ARGSTR
}
-probe nd2_syscall.open = kprobe.function("__*_sys_open") /* _x64_ etc. */
+probe nd2_syscall.open = kprobe.function(@arch_syscall_prefix "compat_sys_open") ?,
+ kprobe.function(@arch_syscall_prefix "sys32_open") ?,
+ kprobe.function(@arch_syscall_prefix "sys_open") ?
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_OPEN_NAME
}
/* kernel 4.17+ */
-probe nd2_syscall.open.return = kprobe.function("__*_sys_open").return /* _x64_ etc. */
+probe nd2_syscall.open.return = kprobe.function(@arch_syscall_prefix "compat_sys_open").return ?,
+ kprobe.function(@arch_syscall_prefix "sys32_open").return ?,
+ kprobe.function(@arch_syscall_prefix "sys_open").return ?
{
@_SYSCALL_OPEN_NAME
retstr = returnstr(1) /* NB: not in the $regs */
}
/* kernel 4.17+ */
-probe nd2_syscall.openat = kprobe.function("__*_sys_openat") /* _x64_ etc. */
+probe nd2_syscall.openat = kprobe.function(@arch_syscall_prefix "compat_sys_openat") ?,
+ kprobe.function(@arch_syscall_prefix "sys_openat") ?
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_OPENAT_NAME
}
/* kernel 4.17+ */
-probe nd2_syscall.openat.return = kprobe.function("__*_sys_openat").return /* _x64_ etc. */
+probe nd2_syscall.openat.return = kprobe.function(@arch_syscall_prefix "compat_sys_openat").return ?,
+ kprobe.function(@arch_syscall_prefix "sys_openat").return ?
{
@_SYSCALL_OPENAT_NAME
retstr = returnstr(1) /* NB: not in the $regs */
probe nd_syscall.read = nd1_syscall.read!, nd2_syscall.read!, tp_syscall.read
{ }
-
probe nd1_syscall.read =
%( arch == "s390" %?
__nd1_syscall.read, kprobe.function("sys32_read") ?,
%)
}
-
/* kernel 4.17+ */
-probe nd2_syscall.read = kprobe.function("__*_sys_read") /* _x64_ etc. */
+probe nd2_syscall.read = kprobe.function(@arch_syscall_prefix "sys_read")
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_READ_NAME
@_SYSCALL_READ_ARGSTR
}
-
-
probe nd_syscall.read.return = nd1_syscall.read.return!, nd2_syscall.read.return!, tp_syscall.read.return
{ }
-
-
probe nd1_syscall.read.return =
%( arch == "s390" %?
%)
}
-
/* kernel 4.17+ */
-probe nd2_syscall.read.return = kprobe.function("__*_sys_read").return /* _x64_ etc. */
+probe nd2_syscall.read.return = kprobe.function(@arch_syscall_prefix "sys_read").return
{
@_SYSCALL_READ_NAME
retstr = returnstr(1) /* NB: not in the $regs */
}
-
-
+
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.read.return = kernel.trace("sys_exit")
{
}
/* kernel 4.17+ */
-probe nd2_syscall.write = kprobe.function("__*_sys_write") /* _x64_ etc. */
+probe nd2_syscall.write = kprobe.function(@arch_syscall_prefix "sys_write")
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_WRITE_NAME
}
/* kernel 4.17+ */
-probe nd2_syscall.write.return = kprobe.function("__*_sys_write").return /* _x64_ etc. */
+probe nd2_syscall.write.return = kprobe.function(@arch_syscall_prefix "sys_write").return
{
@_SYSCALL_WRITE_NAME
retstr = returnstr(1) /* NB: not in the $regs */
--- /dev/null
+@define arch_syscall_prefix %( "__{ia32,x64}_" %)
vector<interned_string> matches;
// Simple names can be found directly
- if (function_string_val.find_first_of("*?[") == string::npos)
+ if (function_string_val.find_first_of("*?[{") == string::npos)
{
if (sess.kernel_functions.count(function_string_val))
matches.push_back(function_string_val);
}
else // Search function name list for matching names
{
- const string& val = function_string_val;
+ const string& val = csh_to_ksh(function_string_val);
for (auto it = sess.kernel_functions.cbegin();
it != sess.kernel_functions.cend(); it++)
{
// fnmatch returns zero for matching.
- if (fnmatch(val.c_str(), it->to_string().c_str(), 0) == 0)
+ if (fnmatch(val.c_str(), it->to_string().c_str(), FNM_EXTMATCH) == 0)
matches.push_back(*it);
}
}
return op;
}
+// PR23391, this is still incomplete but enough is
+// complete to handle "__{ia32,x64}_sys_$syscall"
+// functions.
+string csh_to_ksh (const string& csh)
+{
+ string ksh;
+ for (unsigned i=0; i<csh.size(); i++)
+ {
+ if (csh[i] == '{')
+ ksh += "@(";
+ else if (csh[i] == '}')
+ ksh += ')';
+ else if (csh[i] == ',')
+ ksh += '|';
+ else
+ ksh += csh[i];
+ }
+ return ksh;
+}
+
bool identifier_string_needs_escape (const string& str)
{
for (unsigned i = 0; i < str.size (); i++)
bool contains_glob_chars (const std::string &str);
std::string escape_glob_chars (const std::string& str);
std::string unescape_glob_chars (const std::string& str);
+std::string csh_to_ksh (const std::string& csh);
bool identifier_string_needs_escape (const std::string& str);
std::string escaped_identifier_string (const std::string& str);
std::string escaped_character (unsigned c);