diff options
author | Todd Poynor <toddpoynor@google.com> | 2018-07-19 20:49:16 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-07-21 08:50:35 +0200 |
commit | ed74277bd80a47ec552ccf3581583421c3a4df5d (patch) | |
tree | c9e4eb90d95b4e1d08fcc7e092884ac006ec9dc5 /drivers/staging/gasket/gasket_core.c | |
parent | 563f3bb51f59e288879c099b2e8ee1496b7c3234 (diff) |
staging: gasket: always allow root open for write
Always allow root to open device for writing.
Drop special-casing of ioctl permissions for root vs. owner.
Convert to bool types as appropriate.
Reported-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/gasket/gasket_core.c')
-rw-r--r-- | drivers/staging/gasket/gasket_core.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index ba48a379b0ad..254fb392c05c 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1072,6 +1072,7 @@ static int gasket_open(struct inode *inode, struct file *filp) char task_name[TASK_COMM_LEN]; struct gasket_cdev_info *dev_info = container_of(inode->i_cdev, struct gasket_cdev_info, cdev); + int is_root = capable(CAP_SYS_ADMIN); gasket_dev = dev_info->gasket_dev_ptr; driver_desc = gasket_dev->internal_desc->driver_desc; @@ -1085,7 +1086,7 @@ static int gasket_open(struct inode *inode, struct file *filp) "Attempting to open with tgid %u (%s) (f_mode: 0%03o, " "fmode_write: %d is_root: %u)", current->tgid, task_name, filp->f_mode, - (filp->f_mode & FMODE_WRITE), capable(CAP_SYS_ADMIN)); + (filp->f_mode & FMODE_WRITE), is_root); /* Always allow non-writing accesses. */ if (!(filp->f_mode & FMODE_WRITE)) { @@ -1099,8 +1100,9 @@ static int gasket_open(struct inode *inode, struct file *filp) gasket_dev, "Current owner open count (owning tgid %u): %d.", ownership->owner, ownership->write_open_count); - /* Opening a node owned by another TGID is an error (even root.) */ - if (ownership->is_owned && ownership->owner != current->tgid) { + /* Opening a node owned by another TGID is an error (unless root) */ + if (ownership->is_owned && ownership->owner != current->tgid && + !is_root) { gasket_log_error( gasket_dev, "Process %u is opening a node held by %u.", |