From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A22F7192D97 for ; Sun, 22 Feb 2026 14:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771770968; cv=none; b=XkeVF4ABkTj25/tfIm5CghtPAS/pk+Tv4MvXkmkNqdlHowxd2kBs1wqXW4j5gqpdGEKQ8pg48oC3kQmhi7ycfsThsAH7ei2ze1AIQwNp5iz3Po/s0Y/NaAbB7LQkQ6AJ0NulVSTrWmsQmmAzXCoi9X44seirgm4pMKgIUi1sEkU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771770968; c=relaxed/simple; bh=Lh7zHtti+UFwjZSPSdzF1eFbtEdNKhAcoT8uv6ypMQ8=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ElNKERjqkf+mozXc9dGn76GNhjMsPM4XYwlpFozngxLW0F99gSlB008YZwgnuS0KEMHMMevKmS67rOwxGNUN0sm5i4dgnW2I574HOUVMd/NKCIsub60erjZzy0gAlePN3yn3jzlLlzBg8M2hJKSexAh8F/yzWC+nD3cVuojYji4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Sa8GutYr; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Sa8GutYr" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4806cc07ce7so31856615e9.1 for ; Sun, 22 Feb 2026 06:36:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771770965; x=1772375765; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=2HZ6whw5IMPhwktEDQwrczvE7RIG7O7dxlSCf6ECZ8U=; b=Sa8GutYrmDchdFKB+OZBz0E1rwNNApqAk4PqTQfNZildGsATPY72fbILOWAA2bYqNC hJFIYFIlvwCgIDf7tM8ekOp9t3tZWviXhS1kB3Kys/T6jZk0jbxHBjOXm4R+0ukqo9KA wEXqw9MzSHsVvIuXINekHMDF/zPHAeK0R3dJ3BrOzUCm2yRe8FMcyFPgWa1DZU5RHDpw QzlvS1RPqw8DyrDRFmLvJ7JhP83xYAefawhkNjjfEJiqmGCa1UkUV4/B7hYu8+AV/qT9 p9U36456mMRGtKXvDfBjVx0Hfce82mkJGtqxz+vMnJgyQ28yPgA6ahm9Sdq6vDeE50B7 J6eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771770965; x=1772375765; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2HZ6whw5IMPhwktEDQwrczvE7RIG7O7dxlSCf6ECZ8U=; b=f0Wr8V3znVggkZX74GxcNfAWLJc1T0BJtpYxMgs6OAiTxf3RuyJg1bCCY7WEVcHGLL aiQ2pigjyWybgeCfSv7t+Qiy2DiKnJ81XiTNuCX376buSW1KY4Iepmo+sFCuJX9/n2tg u1BT4tzKwJJaz04aM+TdHDBlqlpww0GnTZ7/P8xUXC+1eKvl3GItYe4HQ+JYmYMboT00 Aq7Qq+2DD1B6qdk2XX4Cu8e21owcfuXT32xm5tBbseA9L/Pg8mz6dOmEDWqNqzFh/wHj 0UUYxSYE6qv+SVws5mldqMaOUuIQgsbv58+cDAoeLaks7FNXQ4JD2NvMNeih3P22i4/L KcmQ== X-Forwarded-Encrypted: i=1; AJvYcCW1nO9HVTsLhc6Iix3u7DYlV1Q4/K5V5me7apUEB6j6by5pEGfexv+FR8DpMef1SUSG5CYVO4tQR+4vJ3kCSMUoEUE=@vger.kernel.org X-Gm-Message-State: AOJu0YzmI6dfw+3MgV4uSgLgltf6MUPlWNqNTukWJPrhq0dtuVJXDUCe N+HL9Y5YM8PrMG3fcp6IPXuXcvna1iN16s4hLa3Q5Sg2+Jg6uqLvnV+H X-Gm-Gg: AZuq6aJE+BAshcsyMaPj236EJ7OI1F2cduImUwn6U+ouq2/gbpAHJepLF0gobm8DJOp 0024kB5iIP1vN9lECCnOsyVa/+r4RJzzqm8xLTWgQu1VM1ll/F3E+vSlvd1Xrmh+4WnKdLptK8I q3NVL/2LXdgfgAs03CPB49R9IrLkKQn8GP5HTltwqTSNom+4tXqp3awNt170ywDwSlp3el1yXnz 5ekNSJt7iNUL4iqN4MIlODDzHC04QFSjmgNuHI8D5g5oiPAlErfpy3z2EFocJ0zTgJjNi0lCuoN FHqguaqMdwPzIpUnc6eAc8LjB07H+jhye46uYZt7ae4vzbkv5QtMJden/B/obVxEdTVkdXoXdhv /41btgxmxwMkL89I9/tS+1WWlXzVLITkY3Rww5ZLRK7d4ThU7QN2QTlyzokaENPQgFEpK2mZG X-Received: by 2002:a05:600c:8b0a:b0:483:7f27:cdc5 with SMTP id 5b1f17b1804b1-483a9603c12mr95344775e9.31.1771770964732; Sun, 22 Feb 2026 06:36:04 -0800 (PST) Received: from krava ([2a02:8308:a00c:e200::b44f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9cb3de5sm133442465e9.12.2026.02.22.06.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Feb 2026 06:36:04 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Sun, 22 Feb 2026 15:36:02 +0100 To: bot+bpf-ci@kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org, kafai@fb.com, eddyz87@gmail.com, songliubraving@fb.com, yhs@fb.com, menglong8.dong@gmail.com, rostedt@kernel.org, martin.lau@kernel.org, yonghong.song@linux.dev, clm@meta.com, ihor.solodrai@linux.dev Subject: Re: [PATCH bpf-next 11/17] libbpf: Add support to create tracing multi link Message-ID: References: <20260220100649.628307-12-jolsa@kernel.org> <56ab264977d669e52dc1cbb2fa6224443cae58e723b4757ea59d21fd160f1b9f@mail.kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56ab264977d669e52dc1cbb2fa6224443cae58e723b4757ea59d21fd160f1b9f@mail.kernel.org> On Fri, Feb 20, 2026 at 10:57:53AM +0000, bot+bpf-ci@kernel.org wrote: > > The provided is used as 'pattern' argument in > > bpf_program__attach_kprobe_multi_opts function. > > This isn't a bug, but the commit message references > bpf_program__attach_kprobe_multi_opts when the code actually calls > bpf_program__attach_tracing_multi. Looks like a leftover from > the kprobe_multi code this was modeled after. copy&paste error :-\ thnx > > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > > --- a/tools/lib/bpf/libbpf.c > > +++ b/tools/lib/bpf/libbpf.c > > [ ... ] > > > +struct bpf_link * > > +bpf_program__attach_tracing_multi(const struct bpf_program *prog, const char *pattern, > > + const struct bpf_tracing_multi_opts *opts) > > +{ > > + LIBBPF_OPTS(bpf_link_create_opts, lopts); > > + __u32 *ids, cnt, *free_ids = NULL; > > cnt is declared as __u32 here, but collect_btf_func_ids_by_glob() > returns int. When that function returns a negative error such as > -ENOMEM, the value wraps to a large unsigned number. yes, will fix > > > + __u64 *cookies; > > + int prog_fd, link_fd, err; > > + struct bpf_link *link; > > [ ... ] > > > + if (pattern) { > > + err = bpf_object__load_vmlinux_btf(prog->obj, true); > > + if (err) > > + return libbpf_err_ptr(err); > > + > > + cnt = collect_btf_func_ids_by_glob(prog->obj->btf_vmlinux, pattern, &ids); > > + if (cnt < 0) > > + return libbpf_err_ptr(cnt); > > Since cnt is __u32, this comparison is always false. On an allocation > failure inside collect_btf_func_ids_by_glob(), the error is silently > ignored. That function also does free(*ids) before returning -ENOMEM, > so ids becomes a dangling pointer. The code then continues with a > freed ids pointer and a garbage cnt, and eventually double-frees ids > through the error label via free_ids. > > Should cnt be declared as int instead of __u32? it should, will fix > > > + if (cnt == 0) > > + return libbpf_err_ptr(-EINVAL); > > + free_ids = ids; > > + } > > [ ... ] > > > +error: > > + free(link); > > + free(free_ids); > > + return libbpf_err_ptr(err); > > +} > > + > > +static int attach_tracing_multi(const struct bpf_program *prog, long cookie, struct bpf_link **link) > > +{ > > + bool is_fexit, is_fsession; > > + const char *spec; > > + char *pattern; > > + int n; > > + > > + /* Do not allow auto attach if there's no function pattern. */ > > + if (strcmp(prog->sec_name, "fentry.multi") == 0 || > > + strcmp(prog->sec_name, "fexit.multi") == 0 || > > + strcmp(prog->sec_name, "fsession.multi") == 0 || > > + strcmp(prog->sec_name, "fentry.multi.s") == 0 || > > + strcmp(prog->sec_name, "fexit.multi.s") == 0 || > > + strcmp(prog->sec_name, "fsession.multi.s") == 0) > > + return 0; > > + > > + is_fexit = str_has_pfx(prog->sec_name, "fexit.multi/"); > > + is_fsession = str_has_pfx(prog->sec_name, "fsession.multi/"); > > + > > + if (is_fsession) > > + spec = prog->sec_name + sizeof("fsession.multi/") - 1; > > + else if (is_fexit) > > + spec = prog->sec_name + sizeof("fexit.multi/") - 1; > > + else > > + spec = prog->sec_name + sizeof("fentry.multi/") - 1; > > The sleepable variants with patterns don't seem to be handled here. > For a section name like "fentry.multi.s/my_func", none of the > str_has_pfx checks match because "fexit.multi/" and "fsession.multi/" > are not prefixes of "fentry.multi.s/..." (the character at position > 11 or 14 is '.' not '/'). > > The else branch then computes spec using sizeof("fentry.multi/") - 1 > which gives an offset of 13, pointing into "s/my_func" instead of > "my_func". The sscanf then extracts "s" as the pattern, and the > program attaches to any function matching the glob "s" rather than > "my_func". > > Similarly for "fexit.multi.s/X" and "fsession.multi.s/X", the > offsets are wrong and produce either error returns or incorrect > patterns. > > The SEC_DEF entries register all six sleepable variants, and > sec_def_matches() correctly distinguishes "fentry.multi.s+" from > "fentry.multi+" using the '/' separator check, so the matching > works but the pattern extraction here does not. > > Would it work to also check for the ".s/" variants, for example: > > is_fexit = str_has_pfx(prog->sec_name, "fexit.multi/") || > str_has_pfx(prog->sec_name, "fexit.multi.s/"); > > with the corresponding sizeof adjustments for the spec offset? yes, I mentioned in the cover letter that I did not add tests for sleepable functions attachments.. I should have ;-) will fix thanks, jirka