From: Yang Hanlin <mattoncis@hotmail.com>
To: "kernelnewbies@kernelnewbies.org" <kernelnewbies@kernelnewbies.org>
Subject: How to find hook points for USB device additions and removals
Date: Thu, 25 Aug 2022 12:49:51 +0000 [thread overview]
Message-ID: <SY6P282MB3766102347DC8BB7D2065752BB729@SY6P282MB3766.AUSP282.PROD.OUTLOOK.COM> (raw)
Hi all,
I am learning about the Linux kernel, especially the eBPF subsystem, for
various observability and networking applications. As a practice, I am
developing a simple utility that detects additions and removals of USB devices
and performs actions accordingly. For the sake of practicing eBPF, I plan to
implement this utility by instrumenting kernel functions with kprobes rather
than writing udev rules etc.
However, I found it not that easy to find the correct hook points. From the
kernel documentation for writing USB device drivers
(https://www.kernel.org/doc/html/latest/driver-api/usb/writing_usb_driver.html),
I learned that there is a `probe` function and a `disconnect` function
provided by a driver (in a `usb_driver` struct,
https://github.com/torvalds/linux/blob/e146caf303493c4f2458173d7f1598b76a9b1396/include/linux/usb.h#L1186-L1189)
for the kernel to call on additions and removals of USB devices respectively.
So I thought finding callers to `probe` and `disconnect` might help; but I did
not find such callers, either by searching `.probe(` in the repository or
using static analysis provided by an IDE.
Is there anything wrong with the methods I am using? How can I find
appropriate hook points for USB device additions & removals in the kernel? Or
is there an alternative solution using eBPF (such as instrumenting udev with a
uprobe)?
Thanks in advance.
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
next reply other threads:[~2022-08-25 12:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-25 12:49 Yang Hanlin [this message]
2022-09-05 6:04 ` How to find hook points for USB device additions and removals Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=SY6P282MB3766102347DC8BB7D2065752BB729@SY6P282MB3766.AUSP282.PROD.OUTLOOK.COM \
--to=mattoncis@hotmail.com \
--cc=kernelnewbies@kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).