Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experimental helpers for calling kernel functions and writing to memory #430

Merged
merged 5 commits into from
Sep 18, 2024

Conversation

osandov
Copy link
Owner

@osandov osandov commented Sep 18, 2024

There are a few preparatory commits moving code around. The top commit has the details.

In all of our current code, we want to document a class separately from
its "constructor"; see commit c801e5e ("drgndoc: format __init__()
signature separately from class"). But for some trivial classes, like
one that will be added in an upcoming change, it makes sense to collapse
them. So, for classes with no docstring and one __init__() signature
with a docstring, document the class with the __init__() signature and
docstring.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
An upcoming helper will need these. We also need them from vmtest when
_drgn may not be built yet, though, so they can't go in drgn.internal.
Create a new package, _drgn_util, and move them there.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
An upcoming helper will need some ELF constant definitions.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
This will be used by an upcoming helper.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
…memory

These are highly-requested features that I didn't implement for awhile
because I thought they would be too difficult or hacky. The approach
that I finally came up with is slightly deranged but solid: we manually
generate a kernel module ELF file and machine code to do a function
call. An alternative approach that I tried was generating C source code
for a kernel module and building it, but that relies on having
kernel-devel and a compatible toolchain installed, and it's slow. (Kudos
to Matthew Wilcox for suggesting the kernel module approach last year:
https://lwn.net/Articles/953256/.)

For now, this is under a new drgn.helpers.experimental package, in the
drgn.helpers.experimental.kmodify module, with no stability guarantees,
but we still have tests for it.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
@osandov osandov merged commit 1652183 into main Sep 18, 2024
39 checks passed
@osandov osandov deleted the kmodify branch October 1, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant