Additional operation check when enabling read logs.

Vold now does not check caller's permission, but only accepts
transactions from system_server. And it's up to system server to do the
right thing and check permissions/appops.

Bug: b/152633648
Test: atest PackageManagerShellCommandTest PackageManagerShellCommandIncrementalTest
Test: adb shell appops set 1000 GET_USAGE_STATS deny
Change-Id: Id56c1673b135b72b3ec86e572aa4bcca3afc19ab
gugelfrei
Alex Buynytskyy 4 years ago
parent 75973cb0dd
commit 605a44fe93

@ -53,7 +53,6 @@ namespace vold {
namespace { namespace {
constexpr const char* kDump = "android.permission.DUMP"; constexpr const char* kDump = "android.permission.DUMP";
constexpr const char* kDataUsageStats = "android.permission.LOADER_USAGE_STATS";
static binder::Status error(const std::string& msg) { static binder::Status error(const std::string& msg) {
PLOG(ERROR) << msg; PLOG(ERROR) << msg;
@ -920,11 +919,9 @@ binder::Status VoldNativeService::unmountIncFs(const std::string& dir) {
binder::Status VoldNativeService::setIncFsMountOptions( binder::Status VoldNativeService::setIncFsMountOptions(
const ::android::os::incremental::IncrementalFileSystemControlParcel& control, const ::android::os::incremental::IncrementalFileSystemControlParcel& control,
bool enableReadLogs) { bool enableReadLogs) {
auto status = CheckPermission(kDataUsageStats); ENFORCE_SYSTEM_OR_ROOT;
if (!status.isOk()) {
return status;
}
auto status = Ok();
auto incfsControl = IncFs_CreateControl(dup(control.cmd.get()), dup(control.pendingReads.get()), auto incfsControl = IncFs_CreateControl(dup(control.cmd.get()), dup(control.pendingReads.get()),
dup(control.log.get())); dup(control.log.get()));
if (auto error = IncFs_SetOptions( if (auto error = IncFs_SetOptions(

@ -39,11 +39,10 @@ binder::Status Exception(uint32_t code, const std::string& msg) {
} }
binder::Status CheckPermission(const char* permission) { binder::Status CheckPermission(const char* permission) {
pid_t pid; int32_t pid;
uid_t uid; int32_t uid;
if (checkCallingPermission(String16(permission), reinterpret_cast<int32_t*>(&pid), if (checkCallingPermission(String16(permission), &pid, &uid)) {
reinterpret_cast<int32_t*>(&uid))) {
return Ok(); return Ok();
} else { } else {
return Exception(binder::Status::EX_SECURITY, return Exception(binder::Status::EX_SECURITY,

Loading…
Cancel
Save