diff options
author | Richard Guy Briggs <rgb@redhat.com> | 2015-08-05 23:48:20 -0400 |
---|---|---|
committer | Paul Moore <pmoore@redhat.com> | 2015-08-06 14:39:02 -0400 |
commit | 84cb777e67814f2e06a99ff228f743409e9617e9 (patch) | |
tree | 86cbb87dbab8defa95a45de645c6a53a708c67db | |
parent | 8c85fc9ae69a4510ba5e2bd5fac2c1d9d60967ad (diff) |
audit: use macros for unset inode and device values
Clean up a number of places were casted magic numbers are used to represent
unset inode and device numbers in preparation for the audit by executable path
patch set.
Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
[PM: enclosed the _UNSET macros in parentheses for ./scripts/checkpatch]
Signed-off-by: Paul Moore <pmoore@redhat.com>
-rw-r--r-- | include/linux/audit.h | 3 | ||||
-rw-r--r-- | kernel/audit.c | 2 | ||||
-rw-r--r-- | kernel/audit_watch.c | 8 | ||||
-rw-r--r-- | kernel/auditsc.c | 6 |
4 files changed, 11 insertions, 8 deletions
diff --git a/include/linux/audit.h b/include/linux/audit.h index c2e7e3a83965..759feb0e9d13 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h | |||
@@ -27,6 +27,9 @@ | |||
27 | #include <linux/ptrace.h> | 27 | #include <linux/ptrace.h> |
28 | #include <uapi/linux/audit.h> | 28 | #include <uapi/linux/audit.h> |
29 | 29 | ||
30 | #define AUDIT_INO_UNSET ((unsigned long)-1) | ||
31 | #define AUDIT_DEV_UNSET ((dev_t)-1) | ||
32 | |||
30 | struct audit_sig_info { | 33 | struct audit_sig_info { |
31 | uid_t uid; | 34 | uid_t uid; |
32 | pid_t pid; | 35 | pid_t pid; |
diff --git a/kernel/audit.c b/kernel/audit.c index 7497a5a0fac0..060153dc47d4 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -1759,7 +1759,7 @@ void audit_log_name(struct audit_context *context, struct audit_names *n, | |||
1759 | } else | 1759 | } else |
1760 | audit_log_format(ab, " name=(null)"); | 1760 | audit_log_format(ab, " name=(null)"); |
1761 | 1761 | ||
1762 | if (n->ino != (unsigned long)-1) { | 1762 | if (n->ino != AUDIT_INO_UNSET) { |
1763 | audit_log_format(ab, " inode=%lu" | 1763 | audit_log_format(ab, " inode=%lu" |
1764 | " dev=%02x:%02x mode=%#ho" | 1764 | " dev=%02x:%02x mode=%#ho" |
1765 | " ouid=%u ogid=%u rdev=%02x:%02x", | 1765 | " ouid=%u ogid=%u rdev=%02x:%02x", |
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c index b81ad5bc7485..645c6884cee5 100644 --- a/kernel/audit_watch.c +++ b/kernel/audit_watch.c | |||
@@ -138,7 +138,7 @@ char *audit_watch_path(struct audit_watch *watch) | |||
138 | 138 | ||
139 | int audit_watch_compare(struct audit_watch *watch, unsigned long ino, dev_t dev) | 139 | int audit_watch_compare(struct audit_watch *watch, unsigned long ino, dev_t dev) |
140 | { | 140 | { |
141 | return (watch->ino != (unsigned long)-1) && | 141 | return (watch->ino != AUDIT_INO_UNSET) && |
142 | (watch->ino == ino) && | 142 | (watch->ino == ino) && |
143 | (watch->dev == dev); | 143 | (watch->dev == dev); |
144 | } | 144 | } |
@@ -179,8 +179,8 @@ static struct audit_watch *audit_init_watch(char *path) | |||
179 | INIT_LIST_HEAD(&watch->rules); | 179 | INIT_LIST_HEAD(&watch->rules); |
180 | atomic_set(&watch->count, 1); | 180 | atomic_set(&watch->count, 1); |
181 | watch->path = path; | 181 | watch->path = path; |
182 | watch->dev = (dev_t)-1; | 182 | watch->dev = AUDIT_DEV_UNSET; |
183 | watch->ino = (unsigned long)-1; | 183 | watch->ino = AUDIT_INO_UNSET; |
184 | 184 | ||
185 | return watch; | 185 | return watch; |
186 | } | 186 | } |
@@ -493,7 +493,7 @@ static int audit_watch_handle_event(struct fsnotify_group *group, | |||
493 | if (mask & (FS_CREATE|FS_MOVED_TO) && inode) | 493 | if (mask & (FS_CREATE|FS_MOVED_TO) && inode) |
494 | audit_update_watch(parent, dname, inode->i_sb->s_dev, inode->i_ino, 0); | 494 | audit_update_watch(parent, dname, inode->i_sb->s_dev, inode->i_ino, 0); |
495 | else if (mask & (FS_DELETE|FS_MOVED_FROM)) | 495 | else if (mask & (FS_DELETE|FS_MOVED_FROM)) |
496 | audit_update_watch(parent, dname, (dev_t)-1, (unsigned long)-1, 1); | 496 | audit_update_watch(parent, dname, AUDIT_DEV_UNSET, AUDIT_INO_UNSET, 1); |
497 | else if (mask & (FS_DELETE_SELF|FS_UNMOUNT|FS_MOVE_SELF)) | 497 | else if (mask & (FS_DELETE_SELF|FS_UNMOUNT|FS_MOVE_SELF)) |
498 | audit_remove_parent_watches(parent); | 498 | audit_remove_parent_watches(parent); |
499 | 499 | ||
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index f6bc31e7dca9..ea3fe2b748a8 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
@@ -180,7 +180,7 @@ static int audit_match_filetype(struct audit_context *ctx, int val) | |||
180 | return 0; | 180 | return 0; |
181 | 181 | ||
182 | list_for_each_entry(n, &ctx->names_list, list) { | 182 | list_for_each_entry(n, &ctx->names_list, list) { |
183 | if ((n->ino != -1) && | 183 | if ((n->ino != AUDIT_INO_UNSET) && |
184 | ((n->mode & S_IFMT) == mode)) | 184 | ((n->mode & S_IFMT) == mode)) |
185 | return 1; | 185 | return 1; |
186 | } | 186 | } |
@@ -1681,7 +1681,7 @@ static struct audit_names *audit_alloc_name(struct audit_context *context, | |||
1681 | aname->should_free = true; | 1681 | aname->should_free = true; |
1682 | } | 1682 | } |
1683 | 1683 | ||
1684 | aname->ino = (unsigned long)-1; | 1684 | aname->ino = AUDIT_INO_UNSET; |
1685 | aname->type = type; | 1685 | aname->type = type; |
1686 | list_add_tail(&aname->list, &context->names_list); | 1686 | list_add_tail(&aname->list, &context->names_list); |
1687 | 1687 | ||
@@ -1923,7 +1923,7 @@ void __audit_inode_child(const struct inode *parent, | |||
1923 | if (inode) | 1923 | if (inode) |
1924 | audit_copy_inode(found_child, dentry, inode); | 1924 | audit_copy_inode(found_child, dentry, inode); |
1925 | else | 1925 | else |
1926 | found_child->ino = (unsigned long)-1; | 1926 | found_child->ino = AUDIT_INO_UNSET; |
1927 | } | 1927 | } |
1928 | EXPORT_SYMBOL_GPL(__audit_inode_child); | 1928 | EXPORT_SYMBOL_GPL(__audit_inode_child); |
1929 | 1929 | ||