{"id":816487,"url":"http://patchwork.ozlabs.org/api/patches/816487/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/1505940337-79069-12-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-12-git-send-email-keescook@chromium.org>","list_archive_url":null,"date":"2017-09-20T20:45:17","name":"[v3,11/31] exofs: Define usercopy region in exofs_inode_cache slab cache","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":true,"hash":"6f9c8f90ca043c0d2fb83f8b72c8cfb7295c6f13","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-12-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/816487/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816487/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=\"W8b6GrVT\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xyBfj3Dpdz9s8J\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 21 Sep 2017 06:48:45 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751898AbdITUsn (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 20 Sep 2017 16:48:43 -0400","from mail-pg0-f51.google.com ([74.125.83.51]:50507 \"EHLO\n\tmail-pg0-f51.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751897AbdITUqL (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 20 Sep 2017 16:46:11 -0400","by mail-pg0-f51.google.com with SMTP id p5so2333811pgn.7\n\tfor <netdev@vger.kernel.org>; Wed, 20 Sep 2017 13:46:10 -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\tf2sm9787270pfg.135.2017.09.20.13.46.01\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 20 Sep 2017 13:46:08 -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=2ejy2ZaewEVWrIC2ft1+HA6IEafJqiE+Y65Qzj0gFlQ=;\n\tb=W8b6GrVTlp0QMiGb2fXzSBN6u0+CWy8UjPIajv/FL/1u4Ox4l8nJ4zM7fpx7JJl3YY\n\tH84vOPqsAuFKJZeagUHxifIAkJL9sUqGOWm9nt8UmIuI5MZG2uzkVZQDvrFFsWt2wxav\n\tgA0fNDeEi+RgChBu5+8WBZeKeGZQnZ6cDuOtY=","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=2ejy2ZaewEVWrIC2ft1+HA6IEafJqiE+Y65Qzj0gFlQ=;\n\tb=olOQOdpH8tJVYoRqern5u6xGGemhuoSyvfK1kez6K0PfI/zoa7U1rfLPtspzzuNfob\n\t9cswZtlbEXxJWgwmLGTnbq7H0NJ6Sc1VK+vZtDcTnw3jVN8iCdkJTXtxDEqLMNsOnFgh\n\tKcMBSQSMrSvFyvARQFRzJOiaWc8QcP+YLslREC/2pdISLzLeLIxeGfayMJQ2S9MBbGdP\n\tM0dzfRHSkhNpJv1mcCLAtEpi5E1mDAsQ7NU1fcIGkqYwVR/wQ/PNINO/P83pDJoVEu3a\n\txZtlfybrog1QWBOB5fN0Tz1XScw1HnbRLNQv+lpCjWm3YhFDYuIgogJJIVCE4rL+aw5K\n\tCryw==","X-Gm-Message-State":"AHPjjUjFvUOLvnF2rHNCgJkzLQZu6mEDADdfMvAuqc+5NvueoYyWADgS\n\tUjyyK3CzbT4VEfQ/6IFcgS7ewg==","X-Google-Smtp-Source":"AOwi7QB5R+I8CTm74widO7UyglY9ao0h0tZkBIeeanyhzeYoWJE99yEbcQ/OCVYSwlknIxV/7suFWA==","X-Received":"by 10.84.150.130 with SMTP id h2mr2966393plh.436.1505940370584; \n\tWed, 20 Sep 2017 13:46:10 -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\tBoaz Harrosh <ooo@electrozaur.com>,\n\tlinux-fsdevel@vger.kernel.org, netdev@vger.kernel.org,\n\tlinux-mm@kvack.org, kernel-hardening@lists.openwall.com","Subject":"[PATCH v3 11/31] exofs: Define usercopy region in exofs_inode_cache\n\tslab cache","Date":"Wed, 20 Sep 2017 13:45:17 -0700","Message-Id":"<1505940337-79069-12-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 exofs short symlink names, stored in struct exofs_i_info.i_data and\ntherefore contained in the exofs_inode_cache slab cache, need to be copied\nto/from userspace.\n\ncache object allocation:\n    fs/exofs/super.c:\n        exofs_alloc_inode(...):\n            ...\n            oi = kmem_cache_alloc(exofs_inode_cachep, GFP_KERNEL);\n            ...\n            return &oi->vfs_inode;\n\n    fs/exofs/namei.c:\n        exofs_symlink(...):\n            ...\n            inode->i_link = (char *)oi->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 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\nexofs_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: Boaz Harrosh <ooo@electrozaur.com>\nSigned-off-by: Kees Cook <keescook@chromium.org>\n---\n fs/exofs/super.c | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)","diff":"diff --git a/fs/exofs/super.c b/fs/exofs/super.c\nindex 819624cfc8da..e5c532875bb7 100644\n--- a/fs/exofs/super.c\n+++ b/fs/exofs/super.c\n@@ -192,10 +192,13 @@ static void exofs_init_once(void *foo)\n  */\n static int init_inodecache(void)\n {\n-\texofs_inode_cachep = kmem_cache_create(\"exofs_inode_cache\",\n+\texofs_inode_cachep = kmem_cache_create_usercopy(\"exofs_inode_cache\",\n \t\t\t\tsizeof(struct exofs_i_info), 0,\n \t\t\t\tSLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD |\n-\t\t\t\tSLAB_ACCOUNT, exofs_init_once);\n+\t\t\t\tSLAB_ACCOUNT,\n+\t\t\t\toffsetof(struct exofs_i_info, i_data),\n+\t\t\t\tsizeof_field(struct exofs_i_info, i_data),\n+\t\t\t\texofs_init_once);\n \tif (exofs_inode_cachep == NULL)\n \t\treturn -ENOMEM;\n \treturn 0;\n","prefixes":["v3","11/31"]}