mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
sentry: support NULL mount source
NULL mount sources can be valid, e.g. when mounting "proc". PiperOrigin-RevId: 653769241
This commit is contained in:
committed by
gVisor bot
parent
cd56935ddf
commit
e39ed91daa
@@ -116,9 +116,12 @@ func Mount(t *kernel.Task, sysno uintptr, args arch.SyscallArguments) (uintptr,
|
||||
}
|
||||
|
||||
// Only copy in source, fstype, and data if we are doing a normal mount.
|
||||
source, err := t.CopyInString(sourceAddr, hostarch.PageSize)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
var source string
|
||||
if sourceAddr != 0 {
|
||||
source, err = t.CopyInString(sourceAddr, hostarch.PageSize)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
}
|
||||
fsType, err := t.CopyInString(typeAddr, hostarch.PageSize)
|
||||
if err != nil {
|
||||
|
||||
@@ -2328,6 +2328,28 @@ TEST(MountTest, DetachedMountBindFails) {
|
||||
SyscallFailsWithErrno(EINVAL));
|
||||
}
|
||||
|
||||
TEST(MountTest, MountProc) {
|
||||
SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_ADMIN)));
|
||||
|
||||
// Mount procfs with a NULL source to a temporary directory.
|
||||
const TempPath dir = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir());
|
||||
ASSERT_THAT(mount(NULL, dir.path().c_str(), "proc", 0, NULL),
|
||||
SyscallSucceeds());
|
||||
auto cleanup = Cleanup([&dir] {
|
||||
EXPECT_THAT(umount2(dir.path().c_str(), 0), SyscallSucceeds());
|
||||
});
|
||||
|
||||
// Verify that /proc/self/mountinfo describes the device as "none".
|
||||
const std::vector<ProcMountInfoEntry> mountinfo =
|
||||
ASSERT_NO_ERRNO_AND_VALUE(ProcSelfMountInfoEntries());
|
||||
for (auto const& e : mountinfo) {
|
||||
if (e.mount_point == dir.path()) {
|
||||
EXPECT_EQ(e.fstype, "proc");
|
||||
EXPECT_EQ(e.mount_source, "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace testing
|
||||
|
||||
Reference in New Issue
Block a user