summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2004-01-18 18:38:13 -0800
committerLinus Torvalds <torvalds@home.osdl.org>2004-01-18 18:38:13 -0800
commitda6e57a2e6bd7939f610d957afacaf6a131e75ed (patch)
treef4ba93d7a37116b24d4e52dada4f65653e4a8581 /include/linux
parentfa9b605f51e1cb530f197f6bb608e72d9d778512 (diff)
[PATCH] selinux: Add SO_PEERSEC socket option and getpeersec LSM hook.
From: James Morris <jmorris@redhat.com> This patch adds a new option for Unix sockets, SO_PEERSEC, and an associated LSM hook, getpeersec. The SELinux handler is also included. The purpose of this is to allow applications to obtain each others security credentials, analagously to the existing SO_PEERCRED option. Examples of use are Security Enhanced D-BUS and Security Enhanced X. This patch was previously approved in principle by David, and has been updated with feedback from Chris Wright and extended to cover all architectures.
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/security.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/include/linux/security.h b/include/linux/security.h
index 9794223e8e17..06b2c60a48f8 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -757,6 +757,22 @@ struct swap_info_struct;
* incoming sk_buff @skb has been associated with a particular socket, @sk.
* @sk contains the sock (not socket) associated with the incoming sk_buff.
* @skb contains the incoming network data.
+ * @socket_getpeersec:
+ * This hook allows the security module to provide peer socket security
+ * state to userspace via getsockopt SO_GETPEERSEC.
+ * @sock is the local socket.
+ * @optval userspace memory where the security state is to be copied.
+ * @optlen userspace int where the module should copy the actual length
+ * of the security state.
+ * @len as input is the maximum length to copy to userspace provided
+ * by the caller.
+ * Return 0 if all is well, otherwise, typical getsockopt return
+ * values.
+ * @sk_alloc_security:
+ * Allocate and attach a security structure to the sk->sk_security field,
+ * which is used to copy security attributes between local stream sockets.
+ * @sk_free_security:
+ * Deallocate security structure.
*
* Security hooks affecting all System V IPC operations.
*
@@ -1183,6 +1199,9 @@ struct security_operations {
int (*socket_setsockopt) (struct socket * sock, int level, int optname);
int (*socket_shutdown) (struct socket * sock, int how);
int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
+ int (*socket_getpeersec) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
+ int (*sk_alloc_security) (struct sock *sk, int family, int priority);
+ void (*sk_free_security) (struct sock *sk);
#endif /* CONFIG_SECURITY_NETWORK */
};
@@ -2564,6 +2583,22 @@ static inline int security_sock_rcv_skb (struct sock * sk,
{
return security_ops->socket_sock_rcv_skb (sk, skb);
}
+
+static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
+ int __user *optlen, unsigned len)
+{
+ return security_ops->socket_getpeersec(sock, optval, optlen, len);
+}
+
+static inline int security_sk_alloc(struct sock *sk, int family, int priority)
+{
+ return security_ops->sk_alloc_security(sk, family, priority);
+}
+
+static inline void security_sk_free(struct sock *sk)
+{
+ return security_ops->sk_free_security(sk);
+}
#else /* CONFIG_SECURITY_NETWORK */
static inline int security_unix_stream_connect(struct socket * sock,
struct socket * other,
@@ -2664,6 +2699,21 @@ static inline int security_sock_rcv_skb (struct sock * sk,
{
return 0;
}
+
+static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
+ int __user *optlen, unsigned len)
+{
+ return -ENOPROTOOPT;
+}
+
+static inline int security_sk_alloc(struct sock *sk, int family, int priority)
+{
+ return 0;
+}
+
+static inline void security_sk_free(struct sock *sk)
+{
+}
#endif /* CONFIG_SECURITY_NETWORK */
#endif /* ! __LINUX_SECURITY_H */