mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-31 08:28:34 +00:00
Merge pull request #6369 from XDTG/6082/Fix-path-check-bypassed
runtime: use filepath.Clean() to clean the mount path
This commit is contained in:
@@ -44,6 +44,7 @@ func mountLogger() *logrus.Entry {
|
||||
}
|
||||
|
||||
func isSystemMount(m string) bool {
|
||||
m = filepath.Clean(m)
|
||||
for _, p := range systemMountPrefixes {
|
||||
if m == p || strings.HasPrefix(m, p+"/") {
|
||||
return true
|
||||
@@ -54,6 +55,7 @@ func isSystemMount(m string) bool {
|
||||
}
|
||||
|
||||
func isHostDevice(m string) bool {
|
||||
m = filepath.Clean(m)
|
||||
if m == "/dev" {
|
||||
return true
|
||||
}
|
||||
|
@@ -249,6 +249,9 @@ func TestIsHostDevice(t *testing.T) {
|
||||
{"/dev/zero", true},
|
||||
{"/dev/block", true},
|
||||
{"/mnt/dev/block", false},
|
||||
{"/../dev", true},
|
||||
{"/../dev/block", true},
|
||||
{"/../mnt/dev/block", false},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
@@ -41,6 +41,10 @@ func TestIsSystemMount(t *testing.T) {
|
||||
{"/home", false},
|
||||
{"/dev/block/", false},
|
||||
{"/mnt/dev/foo", false},
|
||||
{"/../sys", true},
|
||||
{"/../sys/", true},
|
||||
{"/../sys/fs/cgroup", true},
|
||||
{"/../sysfoo", false},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Reference in New Issue
Block a user