From 39704e777a5fd32a0635208e2aca712c3db5aa66 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 4 May 2022 22:17:54 +0000 Subject: [PATCH] Set correct SELinux labels on new user directories Make vold explicitly set the appropriate fscreate SELinux context when creating per-user subdirectories such as /data/user/$userId. This is needed for these subdirectories to get the correct SELinux labels after the sepolicy change https://r.android.com/2078213 changes their parent directories to have different labels. Note: the helper function being changed is also used for some other directories, such as subdirectories of /data/misc/vold. But this is fine since they still get the same labels as before. Test: see https://r.android.com/2078213 Bug: 156305599 Change-Id: Id61c2d985144007059c563cec91b1355176e915c --- FsCrypt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FsCrypt.cpp b/FsCrypt.cpp index 6c08177..3c825ea 100644 --- a/FsCrypt.cpp +++ b/FsCrypt.cpp @@ -309,7 +309,7 @@ static bool read_and_install_user_ce_key(userid_t user_id, static bool prepare_dir(const std::string& dir, mode_t mode, uid_t uid, gid_t gid) { LOG(DEBUG) << "Preparing: " << dir; - if (fs_prepare_dir(dir.c_str(), mode, uid, gid) != 0) { + if (android::vold::PrepareDir(dir, mode, uid, gid, 0) != 0) { PLOG(ERROR) << "Failed to prepare " << dir; return false; }