Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'probes-fixes-v6.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull probes fixes from Masami Hiramatsu:

- remove unnecessary initial values of kprobes local variables

- probe-events parser bug fixes:

- calculate the argument size and format string after setting type
information from BTF, because BTF can change the size and format
string.

- show $comm parse error correctly instead of failing silently.

* tag 'probes-fixes-v6.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
kprobes: Remove unnecessary initial values of variables
tracing/probes: Fix to set arg size and fmt after setting type from BTF
tracing/probes: Fix to show a parse error for bad type for $comm

+22 -17
+2 -2
kernel/kprobes.c
··· 1993 1993 unsigned long kretprobe_find_ret_addr(struct task_struct *tsk, void *fp, 1994 1994 struct llist_node **cur) 1995 1995 { 1996 - struct kretprobe_instance *ri = NULL; 1996 + struct kretprobe_instance *ri; 1997 1997 kprobe_opcode_t *ret; 1998 1998 1999 1999 if (WARN_ON_ONCE(!cur)) ··· 2802 2802 { 2803 2803 struct hlist_head *head; 2804 2804 struct kprobe *p, *kp; 2805 - const char *sym = NULL; 2805 + const char *sym; 2806 2806 unsigned int i = *(loff_t *) v; 2807 2807 unsigned long offset = 0; 2808 2808 char *modname, namebuf[KSYM_NAME_LEN];
+18 -14
kernel/trace/trace_probe.c
··· 1159 1159 if (!(ctx->flags & TPARG_FL_TEVENT) && 1160 1160 (strcmp(arg, "$comm") == 0 || strcmp(arg, "$COMM") == 0 || 1161 1161 strncmp(arg, "\\\"", 2) == 0)) { 1162 - /* The type of $comm must be "string", and not an array. */ 1163 - if (parg->count || (t && strcmp(t, "string"))) 1162 + /* The type of $comm must be "string", and not an array type. */ 1163 + if (parg->count || (t && strcmp(t, "string"))) { 1164 + trace_probe_log_err(ctx->offset + (t ? (t - arg) : 0), 1165 + NEED_STRING_TYPE); 1164 1166 goto out; 1167 + } 1165 1168 parg->type = find_fetch_type("string", ctx->flags); 1166 1169 } else 1167 1170 parg->type = find_fetch_type(t, ctx->flags); 1168 1171 if (!parg->type) { 1169 1172 trace_probe_log_err(ctx->offset + (t ? (t - arg) : 0), BAD_TYPE); 1170 1173 goto out; 1171 - } 1172 - parg->offset = *size; 1173 - *size += parg->type->size * (parg->count ?: 1); 1174 - 1175 - ret = -ENOMEM; 1176 - if (parg->count) { 1177 - len = strlen(parg->type->fmttype) + 6; 1178 - parg->fmt = kmalloc(len, GFP_KERNEL); 1179 - if (!parg->fmt) 1180 - goto out; 1181 - snprintf(parg->fmt, len, "%s[%d]", parg->type->fmttype, 1182 - parg->count); 1183 1174 } 1184 1175 1185 1176 code = tmp = kcalloc(FETCH_INSN_MAX, sizeof(*code), GFP_KERNEL); ··· 1194 1203 if (ret) 1195 1204 goto fail; 1196 1205 } 1206 + } 1207 + parg->offset = *size; 1208 + *size += parg->type->size * (parg->count ?: 1); 1209 + 1210 + if (parg->count) { 1211 + len = strlen(parg->type->fmttype) + 6; 1212 + parg->fmt = kmalloc(len, GFP_KERNEL); 1213 + if (!parg->fmt) { 1214 + ret = -ENOMEM; 1215 + goto out; 1216 + } 1217 + snprintf(parg->fmt, len, "%s[%d]", parg->type->fmttype, 1218 + parg->count); 1197 1219 } 1198 1220 1199 1221 ret = -EINVAL;
+2 -1
kernel/trace/trace_probe.h
··· 515 515 C(BAD_HYPHEN, "Failed to parse single hyphen. Forgot '>'?"), \ 516 516 C(NO_BTF_FIELD, "This field is not found."), \ 517 517 C(BAD_BTF_TID, "Failed to get BTF type info."),\ 518 - C(BAD_TYPE4STR, "This type does not fit for string."), 518 + C(BAD_TYPE4STR, "This type does not fit for string."),\ 519 + C(NEED_STRING_TYPE, "$comm and immediate-string only accepts string type"), 519 520 520 521 #undef C 521 522 #define C(a, b) TP_ERR_##a