From: Jeff Layton <jlayton@redhat.com>
To: eparis@redhat.com, viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-audit@redhat.com,
linux-kernel@vger.kernel.org
Subject: [PATCH v4 7/9] audit: make audit_compare_dname_path use parent_len helper
Date: Tue, 26 Jun 2012 12:35:35 -0400 [thread overview]
Message-ID: <1340728537-25599-8-git-send-email-jlayton@redhat.com> (raw)
In-Reply-To: <1340728537-25599-1-git-send-email-jlayton@redhat.com>
From: Eric Paris <eparis@redhat.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
---
kernel/auditfilter.c | 27 +++++++--------------------
1 files changed, 7 insertions(+), 20 deletions(-)
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index f9c48d0..f47ba18 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -1232,32 +1232,19 @@ int parent_len(const char *path)
* return of 0 indicates a match. */
int audit_compare_dname_path(const char *dname, const char *path)
{
- int dlen, plen;
+ int dlen, pathlen, parentlen;
const char *p;
- if (!dname || !path)
- return 1;
-
dlen = strlen(dname);
- plen = strlen(path);
- if (plen < dlen)
+ pathlen = strlen(path);
+ if (pathlen < dlen)
return 1;
- /* disregard trailing slashes */
- p = path + plen - 1;
- while ((*p == '/') && (p > path))
- p--;
-
- /* find last path component */
- p = p - dlen + 1;
- if (p < path)
+ parentlen = parent_len(path);
+ if (pathlen - parentlen != dlen)
return 1;
- else if (p > path) {
- if (*--p != '/')
- return 1;
- else
- p++;
- }
+
+ p = path + parentlen;
return strncmp(p, dname, dlen);
}
--
1.7.7.6
next prev parent reply other threads:[~2012-06-26 16:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-26 16:35 [PATCH v4 0/9] audit: overhaul audit_names handling to allow for retrying on path-based syscalls Jeff Layton
2012-06-26 16:35 ` [PATCH v4 1/9] audit: remove unnecessary NULL ptr checks from do_path_lookup Jeff Layton
2012-06-26 16:35 ` [PATCH v4 2/9] audit: pass in dentry to audit_copy_inode wherever possible Jeff Layton
2012-06-26 16:35 ` [PATCH v4 3/9] audit: reverse arguments to audit_inode_child Jeff Layton
2012-06-26 16:35 ` [PATCH v4 4/9] audit: add a new "type" field to audit_names struct Jeff Layton
2012-06-26 16:35 ` [PATCH v4 5/9] audit: set the name_len in audit_inode for parent lookups Jeff Layton
2012-06-26 16:35 ` [PATCH v4 6/9] audit: remove dirlen argument to audit_compare_dname_path Jeff Layton
2012-06-26 16:35 ` Jeff Layton [this message]
2012-06-26 16:35 ` [PATCH v4 8/9] audit: optimize audit_compare_dname_path Jeff Layton
2012-06-26 16:35 ` [PATCH v4 9/9] audit: overhaul __audit_inode_child to accomodate retrying 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=1340728537-25599-8-git-send-email-jlayton@redhat.com \
--to=jlayton@redhat.com \
--cc=eparis@redhat.com \
--cc=linux-audit@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).