libata: HPA support
[safe/jmp/linux-2.6] / include / linux / security.h
index 8e3dc6c..47e82c1 100644 (file)
@@ -90,6 +90,7 @@ extern int cap_netlink_recv(struct sk_buff *skb, int cap);
 struct nfsctl_arg;
 struct sched_param;
 struct swap_info_struct;
+struct request_sock;
 
 /* bprm_apply_creds unsafe reasons */
 #define LSM_UNSAFE_SHARE       1
@@ -491,7 +492,7 @@ struct swap_info_struct;
  *     Note that the fown_struct, @fown, is never outside the context of a
  *     struct file, so the file structure (and associated security information)
  *     can always be obtained:
- *             (struct file *)((long)fown - offsetof(struct file,f_owner));
+ *             container_of(fown, struct file, f_owner)
  *     @tsk contains the structure of task receiving signal.
  *     @fown contains the file owner information.
  *     @sig is the signal that will be sent.  When 0, kernel sends SIGIO.
@@ -819,6 +820,16 @@ struct swap_info_struct;
  * @sk_getsecid:
  *     Retrieve the LSM-specific secid for the sock to enable caching of network
  *     authorizations.
+ * @sock_graft:
+ *     Sets the socket's isec sid to the sock's sid.
+ * @inet_conn_request:
+ *     Sets the openreq's sid to socket's sid with MLS portion taken from peer sid.
+ * @inet_csk_clone:
+ *     Sets the new child socket's sid to the openreq sid.
+ * @inet_conn_established:
+ *     Sets the connection's peersid to the secmark on skb.
+ * @req_classify_flow:
+ *     Sets the flow's sid to the openreq sid.
  *
  * Security hooks for XFRM operations.
  *
@@ -827,10 +838,8 @@ struct swap_info_struct;
  *     used by the XFRM system.
  *     @sec_ctx contains the security context information being provided by
  *     the user-level policy update program (e.g., setkey).
- *     @sk refers to the sock from which to derive the security context.
  *     Allocate a security structure to the xp->security field; the security
- *     field is initialized to NULL when the xfrm_policy is allocated. Only
- *     one of sec_ctx or sock can be specified.
+ *     field is initialized to NULL when the xfrm_policy is allocated.
  *     Return 0 if operation was successful (memory to allocate, legal context)
  * @xfrm_policy_clone_security:
  *     @old contains an existing xfrm_policy in the SPD.
@@ -849,9 +858,6 @@ struct swap_info_struct;
  *     Database by the XFRM system.
  *     @sec_ctx contains the security context information being provided by
  *     the user-level SA generation program (e.g., setkey or racoon).
- *     @polsec contains the security context information associated with a xfrm
- *     policy rule from which to take the base context. polsec must be NULL
- *     when sec_ctx is specified.
  *     @secid contains the secid from which to take the mls portion of the context.
  *     Allocate a security structure to the x->security field; the security
  *     field is initialized to NULL when the xfrm_state is allocated. Set the
@@ -873,16 +879,13 @@ struct swap_info_struct;
  *     Check permission when a flow selects a xfrm_policy for processing
  *     XFRMs on a packet.  The hook is called when selecting either a
  *     per-socket policy or a generic xfrm policy.
- *     Return 0 if permission is granted.
+ *     Return 0 if permission is granted, -ESRCH otherwise, or -errno
+ *     on other errors.
  * @xfrm_state_pol_flow_match:
  *     @x contains the state to match.
  *     @xp contains the policy to check for a match.
  *     @fl contains the flow to check for a match.
  *     Return 1 if there is a match.
- * @xfrm_flow_state_match:
- *     @fl contains the flow key to match.
- *     @xfrm points to the xfrm_state to match.
- *     Return 1 if there is a match.
  * @xfrm_decode_session:
  *     @skb points to skb to decode.
  *     @secid points to the flow key secid to set.
