diff options
| author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2009-10-04 08:49:47 -0400 |
|---|---|---|
| committer | James Morris <jmorris@namei.org> | 2009-10-11 19:56:00 -0400 |
| commit | 89eda06837094ce9f34fae269b8773fcfd70f046 (patch) | |
| tree | dc11701c68ebcc8346d7567cfb53b9c7327ef445 /security | |
| parent | 941fc5b2bf8f7dd1d0a9c502e152fa719ff6578e (diff) | |
LSM: Add security_path_chmod() and security_path_chown().
This patch allows pathname based LSM modules to check chmod()/chown()
operations. Since notify_change() does not receive "struct vfsmount *",
we add security_path_chmod() and security_path_chown() to the caller of
notify_change().
These hooks are used by TOMOYO.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security')
| -rw-r--r-- | security/capability.c | 13 | ||||
| -rw-r--r-- | security/security.c | 15 |
2 files changed, 28 insertions, 0 deletions
diff --git a/security/capability.c b/security/capability.c index fce07a7bc825..09279a8d4a14 100644 --- a/security/capability.c +++ b/security/capability.c | |||
| @@ -308,6 +308,17 @@ static int cap_path_truncate(struct path *path, loff_t length, | |||
| 308 | { | 308 | { |
| 309 | return 0; | 309 | return 0; |
| 310 | } | 310 | } |
| 311 | |||
| 312 | static int cap_path_chmod(struct dentry *dentry, struct vfsmount *mnt, | ||
| 313 | mode_t mode) | ||
| 314 | { | ||
| 315 | return 0; | ||
| 316 | } | ||
| 317 | |||
| 318 | static int cap_path_chown(struct path *path, uid_t uid, gid_t gid) | ||
| 319 | { | ||
| 320 | return 0; | ||
| 321 | } | ||
| 311 | #endif | 322 | #endif |
| 312 | 323 | ||
| 313 | static int cap_file_permission(struct file *file, int mask) | 324 | static int cap_file_permission(struct file *file, int mask) |
| @@ -977,6 +988,8 @@ void security_fixup_ops(struct security_operations *ops) | |||
| 977 | set_to_cap_if_null(ops, path_link); | 988 | set_to_cap_if_null(ops, path_link); |
| 978 | set_to_cap_if_null(ops, path_rename); | 989 | set_to_cap_if_null(ops, path_rename); |
| 979 | set_to_cap_if_null(ops, path_truncate); | 990 | set_to_cap_if_null(ops, path_truncate); |
| 991 | set_to_cap_if_null(ops, path_chmod); | ||
| 992 | set_to_cap_if_null(ops, path_chown); | ||
| 980 | #endif | 993 | #endif |
| 981 | set_to_cap_if_null(ops, file_permission); | 994 | set_to_cap_if_null(ops, file_permission); |
| 982 | set_to_cap_if_null(ops, file_alloc_security); | 995 | set_to_cap_if_null(ops, file_alloc_security); |
diff --git a/security/security.c b/security/security.c index c4c673240c1c..5259270e558f 100644 --- a/security/security.c +++ b/security/security.c | |||
| @@ -434,6 +434,21 @@ int security_path_truncate(struct path *path, loff_t length, | |||
| 434 | return 0; | 434 | return 0; |
| 435 | return security_ops->path_truncate(path, length, time_attrs); | 435 | return security_ops->path_truncate(path, length, time_attrs); |
| 436 | } | 436 | } |
| 437 | |||
| 438 | int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt, | ||
| 439 | mode_t mode) | ||
| 440 | { | ||
| 441 | if (unlikely(IS_PRIVATE(dentry->d_inode))) | ||
| 442 | return 0; | ||
| 443 | return security_ops->path_chmod(dentry, mnt, mode); | ||
| 444 | } | ||
| 445 | |||
| 446 | int security_path_chown(struct path *path, uid_t uid, gid_t gid) | ||
| 447 | { | ||
| 448 | if (unlikely(IS_PRIVATE(path->dentry->d_inode))) | ||
| 449 | return 0; | ||
| 450 | return security_ops->path_chown(path, uid, gid); | ||
| 451 | } | ||
| 437 | #endif | 452 | #endif |
| 438 | 453 | ||
| 439 | int security_inode_create(struct inode *dir, struct dentry *dentry, int mode) | 454 | int security_inode_create(struct inode *dir, struct dentry *dentry, int mode) |
