[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1222463955.2872.223.camel@localhost.localdomain>
Date: Fri, 26 Sep 2008 17:19:15 -0400
From: Eric Paris <eparis@...hat.com>
To: linux-kernel@...r.kernel.org, malware-list@...ts.printk.net
Subject: [RFC 9/11] fanotify: send pid with fanotify notification events
fanotify: send pid with fanotify notification events
From: Eric Paris <eparis@...hat.com>
Often things like AV scanners may want to allow access to 'bad' files
based on the process making the access help by sending the pid of the
originally acting process.
Signed-off-by: Eric Paris <eparis@...hat.com>
---
fs/notify/fanotify.h | 1 +
fs/notify/notification.c | 2 ++
fs/notify/notification_user.c | 8 +++++---
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/fs/notify/fanotify.h b/fs/notify/fanotify.h
index cb97dbb..0394406 100644
--- a/fs/notify/fanotify.h
+++ b/fs/notify/fanotify.h
@@ -75,6 +75,7 @@ struct fanotify_event {
atomic_t refcnt; /* how many groups still are using/need to send this event */
/* if waiting for a userspace access answer this is the cookie they will send back */
unsigned long cookie;
+ pid_t pid; /* pid of the original process */
spinlock_t response_lock; /* protects response */
unsigned int response; /* userspace answer to question */
};
diff --git a/fs/notify/notification.c b/fs/notify/notification.c
index aa74137..d51411f 100644
--- a/fs/notify/notification.c
+++ b/fs/notify/notification.c
@@ -145,6 +145,8 @@ struct fanotify_event *create_event(struct file *file, unsigned int mask)
event->cookie = 0;
event->mask = mask;
+ event->pid = current->pid;
+
WARN_ON(!event->path.dentry);
WARN_ON(!event->path.mnt);
diff --git a/fs/notify/notification_user.c b/fs/notify/notification_user.c
index b492137..484260f 100644
--- a/fs/notify/notification_user.c
+++ b/fs/notify/notification_user.c
@@ -47,12 +47,13 @@
* "fd=%d " = 15 characters
* "mask=%x " = 14 characters
* "cookie=%lu "= 27 characters
+ * "pid=%d " = 16 characters
* "\n " = 2 characters
* NULL = 1 character
*
- * MAX_MESG_LEN = 59
+ * MAX_MESG_LEN = 75
*/
-#define MAX_MESG_LEN 59
+#define MAX_MESG_LEN 75
static ssize_t fanotify_notification_read(struct file *file, char __user *buf, size_t lenp, loff_t *offset)
{
@@ -133,7 +134,8 @@ static ssize_t fanotify_notification_read(struct file *file, char __user *buf, s
* Build metadata string to send to the listener
* IF YOU CHANGE THIS STRING UPDATE MAX_MSG_LEN!!!!!!11111!!!!
*/
- rc = snprintf(output, lenp-1, "fd=%d mask=%x cookie=%lu\n", client_fd, event->mask, event->cookie);
+ rc = snprintf(output, lenp-1, "fd=%d mask=%x cookie=%lu pid=%d\n",
+ client_fd, event->mask, event->cookie, event->pid);
if (rc < 0)
goto out;
output[rc] = '\0';
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists