Skip to content

Commit

Permalink
Don't lock out the driver when root is accessing it
Browse files Browse the repository at this point in the history
  • Loading branch information
eflumerf committed Jan 13, 2025
1 parent d2b3dfa commit 1eda004
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mu2e_driver/mu2e_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ void mu2e_fs_down()

int mu2e_open(struct inode *inode, struct file *filp)
{
// Root doesn't have to ask for permission, and shouldn't lock out anyone
if (capable(CAP_DAC_OVERRIDE)) {
return 0;
}
int dtc = iminor(inode);

spin_lock(&mu2e_fs_spinlock);
Expand Down Expand Up @@ -114,6 +118,13 @@ int mu2e_open(struct inode *inode, struct file *filp)
int mu2e_release(struct inode *inode, struct file *filp)
{
int dtc = iminor(inode);

// Root doesn't have to ask for permission, and shouldn't lock out anyone
if (capable(CAP_DAC_OVERRIDE))
{
return 0;
}

spin_lock(&mu2e_fs_spinlock);
mu2e_dtc_count[dtc]--;
if (mu2e_dtc_count[dtc] == 0)
Expand Down

0 comments on commit 1eda004

Please sign in to comment.