1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3# description: Fprobe event parser error log check 4# requires: dynamic_events "f[:[<group>/][<event>]] <func-name>[%return] [<args>]":README 5 6check_error() { # command-with-error-pos-by-^ 7 ftrace_errlog_check 'trace_fprobe' "$1" 'dynamic_events' 8} 9 10case `uname -m` in 11x86_64|i[3456]86) 12 REG=%ax ;; 13aarch64) 14 REG=%x0 ;; 15*) 16 REG=%r0 ;; 17esac 18 19check_error 'f^100 vfs_read' # MAXACT_NO_KPROBE 20check_error 'f^1a111 vfs_read' # BAD_MAXACT 21check_error 'f^100000 vfs_read' # MAXACT_TOO_BIG 22 23check_error 'f ^non_exist_func' # BAD_PROBE_ADDR (enoent) 24check_error 'f ^vfs_read+10' # BAD_PROBE_ADDR 25check_error 'f:^/bar vfs_read' # NO_GROUP_NAME 26check_error 'f:^12345678901234567890123456789012345678901234567890123456789012345/bar vfs_read' # GROUP_TOO_LONG 27 28check_error 'f:^foo.1/bar vfs_read' # BAD_GROUP_NAME 29check_error 'f:^ vfs_read' # NO_EVENT_NAME 30check_error 'f:foo/^12345678901234567890123456789012345678901234567890123456789012345 vfs_read' # EVENT_TOO_LONG 31check_error 'f:foo/^bar.1 vfs_read' # BAD_EVENT_NAME 32 33check_error 'f vfs_read ^$stack10000' # BAD_STACK_NUM 34 35check_error 'f vfs_read ^$arg10000' # BAD_ARG_NUM 36 37if !grep -q 'kernel return probes support:' README; then 38check_error 'f vfs_read $retval ^$arg1' # BAD_VAR 39fi 40check_error 'f vfs_read ^$none_var' # BAD_VAR 41check_error 'f vfs_read ^'$REG # BAD_VAR 42 43check_error 'f vfs_read ^@12345678abcde' # BAD_MEM_ADDR 44check_error 'f vfs_read ^@+10' # FILE_ON_KPROBE 45 46grep -q "imm-value" README && \ 47check_error 'f vfs_read arg1=\^x' # BAD_IMM 48grep -q "imm-string" README && \ 49check_error 'f vfs_read arg1=\"abcd^' # IMMSTR_NO_CLOSE 50 51check_error 'f vfs_read ^+0@0)' # DEREF_NEED_BRACE 52check_error 'f vfs_read ^+0ab1(@0)' # BAD_DEREF_OFFS 53check_error 'f vfs_read +0(+0(@0^)' # DEREF_OPEN_BRACE 54 55if grep -A1 "fetcharg:" README | grep -q '\$comm' ; then 56check_error 'f vfs_read +0(^$comm)' # COMM_CANT_DEREF 57fi 58 59check_error 'f vfs_read ^&1' # BAD_FETCH_ARG 60 61 62# We've introduced this limitation with array support 63if grep -q ' <type>\\\[<array-size>\\\]' README; then 64check_error 'f vfs_read +0(^+0(+0(+0(+0(+0(+0(+0(+0(+0(+0(+0(+0(+0(@0))))))))))))))' # TOO_MANY_OPS? 65check_error 'f vfs_read +0(@11):u8[10^' # ARRAY_NO_CLOSE 66check_error 'f vfs_read +0(@11):u8[10]^a' # BAD_ARRAY_SUFFIX 67check_error 'f vfs_read +0(@11):u8[^10a]' # BAD_ARRAY_NUM 68check_error 'f vfs_read +0(@11):u8[^256]' # ARRAY_TOO_BIG 69fi 70 71check_error 'f vfs_read @11:^unknown_type' # BAD_TYPE 72check_error 'f vfs_read $stack0:^string' # BAD_STRING 73check_error 'f vfs_read @11:^b10@a/16' # BAD_BITFIELD 74 75check_error 'f vfs_read ^arg123456789012345678901234567890=@11' # ARG_NAME_TOO_LOG 76check_error 'f vfs_read ^=@11' # NO_ARG_NAME 77check_error 'f vfs_read ^var.1=@11' # BAD_ARG_NAME 78check_error 'f vfs_read var1=@11 ^var1=@12' # USED_ARG_NAME 79check_error 'f vfs_read ^+1234567(+1234567(+1234567(+1234567(+1234567(+1234567(@1234))))))' # ARG_TOO_LONG 80check_error 'f vfs_read arg1=^' # NO_ARG_BODY 81 82 83# multiprobe errors 84if grep -q "Create/append/" README && grep -q "imm-value" README; then 85echo "f:fprobes/testevent $FUNCTION_FORK" > dynamic_events 86check_error '^f:fprobes/testevent do_exit%return' # DIFF_PROBE_TYPE 87 88# Explicitly use printf "%s" to not interpret \1 89printf "%s" "f:fprobes/testevent $FUNCTION_FORK abcd=\\1" > dynamic_events 90check_error "f:fprobes/testevent $FUNCTION_FORK ^bcd=\\1" # DIFF_ARG_TYPE 91check_error "f:fprobes/testevent $FUNCTION_FORK ^abcd=\\1:u8" # DIFF_ARG_TYPE 92check_error "f:fprobes/testevent $FUNCTION_FORK ^abcd=\\\"foo\"" # DIFF_ARG_TYPE 93check_error "^f:fprobes/testevent $FUNCTION_FORK abcd=\\1" # SAME_PROBE 94fi 95 96# %return suffix errors 97check_error 'f vfs_read^%hoge' # BAD_ADDR_SUFFIX 98 99# BTF arguments errors 100if grep -q "<argname>" README; then 101check_error 'f vfs_read args=^$arg*' # BAD_VAR_ARGS 102check_error 'f vfs_read +0(^$arg*)' # BAD_VAR_ARGS 103check_error 'f vfs_read $arg* ^$arg*' # DOUBLE_ARGS 104if !grep -q 'kernel return probes support:' README; then 105check_error 'f vfs_read%return ^$arg*' # NOFENTRY_ARGS 106fi 107check_error 'f vfs_read ^hoge' # NO_BTFARG 108check_error 'f kfree ^$arg10' # NO_BTFARG (exceed the number of parameters) 109check_error 'f kfree%return ^$retval' # NO_RETVAL 110 111if grep -qF "<argname>[->field[->field|.field...]]" README ; then 112check_error 'f vfs_read%return $retval->^foo' # NO_PTR_STRCT 113check_error 'f vfs_read file->^foo' # NO_BTF_FIELD 114check_error 'f vfs_read file^-.foo' # BAD_HYPHEN 115check_error 'f vfs_read ^file:string' # BAD_TYPE4STR 116fi 117 118else 119check_error 'f vfs_read ^$arg*' # NOSUP_BTFARG 120check_error 't kfree ^$arg*' # NOSUP_BTFARG 121fi 122 123exit 0 124