Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 10 Jan 2018 18:02:42 -0800
From: Kees Cook <>
Cc: Kees Cook <>,
	David Windsor <>,
	Alexander Viro <>,,
	Linus Torvalds <>,
	Andrew Morton <>,
	Andy Lutomirski <>,
	Christoph Hellwig <>,
	Christoph Lameter <>,
	"David S. Miller" <>,
	Laura Abbott <>,
	Mark Rutland <>,
	"Martin K. Petersen" <>,
	Paolo Bonzini <>,
	Christian Borntraeger <>,
	Christoffer Dall <>,
	Dave Kleikamp <>,
	Jan Kara <>,
	Luis de Bethencourt <>,
	Marc Zyngier <>,
	Rik van Riel <>,
	Matthew Garrett <>,,,,
Subject: [PATCH 10/38] dcache: Define usercopy region in dentry_cache slab cache

From: David Windsor <>

When a dentry name is short enough, it can be stored directly in the
dentry itself (instead in a separate kmalloc allocation). These dentry
short names, stored in struct dentry.d_iname and therefore contained in
the dentry_cache slab cache, need to be coped to userspace.

cache object allocation:
            dentry = kmem_cache_alloc(dentry_cache, ...);
            dentry-> = dentry->d_iname;

example usage trace:

        (called via by dir_emit)
        filldir(..., const char *name, ...):
            copy_to_user(..., name, namlen)

            next = next_positive(dentry, p, 1)
            dir_emit(..., next->, ...)

In support of usercopy hardening, this patch defines a region in the
dentry_cache slab cache in which userspace copy operations are allowed.

This region is known as the slab cache's usercopy region. Slab caches can
now check that each dynamic copy operation involving cache-managed memory
falls entirely within the slab's usercopy region.

This patch is modified from Brad Spengler/PaX Team's PAX_USERCOPY
whitelisting code in the last public patch of grsecurity/PaX based on my
understanding of the code. Changes or omissions from the original code are
mine and don't reflect the original grsecurity/PaX code.

Signed-off-by: David Windsor <>
[kees: adjust hunks for kmalloc-specific things moved later]
[kees: adjust commit log, provide usage trace]
Cc: Alexander Viro <>
Signed-off-by: Kees Cook <>
 fs/dcache.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 5c7df1df81ff..92ad7a2168e1 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3601,8 +3601,9 @@ static void __init dcache_init(void)
 	 * but it is probably not worth it because of the cache nature
 	 * of the dcache.
-	dentry_cache = KMEM_CACHE(dentry,
+	dentry_cache = KMEM_CACHE_USERCOPY(dentry,
+		d_iname);
 	/* Hash may have been set up in dcache_init_early */
 	if (!hashdist)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.