Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure PcmMsrClient can only opened by root #596

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/MacMSRDriver/PcmMsr/PcmMsrClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,23 @@ IOReturn PcmMsrClientClassName::externalMethod(uint32_t selector, IOExternalMeth
return super::externalMethod(selector, args, dispatch, target, reference);
}

bool PcmMsrClientClassName::initWithTask(task_t owningTask, void *securityToken, UInt32 type, OSDictionary *properties)
{
if(!IOUserClient::initWithTask(owningTask, securityToken, type, properties)) {
return false;
}

sSecurityToken = securityToken;
return true;
}

bool PcmMsrClientClassName::start(IOService* provider)
{
bool result = false;


if(clientHasPrivilege(sSecurityToken, kIOClientPrivilegeAdministrator) != kIOReturnSuccess)
return false;

fProvider = OSDynamicCast(PcmMsrDriverClassName, provider);

if (fProvider != NULL) {
Expand Down
4 changes: 3 additions & 1 deletion src/MacMSRDriver/PcmMsr/PcmMsrClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ class PcmMsrClientClassName : public IOUserClient

protected:
PcmMsrDriverClassName* fProvider;
void* sSecurityToken;
static const IOExternalMethodDispatch sMethods[kNumberOfMethods];

public:
virtual bool initWithTask(task_t owningTask, void *securityToken, UInt32 type, OSDictionary *properties) override;
virtual bool start(IOService *provider) override;

virtual IOReturn clientClose(void) override;

virtual bool didTerminate(IOService* provider, IOOptionBits opts, bool* defer) override;
Expand Down