aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2011-02-01 11:05:39 -0500
committerEric Paris <eparis@redhat.com>2011-02-01 11:12:29 -0500
commit2a7dba391e5628ad665ce84ef9a6648da541ebab (patch)
treeba0722bd74d2c883dbda7ff721850bab411cac04 /security
parent821404434f3324bf23f545050ff64055a149766e (diff)
fs/vfs/security: pass last path component to LSM on inode creation
SELinux would like to implement a new labeling behavior of newly created inodes. We currently label new inodes based on the parent and the creating process. This new behavior would also take into account the name of the new object when deciding the new label. This is not the (supposed) full path, just the last component of the path. This is very useful because creating /etc/shadow is different than creating /etc/passwd but the kernel hooks are unable to differentiate these operations. We currently require that userspace realize it is doing some difficult operation like that and than userspace jumps through SELinux hoops to get things set up correctly. This patch does not implement new behavior, that is obviously contained in a seperate SELinux patch, but it does pass the needed name down to the correct LSM hook. If no such name exists it is fine to pass NULL. Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'security')
-rw-r--r--security/capability.c3
-rw-r--r--security/security.c6
-rw-r--r--security/selinux/hooks.c5
-rw-r--r--security/smack/smack_lsm.c5
4 files changed, 13 insertions, 6 deletions
diff --git a/security/capability.c b/security/capability.c
index 2a5df2b7da83..383d14dc12ef 100644
--- a/security/capability.c
+++ b/security/capability.c
@@ -118,7 +118,8 @@ static void cap_inode_free_security(struct inode *inode)
118} 118}
119 119
120static int cap_inode_init_security(struct inode *inode, struct inode *dir, 120static int cap_inode_init_security(struct inode *inode, struct inode *dir,
121 char **name, void **value, size_t *len) 121 const struct qstr *qstr, char **name,
122 void **value, size_t *len)
122{ 123{
123 return -EOPNOTSUPP; 124 return -EOPNOTSUPP;
124} 125}
diff --git a/security/security.c b/security/security.c
index b84a89dd59c6..4830f36e1ab5 100644
--- a/security/security.c
+++ b/security/security.c
@@ -336,11 +336,13 @@ void security_inode_free(struct inode *inode)
336} 336}
337 337
338int security_inode_init_security(struct inode *inode, struct inode *dir, 338int security_inode_init_security(struct inode *inode, struct inode *dir,
339 char **name, void **value, size_t *len) 339 const struct qstr *qstr, char **name,
340 void **value, size_t *len)
340{ 341{
341 if (unlikely(IS_PRIVATE(inode))) 342 if (unlikely(IS_PRIVATE(inode)))
342 return -EOPNOTSUPP; 343 return -EOPNOTSUPP;
343 return security_ops->inode_init_security(inode, dir, name, value, len); 344 return security_ops->inode_init_security(inode, dir, qstr, name, value,
345 len);
344} 346}
345EXPORT_SYMBOL(security_inode_init_security); 347EXPORT_SYMBOL(security_inode_init_security);
346 348
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e276eb468536..099bbd07732f 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -39,6 +39,7 @@
39#include <linux/swap.h> 39#include <linux/swap.h>
40#include <linux/spinlock.h> 40#include <linux/spinlock.h>
41#include <linux/syscalls.h> 41#include <linux/syscalls.h>
42#include <linux/dcache.h>
42#include <linux/file.h> 43#include <linux/file.h>
43#include <linux/fdtable.h> 44#include <linux/fdtable.h>
44#include <linux/namei.h> 45#include <linux/namei.h>
@@ -2509,8 +2510,8 @@ static void selinux_inode_free_security(struct inode *inode)
2509} 2510}
2510 2511
2511static int selinux_inode_init_security(struct inode *inode, struct inode *dir, 2512static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
2512 char **name, void **value, 2513 const struct qstr *qstr, char **name,
2513 size_t *len) 2514 void **value, size_t *len)
2514{ 2515{
2515 const struct task_security_struct *tsec = current_security(); 2516 const struct task_security_struct *tsec = current_security();
2516 struct inode_security_struct *dsec; 2517 struct inode_security_struct *dsec;
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 123a499ded37..0c91a906b3f4 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -33,6 +33,7 @@
33#include <net/cipso_ipv4.h> 33#include <net/cipso_ipv4.h>
34#include <linux/audit.h> 34#include <linux/audit.h>
35#include <linux/magic.h> 35#include <linux/magic.h>
36#include <linux/dcache.h>
36#include "smack.h" 37#include "smack.h"
37 38
38#define task_security(task) (task_cred_xxx((task), security)) 39#define task_security(task) (task_cred_xxx((task), security))
@@ -501,6 +502,7 @@ static void smack_inode_free_security(struct inode *inode)
501 * smack_inode_init_security - copy out the smack from an inode 502 * smack_inode_init_security - copy out the smack from an inode
502 * @inode: the inode 503 * @inode: the inode
503 * @dir: unused 504 * @dir: unused
505 * @qstr: unused
504 * @name: where to put the attribute name 506 * @name: where to put the attribute name
505 * @value: where to put the attribute value 507 * @value: where to put the attribute value
506 * @len: where to put the length of the attribute 508 * @len: where to put the length of the attribute
@@ -508,7 +510,8 @@ static void smack_inode_free_security(struct inode *inode)
508 * Returns 0 if it all works out, -ENOMEM if there's no memory 510 * Returns 0 if it all works out, -ENOMEM if there's no memory
509 */ 511 */
510static int smack_inode_init_security(struct inode *inode, struct inode *dir, 512static int smack_inode_init_security(struct inode *inode, struct inode *dir,
511 char **name, void **value, size_t *len) 513 const struct qstr *qstr, char **name,
514 void **value, size_t *len)
512{ 515{
513 char *isp = smk_of_inode(inode); 516 char *isp = smk_of_inode(inode);
514 char *dsp = smk_of_inode(dir); 517 char *dsp = smk_of_inode(dir);