diff options
Diffstat (limited to 'security/security.c')
-rw-r--r-- | security/security.c | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/security/security.c b/security/security.c index 7da630a8c065..b98334b0a576 100644 --- a/security/security.c +++ b/security/security.c | |||
@@ -23,10 +23,12 @@ static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] = | |||
23 | CONFIG_DEFAULT_SECURITY; | 23 | CONFIG_DEFAULT_SECURITY; |
24 | 24 | ||
25 | /* things that live in capability.c */ | 25 | /* things that live in capability.c */ |
26 | extern struct security_operations default_security_ops; | ||
27 | extern void security_fixup_ops(struct security_operations *ops); | 26 | extern void security_fixup_ops(struct security_operations *ops); |
28 | 27 | ||
29 | struct security_operations *security_ops; /* Initialized to NULL */ | 28 | static struct security_operations *security_ops; |
29 | static struct security_operations default_security_ops = { | ||
30 | .name = "default", | ||
31 | }; | ||
30 | 32 | ||
31 | static inline int verify(struct security_operations *ops) | 33 | static inline int verify(struct security_operations *ops) |
32 | { | 34 | { |
@@ -63,6 +65,11 @@ int __init security_init(void) | |||
63 | return 0; | 65 | return 0; |
64 | } | 66 | } |
65 | 67 | ||
68 | void reset_security_ops(void) | ||
69 | { | ||
70 | security_ops = &default_security_ops; | ||
71 | } | ||
72 | |||
66 | /* Save user chosen LSM */ | 73 | /* Save user chosen LSM */ |
67 | static int __init choose_lsm(char *str) | 74 | static int __init choose_lsm(char *str) |
68 | { | 75 | { |
@@ -203,9 +210,9 @@ int security_quota_on(struct dentry *dentry) | |||
203 | return security_ops->quota_on(dentry); | 210 | return security_ops->quota_on(dentry); |
204 | } | 211 | } |
205 | 212 | ||
206 | int security_syslog(int type) | 213 | int security_syslog(int type, bool from_file) |
207 | { | 214 | { |
208 | return security_ops->syslog(type); | 215 | return security_ops->syslog(type, from_file); |
209 | } | 216 | } |
210 | 217 | ||
211 | int security_settime(struct timespec *ts, struct timezone *tz) | 218 | int security_settime(struct timespec *ts, struct timezone *tz) |
@@ -389,42 +396,42 @@ int security_inode_init_security(struct inode *inode, struct inode *dir, | |||
389 | EXPORT_SYMBOL(security_inode_init_security); | 396 | EXPORT_SYMBOL(security_inode_init_security); |
390 | 397 | ||
391 | #ifdef CONFIG_SECURITY_PATH | 398 | #ifdef CONFIG_SECURITY_PATH |
392 | int security_path_mknod(struct path *path, struct dentry *dentry, int mode, | 399 | int security_path_mknod(struct path *dir, struct dentry *dentry, int mode, |
393 | unsigned int dev) | 400 | unsigned int dev) |
394 | { | 401 | { |
395 | if (unlikely(IS_PRIVATE(path->dentry->d_inode))) | 402 | if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
396 | return 0; | 403 | return 0; |
397 | return security_ops->path_mknod(path, dentry, mode, dev); | 404 | return security_ops->path_mknod(dir, dentry, mode, dev); |
398 | } | 405 | } |
399 | EXPORT_SYMBOL(security_path_mknod); | 406 | EXPORT_SYMBOL(security_path_mknod); |
400 | 407 | ||
401 | int security_path_mkdir(struct path *path, struct dentry *dentry, int mode) | 408 | int security_path_mkdir(struct path *dir, struct dentry *dentry, int mode) |
402 | { | 409 | { |
403 | if (unlikely(IS_PRIVATE(path->dentry->d_inode))) | 410 | if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
404 | return 0; | 411 | return 0; |
405 | return security_ops->path_mkdir(path, dentry, mode); | 412 | return security_ops->path_mkdir(dir, dentry, mode); |
406 | } | 413 | } |
407 | 414 | ||
408 | int security_path_rmdir(struct path *path, struct dentry *dentry) | 415 | int security_path_rmdir(struct path *dir, struct dentry *dentry) |
409 | { | 416 | { |
410 | if (unlikely(IS_PRIVATE(path->dentry->d_inode))) | 417 | if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
411 | return 0; | 418 | return 0; |
412 | return security_ops->path_rmdir(path, dentry); | 419 | return security_ops->path_rmdir(dir, dentry); |
413 | } | 420 | } |
414 | 421 | ||
415 | int security_path_unlink(struct path *path, struct dentry *dentry) | 422 | int security_path_unlink(struct path *dir, struct dentry *dentry) |
416 | { | 423 | { |
417 | if (unlikely(IS_PRIVATE(path->dentry->d_inode))) | 424 | if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
418 | return 0; | 425 | return 0; |
419 | return security_ops->path_unlink(path, dentry); | 426 | return security_ops->path_unlink(dir, dentry); |
420 | } | 427 | } |
421 | 428 | ||
422 | int security_path_symlink(struct path *path, struct dentry *dentry, | 429 | int security_path_symlink(struct path *dir, struct dentry *dentry, |
423 | const char *old_name) | 430 | const char *old_name) |
424 | { | 431 | { |
425 | if (unlikely(IS_PRIVATE(path->dentry->d_inode))) | 432 | if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
426 | return 0; | 433 | return 0; |
427 | return security_ops->path_symlink(path, dentry, old_name); | 434 | return security_ops->path_symlink(dir, dentry, old_name); |
428 | } | 435 | } |
429 | 436 | ||
430 | int security_path_link(struct dentry *old_dentry, struct path *new_dir, | 437 | int security_path_link(struct dentry *old_dentry, struct path *new_dir, |
@@ -630,14 +637,14 @@ int security_inode_killpriv(struct dentry *dentry) | |||
630 | int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc) | 637 | int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc) |
631 | { | 638 | { |
632 | if (unlikely(IS_PRIVATE(inode))) | 639 | if (unlikely(IS_PRIVATE(inode))) |
633 | return 0; | 640 | return -EOPNOTSUPP; |
634 | return security_ops->inode_getsecurity(inode, name, buffer, alloc); | 641 | return security_ops->inode_getsecurity(inode, name, buffer, alloc); |
635 | } | 642 | } |
636 | 643 | ||
637 | int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags) | 644 | int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags) |
638 | { | 645 | { |
639 | if (unlikely(IS_PRIVATE(inode))) | 646 | if (unlikely(IS_PRIVATE(inode))) |
640 | return 0; | 647 | return -EOPNOTSUPP; |
641 | return security_ops->inode_setsecurity(inode, name, value, size, flags); | 648 | return security_ops->inode_setsecurity(inode, name, value, size, flags); |
642 | } | 649 | } |
643 | 650 | ||