From: Paul Moore <pmoore@redhat.com>
To: linux-fsdevel@vger.kernel.org, linux-audit@redhat.com
Cc: rgb@redhat.com, viro@zeniv.linux.org.uk,
linux-kernel@vger.kernel.org, linux@roeck-us.net,
sd@queasysnail.net
Subject: [PATCH v2 3/5] audit: enable filename recording via getname_kernel()
Date: Thu, 22 Jan 2015 00:00:10 -0500 [thread overview]
Message-ID: <20150122050010.1347.81629.stgit@localhost> (raw)
In-Reply-To: <20150122045303.1347.98054.stgit@localhost>
Enable recording of filenames in getname_kernel() and remove the
kludgy workaround in __audit_inode() now that we have proper filename
logging for kernel users.
CC: viro@zeniv.linux.org.uk
CC: linux-fsdevel@vger.kernel.org
Signed-off-by: Paul Moore <pmoore@redhat.com>
Reviewed-by: Richard Guy Briggs <rgb@redhat.com>
---
fs/namei.c | 1 +
kernel/auditsc.c | 40 +++-------------------------------------
2 files changed, 4 insertions(+), 37 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index f793fe4..e18a2b5 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -242,6 +242,7 @@ getname_kernel(const char * filename)
memcpy((char *)result->name, filename, len);
result->uptr = NULL;
result->aname = NULL;
+ audit_getname(result);
return result;
}
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 793e9e9..c967ffc 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1882,44 +1882,10 @@ out_alloc:
n = audit_alloc_name(context, AUDIT_TYPE_UNKNOWN);
if (!n)
return;
- /* unfortunately, while we may have a path name to record with the
- * inode, we can't always rely on the string lasting until the end of
- * the syscall so we need to create our own copy, it may fail due to
- * memory allocation issues, but we do our best */
- if (name) {
- /* we can't use getname_kernel() due to size limits */
- size_t len = strlen(name->name) + 1;
- struct filename *new = __getname();
-
- if (unlikely(!new))
- goto out;
+ if (name)
+ /* no need to set ->name_put as the original will cleanup */
+ n->name = name;
- if (len <= (PATH_MAX - sizeof(*new))) {
- new->name = (char *)(new) + sizeof(*new);
- new->separate = false;
- } else if (len <= PATH_MAX) {
- /* this looks odd, but is due to final_putname() */
- struct filename *new2;
-
- new2 = kmalloc(sizeof(*new2), GFP_KERNEL);
- if (unlikely(!new2)) {
- __putname(new);
- goto out;
- }
- new2->name = (char *)new;
- new2->separate = true;
- new = new2;
- } else {
- /* we should never get here, but let's be safe */
- __putname(new);
- goto out;
- }
- strlcpy((char *)new->name, name->name, len);
- new->uptr = NULL;
- new->aname = n;
- n->name = new;
- n->name_put = true;
- }
out:
if (parent) {
n->name_len = n->name ? parent_len(n->name->name) : AUDIT_NAME_FULL;
WARNING: multiple messages have this Message-ID (diff)
From: Paul Moore <pmoore@redhat.com>
To: linux-fsdevel@vger.kernel.org, linux-audit@redhat.com
Cc: rgb@redhat.com, sd@queasysnail.net, linux-kernel@vger.kernel.org,
linux@roeck-us.net, viro@zeniv.linux.org.uk
Subject: [PATCH v2 3/5] audit: enable filename recording via getname_kernel()
Date: Thu, 22 Jan 2015 00:00:10 -0500 [thread overview]
Message-ID: <20150122050010.1347.81629.stgit@localhost> (raw)
In-Reply-To: <20150122045303.1347.98054.stgit@localhost>
Enable recording of filenames in getname_kernel() and remove the
kludgy workaround in __audit_inode() now that we have proper filename
logging for kernel users.
CC: viro@zeniv.linux.org.uk
CC: linux-fsdevel@vger.kernel.org
Signed-off-by: Paul Moore <pmoore@redhat.com>
Reviewed-by: Richard Guy Briggs <rgb@redhat.com>
---
fs/namei.c | 1 +
kernel/auditsc.c | 40 +++-------------------------------------
2 files changed, 4 insertions(+), 37 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index f793fe4..e18a2b5 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -242,6 +242,7 @@ getname_kernel(const char * filename)
memcpy((char *)result->name, filename, len);
result->uptr = NULL;
result->aname = NULL;
+ audit_getname(result);
return result;
}
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 793e9e9..c967ffc 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1882,44 +1882,10 @@ out_alloc:
n = audit_alloc_name(context, AUDIT_TYPE_UNKNOWN);
if (!n)
return;
- /* unfortunately, while we may have a path name to record with the
- * inode, we can't always rely on the string lasting until the end of
- * the syscall so we need to create our own copy, it may fail due to
- * memory allocation issues, but we do our best */
- if (name) {
- /* we can't use getname_kernel() due to size limits */
- size_t len = strlen(name->name) + 1;
- struct filename *new = __getname();
-
- if (unlikely(!new))
- goto out;
+ if (name)
+ /* no need to set ->name_put as the original will cleanup */
+ n->name = name;
- if (len <= (PATH_MAX - sizeof(*new))) {
- new->name = (char *)(new) + sizeof(*new);
- new->separate = false;
- } else if (len <= PATH_MAX) {
- /* this looks odd, but is due to final_putname() */
- struct filename *new2;
-
- new2 = kmalloc(sizeof(*new2), GFP_KERNEL);
- if (unlikely(!new2)) {
- __putname(new);
- goto out;
- }
- new2->name = (char *)new;
- new2->separate = true;
- new = new2;
- } else {
- /* we should never get here, but let's be safe */
- __putname(new);
- goto out;
- }
- strlcpy((char *)new->name, name->name, len);
- new->uptr = NULL;
- new->aname = n;
- n->name = new;
- n->name_put = true;
- }
out:
if (parent) {
n->name_len = n->name ? parent_len(n->name->name) : AUDIT_NAME_FULL;
next prev parent reply other threads:[~2015-01-22 5:00 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-22 4:59 [PATCH v2 0/5] Overhaul the audit filename handling Paul Moore
2015-01-22 4:59 ` [PATCH v2 1/5] fs: rework getname_kernel to handle up to PATH_MAX sized filenames Paul Moore
2015-01-22 15:53 ` Richard Guy Briggs
2015-01-22 16:56 ` Guenter Roeck
2015-01-22 5:00 ` [PATCH v2 2/5] fs: create proper filename objects using getname_kernel() Paul Moore
2015-01-22 15:54 ` Richard Guy Briggs
2015-01-22 5:00 ` Paul Moore [this message]
2015-01-22 5:00 ` [PATCH v2 3/5] audit: enable filename recording via getname_kernel() Paul Moore
2015-01-22 5:00 ` [PATCH v2 4/5] audit: fix filename matching in __audit_inode() and __audit_inode_child() Paul Moore
2015-01-22 16:04 ` Richard Guy Briggs
2015-01-22 5:00 ` [PATCH v2 5/5] audit: replace getname()/putname() hacks with reference counters Paul Moore
2015-01-22 16:09 ` Richard Guy Briggs
2015-01-22 16:24 ` Paul Moore
2015-01-22 5:36 ` [PATCH v2 0/5] Overhaul the audit filename handling Guenter Roeck
2015-01-22 7:54 ` Al Viro
2015-01-22 16:23 ` Paul Moore
2015-01-22 21:25 ` Paul Moore
2015-01-22 21:29 ` Al Viro
2015-01-22 21:40 ` Al Viro
2015-01-22 22:05 ` Paul Moore
2015-01-23 5:30 ` Al Viro
2015-01-23 16:15 ` Paul Moore
2015-01-24 9:03 ` Sedat Dilek
2015-01-24 22:54 ` Stephen Rothwell
2015-01-26 15:52 ` Paul Moore
2015-01-22 17:13 ` Guenter Roeck
2015-01-22 16:22 ` Paul Moore
2015-01-22 16:58 ` Guenter Roeck
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=20150122050010.1347.81629.stgit@localhost \
--to=pmoore@redhat.com \
--cc=linux-audit@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=rgb@redhat.com \
--cc=sd@queasysnail.net \
--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.