.. | .. |
---|
87 | 87 | # define F_LINUX_SPECIFIC_BASE 1024 |
---|
88 | 88 | #endif |
---|
89 | 89 | |
---|
| 90 | +#define RAW_SYSCALL_ARGS_NUM 6 |
---|
| 91 | + |
---|
90 | 92 | /* |
---|
91 | 93 | * strtoul: Go from a string to a value, i.e. for msr: MSR_FS_BASE to 0xc0000100 |
---|
92 | 94 | */ |
---|
.. | .. |
---|
107 | 109 | const char *sys_enter, |
---|
108 | 110 | *sys_exit; |
---|
109 | 111 | } bpf_prog_name; |
---|
110 | | - struct syscall_arg_fmt arg[6]; |
---|
| 112 | + struct syscall_arg_fmt arg[RAW_SYSCALL_ARGS_NUM]; |
---|
111 | 113 | u8 nr_args; |
---|
112 | 114 | bool errpid; |
---|
113 | 115 | bool timeout; |
---|
.. | .. |
---|
1216 | 1218 | */ |
---|
1217 | 1219 | struct bpf_map_syscall_entry { |
---|
1218 | 1220 | bool enabled; |
---|
1219 | | - u16 string_args_len[6]; |
---|
| 1221 | + u16 string_args_len[RAW_SYSCALL_ARGS_NUM]; |
---|
1220 | 1222 | }; |
---|
1221 | 1223 | |
---|
1222 | 1224 | /* |
---|
.. | .. |
---|
1641 | 1643 | { |
---|
1642 | 1644 | int idx; |
---|
1643 | 1645 | |
---|
1644 | | - if (nr_args == 6 && sc->fmt && sc->fmt->nr_args != 0) |
---|
| 1646 | + if (nr_args == RAW_SYSCALL_ARGS_NUM && sc->fmt && sc->fmt->nr_args != 0) |
---|
1645 | 1647 | nr_args = sc->fmt->nr_args; |
---|
1646 | 1648 | |
---|
1647 | 1649 | sc->arg_fmt = calloc(nr_args, sizeof(*sc->arg_fmt)); |
---|
.. | .. |
---|
1774 | 1776 | #endif |
---|
1775 | 1777 | sc = trace->syscalls.table + id; |
---|
1776 | 1778 | if (sc->nonexistent) |
---|
1777 | | - return 0; |
---|
| 1779 | + return -EEXIST; |
---|
1778 | 1780 | |
---|
1779 | 1781 | if (name == NULL) { |
---|
1780 | 1782 | sc->nonexistent = true; |
---|
1781 | | - return 0; |
---|
| 1783 | + return -EEXIST; |
---|
1782 | 1784 | } |
---|
1783 | 1785 | |
---|
1784 | 1786 | sc->name = name; |
---|
.. | .. |
---|
1792 | 1794 | sc->tp_format = trace_event__tp_format("syscalls", tp_name); |
---|
1793 | 1795 | } |
---|
1794 | 1796 | |
---|
1795 | | - if (syscall__alloc_arg_fmts(sc, IS_ERR(sc->tp_format) ? 6 : sc->tp_format->format.nr_fields)) |
---|
1796 | | - return -ENOMEM; |
---|
1797 | | - |
---|
1798 | | - if (IS_ERR(sc->tp_format)) |
---|
| 1797 | + /* |
---|
| 1798 | + * Fails to read trace point format via sysfs node, so the trace point |
---|
| 1799 | + * doesn't exist. Set the 'nonexistent' flag as true. |
---|
| 1800 | + */ |
---|
| 1801 | + if (IS_ERR(sc->tp_format)) { |
---|
| 1802 | + sc->nonexistent = true; |
---|
1799 | 1803 | return PTR_ERR(sc->tp_format); |
---|
| 1804 | + } |
---|
| 1805 | + |
---|
| 1806 | + if (syscall__alloc_arg_fmts(sc, IS_ERR(sc->tp_format) ? |
---|
| 1807 | + RAW_SYSCALL_ARGS_NUM : sc->tp_format->format.nr_fields)) |
---|
| 1808 | + return -ENOMEM; |
---|
1800 | 1809 | |
---|
1801 | 1810 | sc->args = sc->tp_format->format.fields; |
---|
1802 | 1811 | /* |
---|
.. | .. |
---|
2114 | 2123 | (err = trace__read_syscall_info(trace, id)) != 0) |
---|
2115 | 2124 | goto out_cant_read; |
---|
2116 | 2125 | |
---|
2117 | | - if (trace->syscalls.table[id].name == NULL) { |
---|
2118 | | - if (trace->syscalls.table[id].nonexistent) |
---|
2119 | | - return NULL; |
---|
| 2126 | + if (trace->syscalls.table && trace->syscalls.table[id].nonexistent) |
---|
2120 | 2127 | goto out_cant_read; |
---|
2121 | | - } |
---|
2122 | 2128 | |
---|
2123 | 2129 | return &trace->syscalls.table[id]; |
---|
2124 | 2130 | |
---|