{"id":816489,"url":"http://patchwork.ozlabs.org/api/patches/816489/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/1505940337-79069-6-git-send-email-keescook@chromium.org/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1505940337-79069-6-git-send-email-keescook@chromium.org>","list_archive_url":null,"date":"2017-09-20T20:45:11","name":"[v3,05/31] vfs: Define usercopy region in names_cache slab caches","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":true,"hash":"fe6c4aebbb8ab83f38d8c89f5d857279dc5d8d27","submitter":{"id":10641,"url":"http://patchwork.ozlabs.org/api/people/10641/?format=json","name":"Kees Cook","email":"keescook@chromium.org"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/1505940337-79069-6-git-send-email-keescook@chromium.org/mbox/","series":[{"id":4231,"url":"http://patchwork.ozlabs.org/api/series/4231/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=4231","date":"2017-09-20T20:45:22","name":"Hardened usercopy whitelisting","version":3,"mbox":"http://patchwork.ozlabs.org/series/4231/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/816489/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816489/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"k+Ud0bIc\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xyBgP2pNRz9sNr\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 21 Sep 2017 06:49:21 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751889AbdITUqJ (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 20 Sep 2017 16:46:09 -0400","from mail-pf0-f169.google.com ([209.85.192.169]:49054 \"EHLO\n\tmail-pf0-f169.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751834AbdITUqD (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 20 Sep 2017 16:46:03 -0400","by mail-pf0-f169.google.com with SMTP id n24so2111674pfk.5\n\tfor <netdev@vger.kernel.org>; Wed, 20 Sep 2017 13:46:03 -0700 (PDT)","from www.outflux.net\n\t(173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133])\n\tby smtp.gmail.com with ESMTPSA id\n\ty13sm9603425pfi.27.2017.09.20.13.45.57\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 20 Sep 2017 13:46:00 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=guDJ44pN3QXUcnxkBLtl1izw4RCuvLosziifFWcgdJs=;\n\tb=k+Ud0bIcmj7XSK1c7y4e5sMMybz040WNe+O3rVUIqScybyNFKRxGa7rM60ygqMe1L5\n\tXP6cG37uSw0I9Y2G2RUzge+zZFMLQjI7nPhh6izuj63ilpVit8lM+Q3nPeASKmXAWSHM\n\tfhjN80+WeB9pFwYtn4tvQ9gqRRS7lKGP7NyPc=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=guDJ44pN3QXUcnxkBLtl1izw4RCuvLosziifFWcgdJs=;\n\tb=dloNbjFclT2f1qSLJtIYvrX/cdzSSS11nXeCoxQYPBtFfy8ZCuodr0guwhJiuPTSzc\n\tzon/oVJ/QonRA+2gq1ygmjRPJMz93XbLlnkVNW0YIkCOcXm0curc8yraZPj0MOOf2DBN\n\t9BZfZDYr0JWQJpMPKqxfXBi4bCyTvofS/R9xyc2sl3d0xtDZxjn3vJCH4LN36qP/uRrJ\n\tx0/tf5QhkeEG+Ktmmu2wmTPUhPEQuuY+mUh/kfhcUq3Ig1pe984Ag8JFbMNfvaMzPcbR\n\tWZA9ktDHsepO0DukCXymWDVq2kRL7Sjh1UYAiqjj9Gxar73r70CHs31RLcvIorEsqofx\n\tW6og==","X-Gm-Message-State":"AHPjjUg7kFbjElgTA+10wP5YcZ7ErUIcc2cWkM1LJzW2h8JYVoEZEWIL\n\tRlRksTnnw6tqG9AFol6MA2kGDQ==","X-Google-Smtp-Source":"AOwi7QB6/Ywb5q65pasgaUtLau2haawVsjOevWTyJJz/pUOpOYLbcWbqN4hnOiyxU3+UB5zRH8P6VA==","X-Received":"by 10.159.194.137 with SMTP id y9mr3307706pln.77.1505940362933; \n\tWed, 20 Sep 2017 13:46:02 -0700 (PDT)","From":"Kees Cook <keescook@chromium.org>","To":"linux-kernel@vger.kernel.org","Cc":"Kees Cook <keescook@chromium.org>, David Windsor <dave@nullcore.net>,\n\tAlexander Viro <viro@zeniv.linux.org.uk>,\n\tlinux-fsdevel@vger.kernel.org, netdev@vger.kernel.org,\n\tlinux-mm@kvack.org, kernel-hardening@lists.openwall.com","Subject":"[PATCH v3 05/31] vfs: Define usercopy region in names_cache slab\n\tcaches","Date":"Wed, 20 Sep 2017 13:45:11 -0700","Message-Id":"<1505940337-79069-6-git-send-email-keescook@chromium.org>","X-Mailer":"git-send-email 2.7.4","In-Reply-To":"<1505940337-79069-1-git-send-email-keescook@chromium.org>","References":"<1505940337-79069-1-git-send-email-keescook@chromium.org>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"From: David Windsor <dave@nullcore.net>\n\nVFS pathnames are stored in the names_cache slab cache, either inline\nor across an entire allocation entry (when approaching PATH_MAX). These\nare copied to/from userspace, so they must be entirely whitelisted.\n\ncache object allocation:\n    include/linux/fs.h:\n        #define __getname()    kmem_cache_alloc(names_cachep, GFP_KERNEL)\n\nexample usage trace:\n    strncpy_from_user+0x4d/0x170\n    getname_flags+0x6f/0x1f0\n    user_path_at_empty+0x23/0x40\n    do_mount+0x69/0xda0\n    SyS_mount+0x83/0xd0\n\n    fs/namei.c:\n        getname_flags(...):\n            ...\n            result = __getname();\n            ...\n            kname = (char *)result->iname;\n            result->name = kname;\n            len = strncpy_from_user(kname, filename, EMBEDDED_NAME_MAX);\n            ...\n            if (unlikely(len == EMBEDDED_NAME_MAX)) {\n                const size_t size = offsetof(struct filename, iname[1]);\n                kname = (char *)result;\n\n                result = kzalloc(size, GFP_KERNEL);\n                ...\n                result->name = kname;\n                len = strncpy_from_user(kname, filename, PATH_MAX);\n\nIn support of usercopy hardening, this patch defines the entire cache\nobject in the names_cache slab cache as whitelisted, since it may entirely\nhold name strings to be copied to/from userspace.\n\nThis patch is verbatim from Brad Spengler/PaX Team's PAX_USERCOPY\nwhitelisting code in the last public patch of grsecurity/PaX based on my\nunderstanding of the code. Changes or omissions from the original code are\nmine and don't reflect the original grsecurity/PaX code.\n\nSigned-off-by: David Windsor <dave@nullcore.net>\n[kees: adjust commit log, add usage trace]\nCc: Alexander Viro <viro@zeniv.linux.org.uk>\nCc: linux-fsdevel@vger.kernel.org\nSigned-off-by: Kees Cook <keescook@chromium.org>\n---\n fs/dcache.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)","diff":"diff --git a/fs/dcache.c b/fs/dcache.c\nindex 5f5e7c1fcf4b..34ef9a9169be 100644\n--- a/fs/dcache.c\n+++ b/fs/dcache.c\n@@ -3642,8 +3642,8 @@ void __init vfs_caches_init_early(void)\n \n void __init vfs_caches_init(void)\n {\n-\tnames_cachep = kmem_cache_create(\"names_cache\", PATH_MAX, 0,\n-\t\t\tSLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);\n+\tnames_cachep = kmem_cache_create_usercopy(\"names_cache\", PATH_MAX, 0,\n+\t\t\tSLAB_HWCACHE_ALIGN|SLAB_PANIC, 0, PATH_MAX, NULL);\n \n \tdcache_init();\n \tinode_init();\n","prefixes":["v3","05/31"]}