diff mbox

[5/5] staging: android: logger: enforce GID and CAP check on log flush

Message ID 1361945258-24420-6-git-send-email-john.stultz@linaro.org
State Accepted
Commit 1e70bd46a5a950b7ba319e50bdfed9d20ed9fd73
Headers show

Commit Message

John Stultz Feb. 27, 2013, 6:07 a.m. UTC
From: Charndeep Grewal <csgrewa@tycho.ncsc.mil>

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>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Charndeep Grewal <csgrewa@tycho.ncsc.mil>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 drivers/staging/android/logger.c |    5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c
index cfa6061..b14a557 100644
--- a/drivers/staging/android/logger.c
+++ b/drivers/staging/android/logger.c
@@ -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;