{"id":816493,"url":"http://patchwork.ozlabs.org/api/patches/816493/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/1505940337-79069-9-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-9-git-send-email-keescook@chromium.org>","list_archive_url":null,"date":"2017-09-20T20:45:14","name":"[v3,08/31] ext2: Define usercopy region in ext2_inode_cache slab cache","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":true,"hash":"39ab849d028b656d49525ce8a7f946b29dd96394","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-9-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/816493/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816493/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=\"EoCb4hwO\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xyBhj2xGqz9s83\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 21 Sep 2017 06:50:29 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751846AbdITUu1 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 20 Sep 2017 16:50:27 -0400","from mail-pg0-f45.google.com ([74.125.83.45]:55213 \"EHLO\n\tmail-pg0-f45.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751848AbdITUqG (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 20 Sep 2017 16:46:06 -0400","by mail-pg0-f45.google.com with SMTP id c137so2324048pga.11\n\tfor <netdev@vger.kernel.org>; Wed, 20 Sep 2017 13:46:06 -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\tg5sm9409966pfe.94.2017.09.20.13.45.58\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=LvcQspsIR0cZ09igwnjHXzULMGq3Dr6LW9yWsRsqMUs=;\n\tb=EoCb4hwO5OkWUgCqdkj6LdxwhefJQHd/0AAX+/seNjy8OztA6nKzzVA1V8FxnD0t/K\n\tcdCnArv5YRN9C2z0URakmChOLSHkz+FgpNbQhL/2N6TQGHA/YSgXA0PXUrlpybXxuBNm\n\tYofEP/WpFtXAJSGYo6CXfY0cpMhRJf8HtGzkc=","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=LvcQspsIR0cZ09igwnjHXzULMGq3Dr6LW9yWsRsqMUs=;\n\tb=eikg3z/GfIj/4wqtS7P8jujuXLt4NyYj634I9Q+m/PKfB4glcwOIE5U2BU8HySHiO2\n\ttd1tOkj9YEaz3sqCQdUGzYGFU/2esbhGI4PrLth4YMiUSjysALjftuigTqiELcgYdHVa\n\toIUghgeXFBXhmsRD60WdrbseHk/u+SEa/Paz1gxVyUCE50nYC5MOTlYjwTFrAndkGh6Q\n\tLPNjebgV0sYZac8ClzUpUzMwdBU9dNABCFLMN2We2uOMJwSeckWN77FoRoObKrm72ijT\n\tSQ4vMPR0VRWWx1ZxbdD/uRlNkCE7mAvo3aM9i5Cu+6n0GYxDc1XNU7CQECEKCJQ3ykQk\n\tIovg==","X-Gm-Message-State":"AHPjjUhrcTyXQuSJXsI3VPgYOIBvD3fTXy2YCdNflyMLxqqrlaca4r5Y\n\tKWDaxVdtL8+F7E5t695h5wy7pg==","X-Google-Smtp-Source":"AOwi7QBliiflupQIqDjOeU6Guyk7gsp7PfnS+t6H7cX5J1nN7fdMVhelaWdTXOECuREG6yPlGBX29A==","X-Received":"by 10.101.88.203 with SMTP id e11mr3306923pgu.95.1505940365703; \n\tWed, 20 Sep 2017 13:46:05 -0700 (PDT)","From":"Kees Cook <keescook@chromium.org>","To":"linux-kernel@vger.kernel.org","Cc":"Kees Cook <keescook@chromium.org>,\n\tDavid Windsor <dave@nullcore.net>, Jan Kara <jack@suse.com>,\n\tlinux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,\n\tnetdev@vger.kernel.org, linux-mm@kvack.org,\n\tkernel-hardening@lists.openwall.com","Subject":"[PATCH v3 08/31] ext2: Define usercopy region in ext2_inode_cache\n\tslab cache","Date":"Wed, 20 Sep 2017 13:45:14 -0700","Message-Id":"<1505940337-79069-9-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\nThe ext2 symlink pathnames, stored in struct ext2_inode_info.i_data and\ntherefore contained in the ext2_inode_cache slab cache, need to be copied\nto/from userspace.\n\ncache object allocation:\n    fs/ext2/super.c:\n        ext2_alloc_inode(...):\n            struct ext2_inode_info *ei;\n            ...\n            ei = kmem_cache_alloc(ext2_inode_cachep, GFP_NOFS);\n            ...\n            return &ei->vfs_inode;\n\n    fs/ext2/ext2.h:\n        EXT2_I(struct inode *inode):\n            return container_of(inode, struct ext2_inode_info, vfs_inode);\n\n    fs/ext2/namei.c:\n        ext2_symlink(...):\n            ...\n            inode->i_link = (char *)&EXT2_I(inode)->i_data;\n\nexample usage trace:\n    readlink_copy+0x43/0x70\n    vfs_readlink+0x62/0x110\n    SyS_readlinkat+0x100/0x130\n\n    fs/namei.c:\n        readlink_copy(..., link):\n            ...\n            copy_to_user(..., link, len);\n\n        (inlined into vfs_readlink)\n        generic_readlink(dentry, ...):\n            struct inode *inode = d_inode(dentry);\n            const char *link = inode->i_link;\n            ...\n            readlink_copy(..., link);\n\nIn support of usercopy hardening, this patch defines a region in the\next2_inode_cache slab cache in which userspace copy operations are\nallowed.\n\nThis region is known as the slab cache's usercopy region. Slab caches can\nnow check that each copy operation involving cache-managed memory falls\nentirely within the slab's usercopy region.\n\nThis patch is modified 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, provide usage trace]\nCc: Jan Kara <jack@suse.com>\nCc: linux-ext4@vger.kernel.org\nSigned-off-by: Kees Cook <keescook@chromium.org>\nAcked-by: Jan Kara <jack@suse.cz>\n---\n fs/ext2/super.c | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)","diff":"diff --git a/fs/ext2/super.c b/fs/ext2/super.c\nindex 1458706bd2ec..789c29987b36 100644\n--- a/fs/ext2/super.c\n+++ b/fs/ext2/super.c\n@@ -220,11 +220,13 @@ static void init_once(void *foo)\n \n static int __init init_inodecache(void)\n {\n-\text2_inode_cachep = kmem_cache_create(\"ext2_inode_cache\",\n-\t\t\t\t\t     sizeof(struct ext2_inode_info),\n-\t\t\t\t\t     0, (SLAB_RECLAIM_ACCOUNT|\n-\t\t\t\t\t\tSLAB_MEM_SPREAD|SLAB_ACCOUNT),\n-\t\t\t\t\t     init_once);\n+\text2_inode_cachep = kmem_cache_create_usercopy(\"ext2_inode_cache\",\n+\t\t\t\tsizeof(struct ext2_inode_info), 0,\n+\t\t\t\t(SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|\n+\t\t\t\t\tSLAB_ACCOUNT),\n+\t\t\t\toffsetof(struct ext2_inode_info, i_data),\n+\t\t\t\tsizeof_field(struct ext2_inode_info, i_data),\n+\t\t\t\tinit_once);\n \tif (ext2_inode_cachep == NULL)\n \t\treturn -ENOMEM;\n \treturn 0;\n","prefixes":["v3","08/31"]}