lkml.org 
[lkml]   [2008]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -v2 12/16] fanotify: user interface for access decisions
Date
turns out that access decisions are useless if there is no way to do
anything about them. So we add an interface. Alan will hate it, but at
least it works...

Signed-off-by: Eric Paris <eparis@redhat.com>
---

include/linux/fanotify.h | 7 +++++++
net/fanotify/af_fanotify.c | 11 ++++++++++-
2 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/include/linux/fanotify.h b/include/linux/fanotify.h
index 07b8e77..b5c9db9 100644
--- a/include/linux/fanotify.h
+++ b/include/linux/fanotify.h
@@ -81,8 +81,15 @@ struct fanotify_so_fastpath {
uint32_t mask;
};

+/* struct used for FANOTIFY_SEND_RESPONSE */
+struct fanotify_so_access {
+ uint64_t cookie;
+ uint32_t response;
+};
+
/* fanotify setsockopt optvals */
#define FANOTIFY_SET_FASTPATH 1
+#define FANOTIFY_SEND_RESPONSE 2

#ifdef __KERNEL__

diff --git a/net/fanotify/af_fanotify.c b/net/fanotify/af_fanotify.c
index a7d3b96..89099ab 100644
--- a/net/fanotify/af_fanotify.c
+++ b/net/fanotify/af_fanotify.c
@@ -164,6 +164,7 @@ static int fan_setsockopt(struct socket *sock, int level, int optname, char __us
struct fanotify_sock *fan_sock;
struct fanotify_group *group;
struct fanotify_so_fastpath fp_data;
+ struct fanotify_so_access access_data;
int ret = 0;

if (sock->state != SS_CONNECTED)
@@ -179,7 +180,15 @@ static int fan_setsockopt(struct socket *sock, int level, int optname, char __us
ret = copy_from_user(&fp_data, optval, sizeof(struct fanotify_so_fastpath));
if (ret)
return ret;
- fanotify_fastpath_add(group, fp_data.fd, fp_data.mask);
+ ret = fanotify_fastpath_add(group, fp_data.fd, fp_data.mask);
+ break;
+ case FANOTIFY_SEND_RESPONSE:
+ if (optlen < sizeof(struct fanotify_so_access))
+ return -ENOMEM;
+ ret = copy_from_user(&access_data, optval, sizeof(struct fanotify_so_access));
+ if (ret)
+ return ret;
+ ret = fanotify_process_access_response(group, access_data.cookie, access_data.response);
break;
default:
return -ENOPROTOOPT;


\
 
 \ /
  Last update: 2008-10-14 22:59    [W:0.116 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site