kernel/trace/trace_kprobe.c:974:17: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior
Hi Tom,
Below is a report from a 0day bot build w/ Clang, can you please take a look? (Apologies if this has been previously reported). In the past, -Wvarargs warnings are usually related to the last parameter of a va_arg function undergoing implicit promotion (which is explicitly UB, IIRC).
Quoted 107 lines · kbuild test robot
CC: kbuild-all(a)lists.01.org
TO: Tom Zanussi <[email protected]>tree: https://git.kernel.org/pub/scm/linux/kernel/git/zanussi/linux-trace.git ftrace/synth-event-gen-v2 head: 91ee64186d5894724e276c4e7fad70446d7a02a7 commit: 5f052546541d6cc5ad00e28aca6376c221db5c7e [10/12] tracing: Add kprobe event command generation functions config: x86_64-defconfig (attached as .config) compiler: clang version 10.0.0 (git://gitmirror/llvm_project 016bf03ef6fcd9dce43b0c17971f76323f07a684) reproduce: git checkout 5f052546541d6cc5ad00e28aca6376c221db5c7e # save the attached .config to linux build tree make ARCH=x86_64If you fix the issue, kindly add following tag
Reported-by kbuild test robot <[email protected]>All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
kernel/trace/trace_kprobe.c:974:17: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Wvarargs]va_start(args, kretprobe); ^
kernel/trace/trace_kprobe.c:947:30: note: parameter of type 'bool' (aka '_Bool') is declared here
const char *loc, bool kretprobe, ...)
^
1 warning generated.vim +/va_start +974
kernel/trace/trace_kprobe.c925 926 /** 927 * __gen_kprobe_cmd - Generate a synthetic event command from arg list 928 * @cmd: A pointer to the dynevent_cmd struct representing the new event 929 * @name: The name of the kprobe event 930 * @loc: The location of the kprobe event 931 * @kretprobe: Is this a return probe? 932 * @args: Variable number of arg (pairs), one pair for each field 933 * 934 * NOTE: Users normally won't want to call this function directly, but 935 * rather use the gen_kprobe_cmd() wrapper, which automatically adds a 936 * NULL to the end of the arg list. If this function is used 937 * directly, make suer he last arg in the variable arg list is NULL. 938 * 939 * Generate a kprobe event command to be executed by 940 * create_dynevent(). This function can be used to generate the 941 * complete command or only the first part of it; in the latter case, 942 * add_probe_fields() can be used to add more fields following this. 943 * 944 * Return: 0 if successful, error otherwise. 945 */ 946 int __gen_kprobe_cmd(struct dynevent_cmd *cmd, const char *name, 947 const char *loc, bool kretprobe, ...) 948 { 949 char buf[MAX_EVENT_NAME_LEN]; 950 struct dynevent_arg arg; 951 va_list args; 952 int ret; 953 954 if (cmd->type != DYNEVENT_TYPE_KPROBE) 955 return -EINVAL; 956 957 if (kretprobe) 958 snprintf(buf, MAX_EVENT_NAME_LEN, "r:%s", name); 959 else 960 snprintf(buf, MAX_EVENT_NAME_LEN, "p:%s", name); 961 962 dynevent_arg_init(&arg, NULL, 0); 963 arg.str = buf; 964 ret = add_dynevent_arg(cmd, &arg); 965 if (ret) 966 return ret; 967 968 dynevent_arg_init(&arg, NULL, 0); 969 arg.str = loc; 970 ret = add_dynevent_arg(cmd, &arg); 971 if (ret) 972 return ret; 973Quoted 1 line
974
va_start(args, kretprobe);975 for (;;) { 976 const char *field; 977 978 field = va_arg(args, const char *); 979 if (!field) 980 break; 981 982 if (++cmd->n_fields > MAX_TRACE_ARGS) { 983 ret = -EINVAL; 984 break; 985 } 986 987 dynevent_arg_init(&arg, NULL, 0); 988 arg.str = field; 989 ret = add_dynevent_arg(cmd, &arg); 990 if (ret) 991 break; 992 } 993 va_end(args); 994 995 return ret; 996 } 997 EXPORT_SYMBOL_GPL(__gen_kprobe_cmd); 998---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
Signature · 2 lines
Thanks, ~Nick Desaulniers
Hi Nick,
Quoted 7 lines · Nick Desaulniers
Hi Tom,
Below is a report from a 0day bot build w/ Clang, can you please take a look? (Apologies if this has been previously reported). In the past, -Wvarargs warnings are usually related to the last parameter of ava_argfunction undergoing implicit promotion (which is explicitly UB, IIRC).
OK, looks like just changing the param order should fix it, thanks for the report.
Tom
Quoted 134 lines
Quoted 129 lines · kbuild test robot
CC: kbuild-all(a)lists.01.org
TO: Tom Zanussi <[email protected]>tree: https://git.kernel.org/pub/scm/linux/kernel/git/zanussi/lin
ux-trace.git ftrace/synth-event-gen-v2head: 91ee64186d5894724e276c4e7fad70446d7a02a7 commit: 5f052546541d6cc5ad00e28aca6376c221db5c7e [10/12] tracing:Add kprobe event command generation functions
config: x86_64-defconfig (attached as .config)
compiler: clang version 10.0.0 (git://gitmirror/llvm_project016bf03ef6fcd9dce43b0c17971f76323f07a684) reproduce:git checkout 5f052546541d6cc5ad00e28aca6376c221db5c7e # save the attached .config to linux build tree make ARCH=x86_64If you fix the issue, kindly add following tag
Reported-by kbuild test robot <[email protected]>All warnings (new ones prefixed by >>):
Quoted 3 lines
Quoted 3 lines
kernel/trace/trace_kprobe.c:974:17: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Wvarargs]va_start(args, kretprobe); ^
kernel/trace/trace_kprobe.c:947:30: note: parameter of type
'bool' (aka '_Bool') is declared here
const char *loc, bool kretprobe, ...)
^
1 warning generated.vim +/va_start +974
kernel/trace/trace_kprobe.c925 926 /** 927 * __gen_kprobe_cmd - Generate a synthetic event command from arg list 928 * @cmd: A pointer to the dynevent_cmd struct representing the new event 929 * @name: The name of the kprobe event 930 * @loc: The location of the kprobe event 931 * @kretprobe: Is this a return probe? 932 * @args: Variable number of arg (pairs), one pair for eachfield
933 *
934 * NOTE: Users normally won't want to call this function
directly, but
935 * rather use thegen_kprobe_cmd()wrapper, which
automatically adds a
936 * NULL to the end of the arg list. If this function is
used
937 * directly, make suer he last arg in the variable arg list
is NULL.938 * 939 * Generate a kprobe event command to be executed by 940 * create_dynevent(). This function can be used togenerate the
941 * complete command or only the first part of it; in the
latter case,
942 *add_probe_fields()can be used to add more fields
following this.943 * 944 * Return: 0 if successful, error otherwise. 945 */ 946 int __gen_kprobe_cmd(struct dynevent_cmd *cmd, const char *name, 947 const char *loc, bool kretprobe, ...) 948 { 949 char buf[MAX_EVENT_NAME_LEN]; 950 struct dynevent_arg arg; 951 va_list args; 952 int ret; 953 954 if (cmd->type != DYNEVENT_TYPE_KPROBE) 955 return -EINVAL; 956 957 if (kretprobe) 958 snprintf(buf, MAX_EVENT_NAME_LEN, "r:%s", name); 959 else 960 snprintf(buf, MAX_EVENT_NAME_LEN, "p:%s", name); 961 962 dynevent_arg_init(&arg, NULL, 0); 963 arg.str = buf; 964 ret = add_dynevent_arg(cmd, &arg); 965 if (ret) 966 return ret; 967 968 dynevent_arg_init(&arg, NULL, 0); 969 arg.str = loc; 970 ret = add_dynevent_arg(cmd, &arg); 971 if (ret) 972 return ret; 973Quoted 1 line
974
va_start(args, kretprobe);975 for (;;) { 976 const char *field; 977 978 field = va_arg(args, const char *); 979 if (!field) 980 break; 981 982 if (++cmd->n_fields > MAX_TRACE_ARGS) { 983 ret = -EINVAL; 984 break; 985 } 986 987 dynevent_arg_init(&arg, NULL, 0); 988 arg.str = field; 989 ret = add_dynevent_arg(cmd, &arg); 990 if (ret) 991 break; 992 } 993 va_end(args); 994 995 return ret; 996 } 997 EXPORT_SYMBOL_GPL(__gen_kprobe_cmd); 998---
0-DAY kernel test infrastructure Open Source
Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
Quoted 12 lines · Tom Zanussi
Hi Nick,
Quoted 7 lines · Nick Desaulniers
Hi Tom,
Below is a report from a 0day bot build w/ Clang, can you please take a look? (Apologies if this has been previously reported). In the past, -Wvarargs warnings are usually related to the last parameter of ava_argfunction undergoing implicit promotion (which is explicitly UB, IIRC).
Quoted 2 lines
OK, looks like just changing the param order should fix it, thanks for the report.
Yep, IIRC, that was the fix in the past for previous occurrences.
Signature · 2 lines
Thanks, ~Nick Desaulniers