@@ -1321,7 +1324,7 @@ struct security_operations {
 
        void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
 
-       int (*getprocattr)(struct task_struct *p, char *name, void *value, size_t size);
+       int (*getprocattr)(struct task_struct *p, char *name, char **value);
        int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
        int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
        void (*release_secctx)(char *secdata, u32 seclen);
@@ -1332,8 +1335,8 @@ struct security_operations {
        int (*unix_may_send) (struct socket * sock, struct socket * other);
 
        int (*socket_create) (int family, int type, int protocol, int kern);
-       void (*socket_post_create) (struct socket * sock, int family,
-                                   int type, int protocol, int kern);
+       int (*socket_post_create) (struct socket * sock, int family,
+                                  int type, int protocol, int kern);
        int (*socket_bind) (struct socket * sock,
                            struct sockaddr * address, int addrlen);
        int (*socket_connect) (struct socket * sock,
@@ -1358,23 +1361,28 @@ struct security_operations {
        void (*sk_free_security) (struct sock *sk);
        void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
        void (*sk_getsecid) (struct sock *sk, u32 *secid);
+       void (*sock_graft)(struct sock* sk, struct socket *parent);
+       int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb,
+                                       struct request_sock *req);
+       void (*inet_csk_clone)(struct sock *newsk, const struct request_sock *req);
+       void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb);
+       void (*req_classify_flow)(const struct request_sock *req, struct flowi *fl);
 #endif /* CONFIG_SECURITY_NETWORK */
 
 #ifdef CONFIG_SECURITY_NETWORK_XFRM
        int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp,
-                       struct xfrm_user_sec_ctx *sec_ctx, struct sock *sk);
+                       struct xfrm_user_sec_ctx *sec_ctx);
        int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
        void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
        int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
        int (*xfrm_state_alloc_security) (struct xfrm_state *x,
-               struct xfrm_user_sec_ctx *sec_ctx, struct xfrm_sec_ctx *polsec,
+               struct xfrm_user_sec_ctx *sec_ctx,
                u32 secid);
        void (*xfrm_state_free_security) (struct xfrm_state *x);
        int (*xfrm_state_delete_security) (struct xfrm_state *x);
        int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
        int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
                        struct xfrm_policy *xp, struct flowi *fl);
-       int (*xfrm_flow_state_match)(struct flowi *fl, struct xfrm_state *xfrm);
        int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
 
@@ -1581,6 +1589,7 @@ static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
 
 static inline int security_inode_alloc (struct inode *inode)
 {
+       inode->i_security = NULL;
        return security_ops->inode_alloc_security (inode);
 }
 
@@ -2083,9 +2092,9 @@ static inline void security_d_instantiate (struct dentry *dentry, struct inode *
        security_ops->d_instantiate (dentry, inode);
 }
 
-static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
+static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
 {
-       return security_ops->getprocattr(p, name, value, size);
+       return security_ops->getprocattr(p, name, value);
 }
 
 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
@@ -2121,7 +2130,7 @@ extern int mod_reg_security       (const char *name, struct security_operations *ops);
 extern int mod_unreg_security  (const char *name, struct security_operations *ops);
 extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
                                             struct dentry *parent, void *data,
-                                            struct file_operations *fops);
+                                            const struct file_operations *fops);
 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
 extern void securityfs_remove(struct dentry *dentry);
 
