[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHC9VhTcXV9vcqEJo0G5AG9Qikb+h3VCAcyKVe=2P7V0yo8gjQ@mail.gmail.com>
Date: Fri, 26 Apr 2019 15:02:28 -0400
From: Paul Moore <paul@...l-moore.com>
To: Jeff Layton <jlayton@...nel.org>
Cc: viro@...iv.linux.org.uk, linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org, miklos@...redi.hu,
gregkh@...uxfoundation.org, tj@...nel.org, jack@...e.cz,
amir73il@...il.com, Eric Paris <eparis@...hat.com>,
linux-audit@...hat.com, rafael@...nel.org
Subject: Re: [PATCH 5/5] audit: fix audit_compare_dname_path to take a qstr
On Fri, Apr 26, 2019 at 2:28 PM Jeff Layton <jlayton@...nel.org> wrote:
>
> ...and eliminate its strlen call.
>
> Signed-off-by: Jeff Layton <jlayton@...nel.org>
> ---
> kernel/audit.h | 3 ++-
> kernel/audit_fsnotify.c | 2 +-
> kernel/audit_watch.c | 6 +++---
> kernel/auditfilter.c | 7 ++++---
> kernel/auditsc.c | 7 +++----
> 5 files changed, 13 insertions(+), 12 deletions(-)
This looks fine to me. I'm guessing you are planning on this going in
with the other patches, but if you want me to pull this single patch
into audit/next let me know.
Acked-by: Paul Moore <paul@...l-moore.com>
> diff --git a/kernel/audit.h b/kernel/audit.h
> index 958d5b8fc1b3..8c581fd38050 100644
> --- a/kernel/audit.h
> +++ b/kernel/audit.h
> @@ -231,7 +231,8 @@ extern int audit_comparator(const u32 left, const u32 op, const u32 right);
> extern int audit_uid_comparator(kuid_t left, u32 op, kuid_t right);
> extern int audit_gid_comparator(kgid_t left, u32 op, kgid_t right);
> extern int parent_len(const char *path);
> -extern int audit_compare_dname_path(const char *dname, const char *path, int plen);
> +extern int audit_compare_dname_path(const struct qstr *dname, const char *path,
> + int plen);
> extern struct sk_buff *audit_make_reply(int seq, int type, int done, int multi,
> const void *payload, int size);
> extern void audit_panic(const char *message);
> diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c
> index 6def7f426ba6..af281e965d24 100644
> --- a/kernel/audit_fsnotify.c
> +++ b/kernel/audit_fsnotify.c
> @@ -188,7 +188,7 @@ static int audit_mark_handle_event(struct fsnotify_group *group,
> }
>
> if (mask & (FS_CREATE|FS_MOVED_TO|FS_DELETE|FS_MOVED_FROM)) {
> - if (audit_compare_dname_path(dname->name, audit_mark->path,
> + if (audit_compare_dname_path(dname, audit_mark->path,
> AUDIT_NAME_FULL))
> return 0;
> audit_update_mark(audit_mark, inode);
> diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
> index 3c12fd5b680e..b50c574223fa 100644
> --- a/kernel/audit_watch.c
> +++ b/kernel/audit_watch.c
> @@ -255,7 +255,7 @@ static void audit_watch_log_rule_change(struct audit_krule *r, struct audit_watc
>
> /* Update inode info in audit rules based on filesystem event. */
> static void audit_update_watch(struct audit_parent *parent,
> - const char *dname, dev_t dev,
> + const struct qstr *dname, dev_t dev,
> unsigned long ino, unsigned invalidating)
> {
> struct audit_watch *owatch, *nwatch, *nextw;
> @@ -507,9 +507,9 @@ static int audit_watch_handle_event(struct fsnotify_group *group,
> }
>
> if (mask & (FS_CREATE|FS_MOVED_TO) && inode)
> - audit_update_watch(parent, dname->name, inode->i_sb->s_dev, inode->i_ino, 0);
> + audit_update_watch(parent, dname, inode->i_sb->s_dev, inode->i_ino, 0);
> else if (mask & (FS_DELETE|FS_MOVED_FROM))
> - audit_update_watch(parent, dname->name, AUDIT_DEV_UNSET, AUDIT_INO_UNSET, 1);
> + audit_update_watch(parent, dname, AUDIT_DEV_UNSET, AUDIT_INO_UNSET, 1);
> else if (mask & (FS_DELETE_SELF|FS_UNMOUNT|FS_MOVE_SELF))
> audit_remove_parent_watches(parent);
>
> diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
> index 63f8b3f26fab..6f585b48f4ef 100644
> --- a/kernel/auditfilter.c
> +++ b/kernel/auditfilter.c
> @@ -1290,12 +1290,13 @@ int parent_len(const char *path)
> * @parentlen: length of the parent if known. Passing in AUDIT_NAME_FULL
> * here indicates that we must compute this value.
> */
> -int audit_compare_dname_path(const char *dname, const char *path, int parentlen)
> +int audit_compare_dname_path(const struct qstr *dname, const char *path,
> + int parentlen)
> {
> int dlen, pathlen;
> const char *p;
>
> - dlen = strlen(dname);
> + dlen = dname->len;
> pathlen = strlen(path);
> if (pathlen < dlen)
> return 1;
> @@ -1306,7 +1307,7 @@ int audit_compare_dname_path(const char *dname, const char *path, int parentlen)
>
> p = path + parentlen;
>
> - return strncmp(p, dname, dlen);
> + return strncmp(p, dname->name, dlen);
> }
>
> int audit_filter(int msgtype, unsigned int listtype)
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index d1eab1d4a930..05e06b766af1 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -2045,7 +2045,6 @@ void __audit_inode_child(struct inode *parent,
> {
> struct audit_context *context = audit_context();
> struct inode *inode = d_backing_inode(dentry);
> - const char *dname = dentry->d_name.name;
> struct audit_names *n, *found_parent = NULL, *found_child = NULL;
> struct audit_entry *e;
> struct list_head *list = &audit_filter_list[AUDIT_FILTER_FS];
> @@ -2083,7 +2082,7 @@ void __audit_inode_child(struct inode *parent,
> continue;
>
> if (n->ino == parent->i_ino && n->dev == parent->i_sb->s_dev &&
> - !audit_compare_dname_path(dname,
> + !audit_compare_dname_path(&dentry->d_name,
> n->name->name, n->name_len)) {
> if (n->type == AUDIT_TYPE_UNKNOWN)
> n->type = AUDIT_TYPE_PARENT;
> @@ -2099,8 +2098,8 @@ void __audit_inode_child(struct inode *parent,
> (n->type != type && n->type != AUDIT_TYPE_UNKNOWN))
> continue;
>
> - if (!strcmp(dname, n->name->name) ||
> - !audit_compare_dname_path(dname, n->name->name,
> + if (!strcmp(dentry->d_name.name, n->name->name) ||
> + !audit_compare_dname_path(&dentry->d_name, n->name->name,
> found_parent ?
> found_parent->name_len :
> AUDIT_NAME_FULL)) {
> --
> 2.20.1
>
--
paul moore
www.paul-moore.com
Powered by blists - more mailing lists