sysctl: Check path is under /proc/sys

sysctl would try to read/write any path you gave it either on
the command line or configuration file. It would append /proc/sys
on the path but not check for any sneaky path traversal with ../

This commit means it first resolves all paths using realpath(3)
and then checks the path starts with "/proc/sys/"

At first I thought this might be a non-issue, but perhaps someone
could put a file into the sysctl configuration path and.. do
something? Anyway its a 8-line fix and makes things more correct.

References:
 #179

Signed-off-by: Craig Small <csmall@dropbear.xyz>
This commit is contained in:
Craig Small
2021-07-20 22:36:15 +10:00
parent 05a720fdba
commit f25d462166
2 changed files with 29 additions and 0 deletions

1
NEWS
View File

@@ -9,6 +9,7 @@ procps-ng-NEXT
* ps: Add IO Accounting fields issue #184
* ps: Add PSS and USS fields issue #112
* slabtop: Don't combine d and o options issue #160
* sysctl: Check resolved path to be under /proc/sys issue #179
* top: exploit some library smaps_rollup provisions issue #112
* top: added four new IO accounting fields issue #184