@@ -2740,7 +2749,7 @@ static inline int security_sem_semop (struct sem_array * sma,
 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
 { }
 
-static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
+static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
 {
        return -EINVAL;
 }
@@ -2810,13 +2819,13 @@ static inline int security_socket_create (int family, int type,
        return security_ops->socket_create(family, type, protocol, kern);
 }
 
-static inline void security_socket_post_create(struct socket * sock, 
-                                              int family,
-                                              int type, 
-                                              int protocol, int kern)
+static inline int security_socket_post_create(struct socket * sock,
+                                             int family,
+                                             int type,
+                                             int protocol, int kern)
 {
-       security_ops->socket_post_create(sock, family, type,
-                                        protocol, kern);
+       return security_ops->socket_post_create(sock, family, type,
+                                               protocol, kern);
 }
 
 static inline int security_socket_bind(struct socket * sock, 
@@ -2926,9 +2935,37 @@ static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
 {
        security_ops->sk_getsecid(sk, &fl->secid);
 }
+
+static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
+{
+       security_ops->req_classify_flow(req, fl);
+}
+
+static inline void security_sock_graft(struct sock* sk, struct socket *parent)
+{
+       security_ops->sock_graft(sk, parent);
+}
+
+static inline int security_inet_conn_request(struct sock *sk,
+                       struct sk_buff *skb, struct request_sock *req)
+{
+       return security_ops->inet_conn_request(sk, skb, req);
+}
+
+static inline void security_inet_csk_clone(struct sock *newsk,
+                       const struct request_sock *req)
+{
+       security_ops->inet_csk_clone(newsk, req);
+}
+
+static inline void security_inet_conn_established(struct sock *sk,
+                       struct sk_buff *skb)
+{
+       security_ops->inet_conn_established(sk, skb);
+}
 #else  /* CONFIG_SECURITY_NETWORK */
 static inline int security_unix_stream_connect(struct socket * sock,
-                                              struct socket * other, 
+                                              struct socket * other,
                                               struct sock * newsk)
 {
        return 0;
@@ -2946,11 +2983,12 @@ static inline int security_socket_create (int family, int type,
        return 0;
 }
 
-static inline void security_socket_post_create(struct socket * sock, 
-                                              int family,
-                                              int type, 
-                                              int protocol, int kern)
+static inline int security_socket_post_create(struct socket * sock,
+                                             int family,
+                                             int type,
+                                             int protocol, int kern)
 {
+       return 0;
 }
 
 static inline int security_socket_bind(struct socket * sock, 
@@ -3055,17 +3093,36 @@ static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
 static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
 {
 }
-#endif /* CONFIG_SECURITY_NETWORK */
 
-#ifdef CONFIG_SECURITY_NETWORK_XFRM
-static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
+static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
 {
-       return security_ops->xfrm_policy_alloc_security(xp, sec_ctx, NULL);
 }
 
-static inline int security_xfrm_sock_policy_alloc(struct xfrm_policy *xp, struct sock *sk)
+static inline void security_sock_graft(struct sock* sk, struct socket *parent)
 {
-       return security_ops->xfrm_policy_alloc_security(xp, NULL, sk);
+}
+
+static inline int security_inet_conn_request(struct sock *sk,
+                       struct sk_buff *skb, struct request_sock *req)
+{
+       return 0;
+}
+
+static inline void security_inet_csk_clone(struct sock *newsk,
+                       const struct request_sock *req)
+{
+}
+
+static inline void security_inet_conn_established(struct sock *sk,
+                       struct sk_buff *skb)
+{
+}
+#endif /* CONFIG_SECURITY_NETWORK */
+
+#ifdef CONFIG_SECURITY_NETWORK_XFRM
+static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
+{
+       return security_ops->xfrm_policy_alloc_security(xp, sec_ctx);
 }
 
 static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
@@ -3086,7 +3143,7 @@ static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
                        struct xfrm_user_sec_ctx *sec_ctx)
 {
-       return security_ops->xfrm_state_alloc_security(x, sec_ctx, NULL, 0);
+       return security_ops->xfrm_state_alloc_security(x, sec_ctx, 0);
 }
 
 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
@@ -3094,7 +3151,11 @@ static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
 {
        if (!polsec)
                return 0;
-       return security_ops->xfrm_state_alloc_security(x, NULL, polsec, secid);
+       /*
+        * We want the context to be taken from secid which is usually
+        * from the sock.
+        */
+       return security_ops->xfrm_state_alloc_security(x, NULL, secid);
 }
 
 static inline int security_xfrm_state_delete(struct xfrm_state *x)
@@ -3118,11 +3179,6 @@ static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
        return security_ops->xfrm_state_pol_flow_match(x, xp, fl);
 }
 
-static inline int security_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm)
-{
-       return security_ops->xfrm_flow_state_match(fl, xfrm);
-}
-
 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
 {
        return security_ops->xfrm_decode_session(skb, secid, 1);
@@ -3140,11 +3196,6 @@ static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm
        return 0;
 }
 
-static inline int security_xfrm_sock_policy_alloc(struct xfrm_policy *xp, struct sock *sk)
-{
-       return 0;
-}
-
 static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
 {
        return 0;
@@ -3191,12 +3242,6 @@ static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
        return 1;
 }
 
-static inline int security_xfrm_flow_state_match(struct flowi *fl,
-                                struct xfrm_state *xfrm)
-{
-       return 1;
-}
-
 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
 {
        return 0;