staging: android: logger: enforce GID and CAP check on log flush
authorCharndeep Grewal <csgrewa@tycho.ncsc.mil>
Wed, 27 Feb 2013 06:07:38 +0000 (22:07 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 Mar 2013 08:38:44 +0000 (16:38 +0800)
Restrict log flushing to those in the logs group, or
anyone with CAP_SYSLOG.

Cc: Android Kernel Team <kernel-team@android.com>
Cc: Charndeep Grewal <csgrewa@tycho.ncsc.mil>
Signed-off-by: Charndeep Grewal <csgrewa@tycho.ncsc.mil>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/android/logger.c

index cfa606110cc20ab60687efcbb94de4b8fcf2f48e..b14a55742559986781331e2bdd10cd7711b01d5f 100644 (file)
@@ -695,6 +695,11 @@ static long logger_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                        ret = -EBADF;
                        break;
                }
+               if (!(in_egroup_p(file->f_dentry->d_inode->i_gid) ||
+                               capable(CAP_SYSLOG))) {
+                       ret = -EPERM;
+                       break;
+               }
                list_for_each_entry(reader, &log->readers, list)
                        reader->r_off = log->w_off;
                log->head = log->w_off;