aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/auditsc.c
diff options
context:
space:
mode:
authorPaul Moore <pmoore@redhat.com>2015-01-22 00:00:10 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-01-23 00:23:52 -0500
commitfd3522fdc84023b050bb40318d9fc71a9adc22bc (patch)
treedc0df711a6d6590a1944469b7d8b6f5fe9641f12 /kernel/auditsc.c
parentcbaab2db9103cc6727c7166d2fda9f64038c828c (diff)
audit: enable filename recording via getname_kernel()
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> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel/auditsc.c')
-rw-r--r--kernel/auditsc.c40
1 files changed, 3 insertions, 37 deletions
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 072566dd0caf..132dbcdef6ec 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1882,44 +1882,10 @@ out_alloc:
1882 n = audit_alloc_name(context, AUDIT_TYPE_UNKNOWN); 1882 n = audit_alloc_name(context, AUDIT_TYPE_UNKNOWN);
1883 if (!n) 1883 if (!n)
1884 return; 1884 return;
1885 /* unfortunately, while we may have a path name to record with the 1885 if (name)
1886 * inode, we can't always rely on the string lasting until the end of 1886 /* no need to set ->name_put as the original will cleanup */
1887 * the syscall so we need to create our own copy, it may fail due to 1887 n->name = name;
1888 * memory allocation issues, but we do our best */
1889 if (name) {
1890 /* we can't use getname_kernel() due to size limits */
1891 size_t len = strlen(name->name) + 1;
1892 struct filename *new = __getname();
1893
1894 if (unlikely(!new))
1895 goto out;
1896 1888
1897 if (len <= (PATH_MAX - sizeof(*new))) {
1898 new->name = (char *)(new) + sizeof(*new);
1899 new->separate = false;
1900 } else if (len <= PATH_MAX) {
1901 /* this looks odd, but is due to final_putname() */
1902 struct filename *new2;
1903
1904 new2 = kmalloc(sizeof(*new2), GFP_KERNEL);
1905 if (unlikely(!new2)) {
1906 __putname(new);
1907 goto out;
1908 }
1909 new2->name = (char *)new;
1910 new2->separate = true;
1911 new = new2;
1912 } else {
1913 /* we should never get here, but let's be safe */
1914 __putname(new);
1915 goto out;
1916 }
1917 strlcpy((char *)new->name, name->name, len);
1918 new->uptr = NULL;
1919 new->aname = n;
1920 n->name = new;
1921 n->name_put = true;
1922 }
1923out: 1889out:
1924 if (parent) { 1890 if (parent) {
1925 n->name_len = n->name ? parent_len(n->name->name) : AUDIT_NAME_FULL; 1891 n->name_len = n->name ? parent_len(n->name->name) : AUDIT_NAME_FULL;