Probes fixes for v6.6-rc6:

- Fix fprobe document to add a new ret_ip parameter for callback
    functions. This has been introduced in v6.5 but the document was not
    updated.
 
  - Fix fprobe to check the number of active retprobes is not zero. This
    number is passed from parameter or calculated by the parameter and it
    can be zero which is not acceptable. But current code only check it is
    not minus.
 -----BEGIN PGP SIGNATURE-----
 
 iQFPBAABCgA5FiEEh7BulGwFlgAOi5DV2/sHvwUrPxsFAmUt5McbHG1hc2FtaS5o
 aXJhbWF0c3VAZ21haWwuY29tAAoJENv7B78FKz8bS0cIALxtYVbKpzS95TRUKbjP
 RvB9qp6howvbWY5dJnoIqMfuws4SLGsaOtg6dMWN+C/I/cQexTpW2jQLdYS+k837
 Q+TyWIHqzLXfbtqSQwEr08wcGfM95eu5UGA8LMkMvT7o+ias6tHXBLDiMsynmm+7
 a9BZtWgj2O/S8TZDqbz2PfbeWYr/pd2uyqJriN9yN+YfJ0trwccHxQJZC9lQEPnN
 tcf99rX7cpK/fmXafCNCpsJHA0yfp25Twgm2sC1uD75cCOpn5ZpG33PBE8WW1MGT
 fVGK7dF6Cf8YClZ0SI/VJpLlwn5B0q2ZPny8374mbWa883wdlG6NhdRBkvaoBNAX
 tSY=
 =4GR/
 -----END PGP SIGNATURE-----

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

Pull probes fixes from Masami Hiramatsu:

 - Fix fprobe document to add a new ret_ip parameter for callback
   functions. This has been introduced in v6.5 but the document was not
   updated.

 - Fix fprobe to check the number of active retprobes is not zero. This
   number is passed from parameter or calculated by the parameter and it
   can be zero which is not acceptable. But current code only check it
   is not minus.

* tag 'probes-fixes-v6.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  fprobe: Fix to ensure the number of active retprobes is not zero
  Documentation: probes: Add a new ret_ip callback parameter
This commit is contained in:
Linus Torvalds 2023-10-16 18:50:48 -07:00
commit 213f891525
2 changed files with 9 additions and 5 deletions

View File

@ -91,9 +91,9 @@ The prototype of the entry/exit callback function are as follows:
.. code-block:: c
int entry_callback(struct fprobe *fp, unsigned long entry_ip, struct pt_regs *regs, void *entry_data);
int entry_callback(struct fprobe *fp, unsigned long entry_ip, unsigned long ret_ip, struct pt_regs *regs, void *entry_data);
void exit_callback(struct fprobe *fp, unsigned long entry_ip, struct pt_regs *regs, void *entry_data);
void exit_callback(struct fprobe *fp, unsigned long entry_ip, unsigned long ret_ip, struct pt_regs *regs, void *entry_data);
Note that the @entry_ip is saved at function entry and passed to exit handler.
If the entry callback function returns !0, the corresponding exit callback will be cancelled.
@ -108,6 +108,10 @@ If the entry callback function returns !0, the corresponding exit callback will
Note that this may not be the actual entry address of the function but
the address where the ftrace is instrumented.
@ret_ip
This is the return address that the traced function will return to,
somewhere in the caller. This can be used at both entry and exit.
@regs
This is the `pt_regs` data structure at the entry and exit. Note that
the instruction pointer of @regs may be different from the @entry_ip

View File

@ -189,7 +189,7 @@ static int fprobe_init_rethook(struct fprobe *fp, int num)
{
int i, size;
if (num < 0)
if (num <= 0)
return -EINVAL;
if (!fp->exit_handler) {
@ -202,8 +202,8 @@ static int fprobe_init_rethook(struct fprobe *fp, int num)
size = fp->nr_maxactive;
else
size = num * num_possible_cpus() * 2;
if (size < 0)
return -E2BIG;
if (size <= 0)
return -EINVAL;
fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler);
if (!fp->rethook)