{"id":816488,"url":"http://patchwork.ozlabs.org/api/patches/816488/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/1505940337-79069-13-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-13-git-send-email-keescook@chromium.org>","list_archive_url":null,"date":"2017-09-20T20:45:18","name":"[v3,12/31] orangefs: Define usercopy region in orangefs_inode_cache slab cache","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":true,"hash":"33e1f51c3f0748eb2cd0e3813dbcbbafad9ae0b9","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-13-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/816488/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816488/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=\"CCiqGFNF\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xyBgC0hQgz9s83\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 21 Sep 2017 06:49:11 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751971AbdITUs6 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 20 Sep 2017 16:48:58 -0400","from mail-pg0-f52.google.com ([74.125.83.52]:53593 \"EHLO\n\tmail-pg0-f52.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751833AbdITUqJ (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 20 Sep 2017 16:46:09 -0400","by mail-pg0-f52.google.com with SMTP id j70so2326815pgc.10\n\tfor <netdev@vger.kernel.org>; Wed, 20 Sep 2017 13:46:09 -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\tl131sm9314645pga.24.2017.09.20.13.46.00\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=P4SFljHEyscsVLWOjbvOMPbmz2tjOkxe1+UySbOaIdE=;\n\tb=CCiqGFNFXpENRjZbIkMhUKnMTPXfuUFlfI1F6c8TCU7/vezwFnTsBZeQg6x5+31sAJ\n\tasHPS8XaMKEY9bCo/DaX/pavTD1dAtIpBslu0Um6nmBREXzOwVGxLj1TFx2ylft9YZVi\n\tIMbviqn4MSVKXOEfehRdn9G1IEgNKuQrllNGM=","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=P4SFljHEyscsVLWOjbvOMPbmz2tjOkxe1+UySbOaIdE=;\n\tb=XOoIFNehcn+N8ReZJcJ4j5rdUSbGO6v6sCedhOWGAPl9oNXxoT/jE2QaEE1tiH24/T\n\t8uwBUGJ3Y4rBObK7xnLwO+Z4jNs1bgrpUVu6ql2t38X9TTdpX7LrbQJfUrRO8p1h0C/a\n\tTLZD1NxJpPBmzPFeWCEPjReygi9etifXpdVOPRjj7FI9Tp6Kie1TIMIb23akGjqrPnsh\n\t5D8UHAR9MYWJ4RMEOJV+S2Q37AWeeOZ3SLtUb2FOgRfC2xNzcjDJZkryELawgwMoQ7ZI\n\tkWmXboazCitJjyhGgAWGclhYNGIaN7aKWT9FA/avbwjUaXPFHIOiJI6sWnOyyLoZLLvA\n\tjLOQ==","X-Gm-Message-State":"AHPjjUhtOaSQ2KrOvX32TfcPa4Vblgnjbtro+mNiM/AQ+C339I0/g+zh\n\tPpqOJhMWKJAj9/lZKP50uaLedw==","X-Google-Smtp-Source":"AOwi7QAS7O4I/BPDHUDiHC+t8CWTXY2AoTEKbLa9dJDQvOigCOMXn+/veg+vLBuEfB3mIrpexxCK0Q==","X-Received":"by 10.98.102.82 with SMTP id a79mr3462325pfc.109.1505940368821; \n\tWed, 20 Sep 2017 13:46:08 -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\tMike Marshall <hubcap@omnibond.com>,\n\tlinux-fsdevel@vger.kernel.org, netdev@vger.kernel.org,\n\tlinux-mm@kvack.org, kernel-hardening@lists.openwall.com","Subject":"[PATCH v3 12/31] orangefs: Define usercopy region in\n\torangefs_inode_cache slab cache","Date":"Wed, 20 Sep 2017 13:45:18 -0700","Message-Id":"<1505940337-79069-13-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\norangefs symlink pathnames, stored in struct orangefs_inode_s.link_target\nand therefore contained in the orangefs_inode_cache, need to be copied\nto/from userspace.\n\ncache object allocation:\n    fs/orangefs/super.c:\n        orangefs_alloc_inode(...):\n            ...\n            orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, ...);\n            ...\n            return &orangefs_inode->vfs_inode;\n\n    fs/orangefs/orangefs-utils.c:\n        exofs_symlink(...):\n            ...\n            inode->i_link = orangefs_inode->link_target;\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\norangefs_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: Mike Marshall <hubcap@omnibond.com>\nSigned-off-by: Kees Cook <keescook@chromium.org>\n---\n fs/orangefs/super.c | 15 ++++++++++-----\n 1 file changed, 10 insertions(+), 5 deletions(-)","diff":"diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c\nindex 47f3fb9cbec4..ee7b8bfa47c2 100644\n--- a/fs/orangefs/super.c\n+++ b/fs/orangefs/super.c\n@@ -624,11 +624,16 @@ void orangefs_kill_sb(struct super_block *sb)\n \n int orangefs_inode_cache_initialize(void)\n {\n-\torangefs_inode_cache = kmem_cache_create(\"orangefs_inode_cache\",\n-\t\t\t\t\t      sizeof(struct orangefs_inode_s),\n-\t\t\t\t\t      0,\n-\t\t\t\t\t      ORANGEFS_CACHE_CREATE_FLAGS,\n-\t\t\t\t\t      orangefs_inode_cache_ctor);\n+\torangefs_inode_cache = kmem_cache_create_usercopy(\n+\t\t\t\t\t\"orangefs_inode_cache\",\n+\t\t\t\t\tsizeof(struct orangefs_inode_s),\n+\t\t\t\t\t0,\n+\t\t\t\t\tORANGEFS_CACHE_CREATE_FLAGS,\n+\t\t\t\t\toffsetof(struct orangefs_inode_s,\n+\t\t\t\t\t\tlink_target),\n+\t\t\t\t\tsizeof_field(struct orangefs_inode_s,\n+\t\t\t\t\t\tlink_target),\n+\t\t\t\t\torangefs_inode_cache_ctor);\n \n \tif (!orangefs_inode_cache) {\n \t\tgossip_err(\"Cannot create orangefs_inode_cache\\n\");\n","prefixes":["v3","12/31"]}