{"id":806789,"url":"http://patchwork.ozlabs.org/api/1.0/patches/806789/?format=json","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.0/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<1503956111-36652-9-git-send-email-keescook@chromium.org>","date":"2017-08-28T21:34:49","name":"[v2,08/30] ext2: Define usercopy region in ext2_inode_cache slab cache","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"39ab849d028b656d49525ce8a7f946b29dd96394","submitter":{"id":10641,"url":"http://patchwork.ozlabs.org/api/1.0/people/10641/?format=json","name":"Kees Cook","email":"keescook@chromium.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/1503956111-36652-9-git-send-email-keescook@chromium.org/mbox/","series":[{"id":267,"url":"http://patchwork.ozlabs.org/api/1.0/series/267/?format=json","date":"2017-08-28T21:34:48","name":null,"version":2,"mbox":"http://patchwork.ozlabs.org/series/267/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/806789/checks/","tags":{},"headers":{"Return-Path":"<linux-ext4-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=linux-ext4-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=\"jKFan3qB\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xh55Y39vqz9t2c\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 29 Aug 2017 07:49:37 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751546AbdH1VfZ (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 28 Aug 2017 17:35:25 -0400","from mail-pg0-f52.google.com ([74.125.83.52]:33779 \"EHLO\n\tmail-pg0-f52.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751194AbdH1VfX (ORCPT\n\t<rfc822; linux-ext4@vger.kernel.org>); Mon, 28 Aug 2017 17:35:23 -0400","by mail-pg0-f52.google.com with SMTP id t3so5023914pgt.0\n\tfor <linux-ext4@vger.kernel.org>;\n\tMon, 28 Aug 2017 14:35:23 -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\tb8sm2248006pfl.16.2017.08.28.14.35.17\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 28 Aug 2017 14:35:19 -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=ZZCTRJwpDkZVPOclHxzOkNUiLhC/JhJGmyLmxiRZFcA=;\n\tb=jKFan3qBQiq9B9JRZreTDPt1YcHRpTe2T9o9dtineqH/NWxdX5EuB4kNz+SdRqV1o/\n\t3sgjgLyLbPd45VBm8Yo62+MnAAYTTMGDAxAroZVC35AmDC8zFqlXZlvIFvcX/t+Z+twz\n\tDApL3mg7taQ/UI5SXfRFKwH/vajO5fq4spQKs=","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=ZZCTRJwpDkZVPOclHxzOkNUiLhC/JhJGmyLmxiRZFcA=;\n\tb=qG8TMxLwYBU6aasJIL7k+vsHFdkptDsCl5Zi2CY+A6TVYxCw3DGfdJiIXkQPbowccj\n\tSuCLAxKKH1lexpjrGNcicdCRCEKmmSyJgU/jyX8L6PIwTxwyGPp1JqcuW7D5u7gwJHS+\n\tgwv8XhsHb9RW9YgBo16SzQiw2WKY5x9xYKi82uV5yUgM1wE7jjdBevOCZX7/8HgOgssr\n\tau0cJV2GJFL7u0Vpt/N0x3gvhcRVEMW0NXbO+e9GkNcekqIeaD/5G831r0+o35AVlCUE\n\t4Rnwf0EqTB8d3xqAC5RcsGEI5awOCz6ht70yPzdYkgnpXQw6RiyPWvWUU2+KTF2Zyka8\n\t/+Tw==","X-Gm-Message-State":"AHYfb5gn6folo5bEQ6KhlV0RqsbAvOZvhGPm3PRMtui2gIBfiB/se9+y\n\tYU1tdrh723Xk5w6R","X-Received":"by 10.99.180.2 with SMTP id s2mr1790135pgf.183.1503956122755;\n\tMon, 28 Aug 2017 14:35:22 -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-mm@kvack.org,\n\tkernel-hardening@lists.openwall.com","Subject":"[PATCH v2 08/30] ext2: Define usercopy region in ext2_inode_cache\n\tslab cache","Date":"Mon, 28 Aug 2017 14:34:49 -0700","Message-Id":"<1503956111-36652-9-git-send-email-keescook@chromium.org>","X-Mailer":"git-send-email 2.7.4","In-Reply-To":"<1503956111-36652-1-git-send-email-keescook@chromium.org>","References":"<1503956111-36652-1-git-send-email-keescook@chromium.org>","Sender":"linux-ext4-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-ext4.vger.kernel.org>","X-Mailing-List":"linux-ext4@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>\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 7b1bc9059863..670142cde59d 100644\n--- a/fs/ext2/super.c\n+++ b/fs/ext2/super.c\n@@ -219,11 +219,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":["v2","08/30"]}