{"id":816491,"url":"http://patchwork.ozlabs.org/api/patches/816491/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/1505940337-79069-10-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-10-git-send-email-keescook@chromium.org>","list_archive_url":null,"date":"2017-09-20T20:45:15","name":"[v3,09/31] jfs: Define usercopy region in jfs_ip slab cache","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":true,"hash":"1413f103a2a12cfec2c1564fb638f1d7d5b43cfd","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-10-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/816491/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816491/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=\"OjV934sg\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xyBhC4qtrz9s83\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 21 Sep 2017 06:50:03 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751878AbdITUtu (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 20 Sep 2017 16:49:50 -0400","from mail-pg0-f54.google.com ([74.125.83.54]:44971 \"EHLO\n\tmail-pg0-f54.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751870AbdITUqH (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 20 Sep 2017 16:46:07 -0400","by mail-pg0-f54.google.com with SMTP id j16so2342377pga.1\n\tfor <netdev@vger.kernel.org>; Wed, 20 Sep 2017 13:46:07 -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\td8sm9704958pfh.159.2017.09.20.13.45.59\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=YR1l6qWujzM7MWpWfchbfi7KVYl2yAFGYY7ov7EK8AA=;\n\tb=OjV934sgbQCdk5NA8tj/znL/3A7nAQfsTaf93wbx9fSmOq4NkzNekmS1fLmzUCZIPb\n\tpplKoA9oSvsgSuSrQlvei7OwCMQXdQZajL9FQqce6ur9wWZXFesBYbgDOyK0sTG9ONuj\n\tQnugS0dmrvnmbPwTJwvOfyYSsGQ5uRFygFbPc=","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=YR1l6qWujzM7MWpWfchbfi7KVYl2yAFGYY7ov7EK8AA=;\n\tb=HBuhNeRGlz2EgJdrQtPp9GEJHyidnU6uUcwzWmvfHj6aLU1WcWhauJDjlk3s+SJ9hC\n\tF9YjCMaojwgumz8rHZKjshSbyFo6zHX94hJXj1KYdFoWlqr790z3q6M4DZp9Yp6/BC/H\n\twrjhHCEdWjlNtvFgDhyb4pyRS9LhlgabVg8WqBPdUeG2MLgQpuPA140JoVlISxrfQPj2\n\tM4Y8lWr503PGIm4wDnOMndXsCLc6oMpQdv9+xPeMvK2yko61H5kso7ciC2NVW/8Dk9xM\n\tmtcNRU8dlUU1VEbeHPxHQXxPfBK4Vcf4eUdjQQSNdbApEZiEgvv0gsSJrX50JkEjZCz4\n\tyVUQ==","X-Gm-Message-State":"AHPjjUhgXfIQBSp0xd+SI7WjrYoKGBGXQkfO0FgFILFmjpD0FotDqvaL\n\tIF13gu7OtlOPaOMYDzT8wIA6Ew==","X-Google-Smtp-Source":"AOwi7QBzB+9Y9qmNJ0mBMHJ04EQ3RZW1ql3iHatix6aob/GXyJgcSnCzWgf43vHEzpyCLXLNvEwzgA==","X-Received":"by 10.99.50.3 with SMTP id y3mr3325340pgy.291.1505940366922;\n\tWed, 20 Sep 2017 13:46:06 -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\tDave Kleikamp <shaggy@kernel.org>, jfs-discussion@lists.sourceforge.net,\n\tlinux-fsdevel@vger.kernel.org, netdev@vger.kernel.org,\n\tlinux-mm@kvack.org, kernel-hardening@lists.openwall.com","Subject":"[PATCH v3 09/31] jfs: Define usercopy region in jfs_ip slab cache","Date":"Wed, 20 Sep 2017 13:45:15 -0700","Message-Id":"<1505940337-79069-10-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 jfs symlink pathnames, stored in struct jfs_inode_info.i_inline and\ntherefore contained in the jfs_ip slab cache, need to be copied to/from\nuserspace.\n\ncache object allocation:\n    fs/jfs/super.c:\n        jfs_alloc_inode(...):\n            ...\n            jfs_inode = kmem_cache_alloc(jfs_inode_cachep, GFP_NOFS);\n            ...\n            return &jfs_inode->vfs_inode;\n\n    fs/jfs/jfs_incore.h:\n        JFS_IP(struct inode *inode):\n            return container_of(inode, struct jfs_inode_info, vfs_inode);\n\n    fs/jfs/inode.c:\n        jfs_iget(...):\n            ...\n            inode->i_link = JFS_IP(inode)->i_inline;\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 in 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\njfs_ip slab cache in which userspace copy operations are allowed.\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: Dave Kleikamp <shaggy@kernel.org>\nCc: jfs-discussion@lists.sourceforge.net\nSigned-off-by: Kees Cook <keescook@chromium.org>\n---\n fs/jfs/super.c | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)","diff":"diff --git a/fs/jfs/super.c b/fs/jfs/super.c\nindex 2f14677169c3..e018412608d4 100644\n--- a/fs/jfs/super.c\n+++ b/fs/jfs/super.c\n@@ -966,9 +966,11 @@ static int __init init_jfs_fs(void)\n \tint rc;\n \n \tjfs_inode_cachep =\n-\t    kmem_cache_create(\"jfs_ip\", sizeof(struct jfs_inode_info), 0,\n-\t\t\t    SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_ACCOUNT,\n-\t\t\t    init_once);\n+\t    kmem_cache_create_usercopy(\"jfs_ip\", sizeof(struct jfs_inode_info),\n+\t\t\t0, SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_ACCOUNT,\n+\t\t\toffsetof(struct jfs_inode_info, i_inline),\n+\t\t\tsizeof_field(struct jfs_inode_info, i_inline),\n+\t\t\tinit_once);\n \tif (jfs_inode_cachep == NULL)\n \t\treturn -ENOMEM;\n \n","prefixes":["v3","09/31"]}