All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: viro@zeniv.linux.org.uk
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	miklos@szeredi.hu, gregkh@linuxfoundation.org, tj@kernel.org,
	jack@suse.cz, amir73il@gmail.com, paul@paul-moore.com,
	eparis@redhat.com, linux-audit@redhat.com, rafael@kernel.org
Subject: [PATCH 5/5] audit: fix audit_compare_dname_path to take a qstr
Date: Fri, 26 Apr 2019 14:28:47 -0400	[thread overview]
Message-ID: <20190426182847.25088-6-jlayton@kernel.org> (raw)
In-Reply-To: <20190426182847.25088-1-jlayton@kernel.org>

...and eliminate its strlen call.

Signed-off-by: Jeff Layton <jlayton@kernel.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(-)

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

  parent reply	other threads:[~2019-04-26 18:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-26 18:28 [PATCH 0/5] vfs: track the dentry name length in name_snapshot Jeff Layton
2019-04-26 18:28 ` [PATCH 1/5] dcache: track the length of the string in struct name_snapshot Jeff Layton
2019-04-26 18:28 ` [PATCH 2/5] fsnotify: have fsnotify_move take a struct qstr instead of a string Jeff Layton
2019-04-26 18:28 ` [PATCH 3/5] fsnotify: have fsnotify() take a " Jeff Layton
2019-04-26 18:28 ` [PATCH 4/5] fsnotify: change ->handle_event and send_to_group to take a qstr Jeff Layton
2019-04-26 18:28 ` Jeff Layton [this message]
2019-04-26 19:02   ` [PATCH 5/5] audit: fix audit_compare_dname_path " Paul Moore
2019-04-26 18:51 ` [PATCH 0/5] vfs: track the dentry name length in name_snapshot Al Viro
2019-04-26 18:59   ` Paul Moore
2019-04-26 19:03   ` Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190426182847.25088-6-jlayton@kernel.org \
    --to=jlayton@kernel.org \
    --cc=amir73il@gmail.com \
    --cc=eparis@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=linux-audit@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=paul@paul-moore.com \
    --cc=rafael@kernel.org \
    --cc=tj@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.