Skip to content

Commit

Permalink
Merge tag 'probes-fixes-v6.6-rc6' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/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
  • Loading branch information
Linus Torvalds committed Oct 17, 2023
2 parents 86d6a62 + 700b2b4 commit 213f891
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Documentation/trace/fprobe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions kernel/trace/fprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down

0 comments on commit 213f891

Please sign in to comment.