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 pcp command for printing Linux kernel per-cpu page cache #1487

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

gsingh93
Copy link
Member

@gsingh93 gsingh93 commented Jan 2, 2023

The Linux kernel uses a per-cpu cache for allocating order-0 pages. Being able to print the contents of these caches can be useful for exploiting some UAF bugs. This is a very rough command to print the caches for each zone. This isn't polished at all or in a state where it should be merged, but I found it useful and won't have time to improve it in the near future, so putting it here for now in case anyone wants to use it or improve it.

Example output:

pwndbg> pcp
Zone 0
count:  371
high:  378

pcp.lists[0]:
0xfffffffefff5a2c0
0xfffffffefff586c0
...

@codecov-commenter
Copy link

codecov-commenter commented Jan 2, 2023

Codecov Report

Merging #1487 (3c67651) into dev (ae5298f) will decrease coverage by 0.01%.
The diff coverage is 51.35%.

@@            Coverage Diff             @@
##              dev    #1487      +/-   ##
==========================================
- Coverage   57.85%   57.83%   -0.02%     
==========================================
  Files         167      168       +1     
  Lines       20264    20301      +37     
  Branches     1834     1839       +5     
==========================================
+ Hits        11723    11742      +19     
- Misses       7980     7996      +16     
- Partials      561      563       +2     
Impacted Files Coverage Δ
pwndbg/commands/pcp.py 50.00% <50.00%> (ø)
pwndbg/commands/__init__.py 73.42% <100.00%> (+0.07%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@gsingh93 gsingh93 added the kernel label Jan 4, 2023
@gsingh93
Copy link
Member Author

Note to self: this needs some minor updates for the latest Linux kernel version, and also some tweaks to handle when CONFIG_NUMA is not set.

@disconnect3d
Copy link
Member

Shall we maybe name the command differently to make it more connected to linux kernel or more understandable?

We already have many fancy shortcuts... so idk, maybe its okay to add more :P

@gsingh93
Copy link
Member Author

When people see it in the pwndbg output it'll be under the "Kernel" category, I think that should be enough?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

3 participants