From d678784ae182bd816e00b69f5838f0665a79485c Mon Sep 17 00:00:00 2001 From: Chirantan Ekbote Date: Thu, 21 Jun 2018 12:14:41 -0700 Subject: [PATCH] p9: Fix file and directory creation mode Don't allow clients to create files and directories that are writable by anyone other than the user. This is equivalent to having a umask of 022. BUG=chromium:703939 TEST=change the umask in the container, mkdir, and see that it has 0755 Change-Id: I0622fcd89935512969bcd25a9b1fece1e72e1f38 Signed-off-by: Chirantan Ekbote Reviewed-on: https://chromium-review.googlesource.com/1112869 Reviewed-by: Dylan Reid --- p9/src/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/p9/src/server.rs b/p9/src/server.rs index 9c41941d37..8f1d649f29 100644 --- a/p9/src/server.rs +++ b/p9/src/server.rs @@ -541,7 +541,7 @@ impl Server { .append((lcreate.flags & P9_APPEND) != 0) .create_new((lcreate.flags & P9_EXCL) != 0) .custom_flags(custom_flags) - .mode(lcreate.mode & 0o777) + .mode(lcreate.mode & 0o755) .open(&path)?; fid.metadata = file.metadata()?; @@ -842,7 +842,7 @@ impl Server { fs::DirBuilder::new() .recursive(false) - .mode(mkdir.mode & 0o777) + .mode(mkdir.mode & 0o755) .create(&newpath)?; Ok(Rmessage::Mkdir(Rmkdir {