aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAhmed S. Darwish <darwish.07@gmail.com>2008-03-01 14:51:09 -0500
committerJames Morris <jmorris@namei.org>2008-04-18 19:52:32 -0400
commit8a076191f373abaeb4aa5f6755d22e49db98940f (patch)
tree1311a11332abb0828999a7347a07509a68dffb5f /include
parentd1a4be630fb068f251d64b62919f143c49ca8057 (diff)
LSM: Introduce inode_getsecid and ipc_getsecid hooks
Introduce inode_getsecid(inode, secid) and ipc_getsecid(ipcp, secid) LSM hooks. These hooks will be used instead of similar exported SELinux interfaces. Let {inode,ipc,task}_getsecid hooks set the secid to 0 by default if CONFIG_SECURITY is not defined or if the hook is set to NULL (dummy). This is done to notify the caller that no valid secid exists. Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com> Acked-by: James Morris <jmorris@namei.org> Reviewed-by: Paul Moore <paul.moore@hp.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/security.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/include/linux/security.h b/include/linux/security.h
index c673dfd4dffc..45717d9d9656 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -468,6 +468,11 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
468 * @dentry is the dentry being changed. 468 * @dentry is the dentry being changed.
469 * Return 0 on success. If error is returned, then the operation 469 * Return 0 on success. If error is returned, then the operation
470 * causing setuid bit removal is failed. 470 * causing setuid bit removal is failed.
471 * @inode_getsecid:
472 * Get the secid associated with the node.
473 * @inode contains a pointer to the inode.
474 * @secid contains a pointer to the location where result will be saved.
475 * In case of failure, @secid will be set to zero.
471 * 476 *
472 * Security hooks for file operations 477 * Security hooks for file operations
473 * 478 *
@@ -636,6 +641,8 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
636 * @task_getsecid: 641 * @task_getsecid:
637 * Retrieve the security identifier of the process @p. 642 * Retrieve the security identifier of the process @p.
638 * @p contains the task_struct for the process and place is into @secid. 643 * @p contains the task_struct for the process and place is into @secid.
644 * In case of failure, @secid will be set to zero.
645 *
639 * @task_setgroups: 646 * @task_setgroups:
640 * Check permission before setting the supplementary group set of the 647 * Check permission before setting the supplementary group set of the
641 * current process. 648 * current process.
@@ -997,6 +1004,11 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
997 * @ipcp contains the kernel IPC permission structure 1004 * @ipcp contains the kernel IPC permission structure
998 * @flag contains the desired (requested) permission set 1005 * @flag contains the desired (requested) permission set
999 * Return 0 if permission is granted. 1006 * Return 0 if permission is granted.
1007 * @ipc_getsecid:
1008 * Get the secid associated with the ipc object.
1009 * @ipcp contains the kernel IPC permission structure.
1010 * @secid contains a pointer to the location where result will be saved.
1011 * In case of failure, @secid will be set to zero.
1000 * 1012 *
1001 * Security hooks for individual messages held in System V IPC message queues 1013 * Security hooks for individual messages held in System V IPC message queues
1002 * @msg_msg_alloc_security: 1014 * @msg_msg_alloc_security:
@@ -1317,6 +1329,7 @@ struct security_operations {
1317 int (*inode_getsecurity)(const struct inode *inode, const char *name, void **buffer, bool alloc); 1329 int (*inode_getsecurity)(const struct inode *inode, const char *name, void **buffer, bool alloc);
1318 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags); 1330 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1319 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size); 1331 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1332 void (*inode_getsecid)(const struct inode *inode, u32 *secid);
1320 1333
1321 int (*file_permission) (struct file * file, int mask); 1334 int (*file_permission) (struct file * file, int mask);
1322 int (*file_alloc_security) (struct file * file); 1335 int (*file_alloc_security) (struct file * file);
@@ -1369,6 +1382,7 @@ struct security_operations {
1369 void (*task_to_inode)(struct task_struct *p, struct inode *inode); 1382 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1370 1383
1371 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag); 1384 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1385 void (*ipc_getsecid) (struct kern_ipc_perm *ipcp, u32 *secid);
1372 1386
1373 int (*msg_msg_alloc_security) (struct msg_msg * msg); 1387 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1374 void (*msg_msg_free_security) (struct msg_msg * msg); 1388 void (*msg_msg_free_security) (struct msg_msg * msg);
@@ -1578,6 +1592,7 @@ int security_inode_killpriv(struct dentry *dentry);
1578int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc); 1592int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc);
1579int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags); 1593int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1580int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size); 1594int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
1595void security_inode_getsecid(const struct inode *inode, u32 *secid);
1581int security_file_permission(struct file *file, int mask); 1596int security_file_permission(struct file *file, int mask);
1582int security_file_alloc(struct file *file); 1597int security_file_alloc(struct file *file);
1583void security_file_free(struct file *file); 1598void security_file_free(struct file *file);
@@ -1622,6 +1637,7 @@ int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
1622void security_task_reparent_to_init(struct task_struct *p); 1637void security_task_reparent_to_init(struct task_struct *p);
1623void security_task_to_inode(struct task_struct *p, struct inode *inode); 1638void security_task_to_inode(struct task_struct *p, struct inode *inode);
1624int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag); 1639int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
1640void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
1625int security_msg_msg_alloc(struct msg_msg *msg); 1641int security_msg_msg_alloc(struct msg_msg *msg);
1626void security_msg_msg_free(struct msg_msg *msg); 1642void security_msg_msg_free(struct msg_msg *msg);
1627int security_msg_queue_alloc(struct msg_queue *msq); 1643int security_msg_queue_alloc(struct msg_queue *msq);
@@ -2022,6 +2038,11 @@ static inline int security_inode_listsecurity(struct inode *inode, char *buffer,
2022 return 0; 2038 return 0;
2023} 2039}
2024 2040
2041static inline void security_inode_getsecid(const struct inode *inode, u32 *secid)
2042{
2043 *secid = 0;
2044}
2045
2025static inline int security_file_permission (struct file *file, int mask) 2046static inline int security_file_permission (struct file *file, int mask)
2026{ 2047{
2027 return 0; 2048 return 0;
@@ -2137,7 +2158,9 @@ static inline int security_task_getsid (struct task_struct *p)
2137} 2158}
2138 2159
2139static inline void security_task_getsecid (struct task_struct *p, u32 *secid) 2160static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
2140{ } 2161{
2162 *secid = 0;
2163}
2141 2164
2142static inline int security_task_setgroups (struct group_info *group_info) 2165static inline int security_task_setgroups (struct group_info *group_info)
2143{ 2166{
@@ -2216,6 +2239,11 @@ static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2216 return 0; 2239 return 0;
2217} 2240}
2218 2241
2242static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
2243{
2244 *secid = 0;
2245}
2246
2219static inline int security_msg_msg_alloc (struct msg_msg * msg) 2247static inline int security_msg_msg_alloc (struct msg_msg * msg)
2220{ 2248{
2221 return 0; 2249 return 0;