-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Restrict permissions for zfs/dbgmsg and other kstats, print real pointers #8476
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That make sense, I'd just suggest we restrict these two additional kstats while we're here.
/proc/spl/kstat/zfs/dbufs
/proc/spl/kstat/zfs/pool/reads
I think this type of protection has been needed for quite some time. There are likely other kstats which we ought to similarly protect lest they be used to perform DOS attacks. I'd suggest restricting |
@behlendorf and @dweeezil - it looks like some of the |
Or perhaps I should add mode to the kstat struct itself? I like they idea of developers having to think a little more about what the permissions really should be when adding kstats. |
@shartse historically we've avoided changing any of the interfaces we're emulating from Illumos. Primarily to reduce code differences and avoid conflicts when porting. Since we only have a few proc entries we want to target, and they don't have Illumos counterparts, I'd suggest we just special case them for now. |
@shartse I agree the special casing approach makes sense for this this. Everything looks good except we had one test failure with
|
Cool - I added |
There are several places where we use zfs_dbgmsg and %p to print pointers. In the Linux kernel, these values obfuscated to prevent information leaks which means the pointers aren't very useful for debugging crash dumps. We decided to restrict the permissions ofdbgmsg (and some other kstats while we were at it) and print pointers with %px in zfs_dbgmsg as well as spl_dumpstack Signed-off-by: sara hartse <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #8476 +/- ##
==========================================
- Coverage 78.81% 78.73% -0.09%
==========================================
Files 381 381
Lines 117512 117513 +1
==========================================
- Hits 92622 92522 -100
- Misses 24890 24991 +101
Continue to review full report at Codecov.
|
(Late) follow-up question about this change: was there any particular reason why the
|
I believe changing the |
Motivation and Context
This is addressing this issue: #8467
There are several places where we use zfs_dbgmsg and
%p
to print pointers. In the Linux kernel, these values obfuscated to prevent information leaks (which makes sense, as/proc/spl/kstat/zfs/dbgmsg
is world readable). However, this means the pointers aren't very useful for debugging crash dumps since you can't find the location of the struct they refer to.Description
I found that kstat proc creation always uses the same permission mode (
0644
). I abstracted out the mode so that different kstats can be created with different permissions. Upon suggestion, I reduced the permissions ofdbufs
andpool/reads
along withdbgmsg
to0600
but left all other kstats with the original mode.Then, I looked for occurrences of
%p
in calls tozfs_dbgmsg
and replaced them with%px
so that the actual pointer is printed.Finally, as proposed by @pcd1193182 in https://github.com/delphix/zfs/pull/40, I changed
spl_dumpstack
to usepx
as well.How Has This Been Tested?
Loaded changes on a VM and verififed that the
kstat
permissions changed as expected.Before
After
Inspected
/proc/spl/kstat/zfs/dbgmsg
and saw that the logged pointers frommetaslab_condense
now look legitimate.Before
metaslab_condense(): condensing: txg 352980, msp[49] 000000003159e1df, vdev id 0, spa rpool, smp size 17056, segents 703, forcing condense=FALSE
After (requires sudo to access)
metaslab_condense(): condensing: txg 84170, msp[51] ffff9619a0271800, vdev id 0, spa rpool, smp size 16520, segments 421, forcing condense=FALSE
Types of changes
Checklist:
Signed-off-by
.