Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/816506/?format=api
{ "id": 816506, "url": "http://patchwork.ozlabs.org/api/patches/816506/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/1505940337-79069-16-git-send-email-keescook@chromium.org/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "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-16-git-send-email-keescook@chromium.org>", "list_archive_url": null, "date": "2017-09-20T20:45:21", "name": "[v3,15/31] xfs: Define usercopy region in xfs_inode slab cache", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": true, "hash": "aebfcc5ac774296952d0e231f1ba50d654efe803", "submitter": { "id": 10641, "url": "http://patchwork.ozlabs.org/api/people/10641/?format=api", "name": "Kees Cook", "email": "keescook@chromium.org" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/1505940337-79069-16-git-send-email-keescook@chromium.org/mbox/", "series": [ { "id": 4231, "url": "http://patchwork.ozlabs.org/api/series/4231/?format=api", "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/816506/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/816506/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=\"AkupWvDs\"; dkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xyBsk3K1tz9s8J\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 21 Sep 2017 06:58:18 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752065AbdITU6B (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 20 Sep 2017 16:58:01 -0400", "from mail-pg0-f52.google.com ([74.125.83.52]:54647 \"EHLO\n\tmail-pg0-f52.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1752121AbdITUw4 (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 20 Sep 2017 16:52:56 -0400", "by mail-pg0-f52.google.com with SMTP id c137so2333132pga.11\n\tfor <netdev@vger.kernel.org>; Wed, 20 Sep 2017 13:52:56 -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\tp88sm10812099pfi.174.2017.09.20.13.52.48\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 20 Sep 2017 13:52:52 -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=gaXaGtAzWUjHAYO+dDE3MyF1jugAsF3WlrO9OWF7ql8=;\n\tb=AkupWvDsDo9VLBJFDJxdicWc1SHl254vWszXrtfhy8aTcsNsrapTZQDkVEaV00KImy\n\tje3p6wQ4Sw3q8iqnZiiFir6bLBIi+wjrLoNwS2ffEFWc1O7FtDO44NdeU3SHOtHSMfki\n\txKsDkp+DrHJX5JlXBuW4MlxM8ws5AKHFVmCzw=", "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=gaXaGtAzWUjHAYO+dDE3MyF1jugAsF3WlrO9OWF7ql8=;\n\tb=gKZOCqQEm1cWHNIGADACDN9GCFl/7G4ncbzza3JYC7X5fFFGEiRczt4maW3InpeevV\n\tTKFDhtOR6BXyK4GfPaULGzLTqZei7v87vIidxROV2WZdVcGyhpQ8wz2Uu2Kln5/CTjOF\n\tQiWMkvnAy2LFmwHG0flwMWeUgixE+4lD30ZOUx7oDgiiVWvOcatYDwsRNaodS01kqQoX\n\tsJIolYIJrUNTb0yCaBhlIS5VTx4VlQ7hUMdRttkINK5ZXVW7f5/9E2efATpDpLCir6GJ\n\tMxVcZSUP/obt55a4pFIise8bHzK2iXMp+U0DcBvoe9jHcPlqQwQCM4uT/6jmieuMxq1F\n\t/uIA==", "X-Gm-Message-State": "AHPjjUhNN4Wj7b/JTISpEUMNqh+6WU1BpWdt9JqNKE9GodGnNOVG8sS0\n\t5F7j7Hxrrgd4mC7ezoBoNa6qsA==", "X-Google-Smtp-Source": "AOwi7QAOjJ3BLMjLoVi/3ZW4pccAEwZ02oHJI5TWwrTEoEykyF+Wr5UwZjDbWxwULJOSca6J3qB/Dw==", "X-Received": "by 10.84.240.196 with SMTP id l4mr3311980plt.443.1505940775819; \n\tWed, 20 Sep 2017 13:52:55 -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\t\"Darrick J. Wong\" <darrick.wong@oracle.com>,\n\tlinux-xfs@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 15/31] xfs: Define usercopy region in xfs_inode slab cache", "Date": "Wed, 20 Sep 2017 13:45:21 -0700", "Message-Id": "<1505940337-79069-16-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 XFS inline inode data, stored in struct xfs_inode_t field\ni_df.if_u2.if_inline_data and therefore contained in the xfs_inode slab\ncache, needs to be copied to/from userspace.\n\ncache object allocation:\n fs/xfs/xfs_icache.c:\n xfs_inode_alloc(...):\n ...\n ip = kmem_zone_alloc(xfs_inode_zone, KM_SLEEP);\n\n fs/xfs/libxfs/xfs_inode_fork.c:\n xfs_init_local_fork(...):\n ...\n if (mem_size <= sizeof(ifp->if_u2.if_inline_data))\n ifp->if_u1.if_data = ifp->if_u2.if_inline_data;\n ...\n\n fs/xfs/xfs_symlink.c:\n xfs_symlink(...):\n ...\n xfs_init_local_fork(ip, XFS_DATA_FORK, target_path, pathlen);\n\nexample usage trace:\n readlink_copy+0x43/0x70\n vfs_readlink+0x62/0x110\n SyS_readlinkat+0x100/0x130\n\n fs/xfs/xfs_iops.c:\n (via inode->i_op->get_link)\n xfs_vn_get_link_inline(...):\n ...\n return XFS_I(inode)->i_df.if_u1.if_data;\n\n fs/namei.c:\n readlink_copy(..., link):\n ...\n copy_to_user(..., link, len);\n\n generic_readlink(dentry, ...):\n struct inode *inode = d_inode(dentry);\n const char *link = inode->i_link;\n ...\n if (!link) {\n link = inode->i_op->get_link(dentry, inode, &done);\n ...\n readlink_copy(..., link);\n\nIn support of usercopy hardening, this patch defines a region in the\nxfs_inode 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: \"Darrick J. Wong\" <darrick.wong@oracle.com>\nCc: linux-xfs@vger.kernel.org\nSigned-off-by: Kees Cook <keescook@chromium.org>\nReviewed-by: Darrick J. Wong <darrick.wong@oracle.com>\n---\n fs/xfs/kmem.h | 10 ++++++++++\n fs/xfs/xfs_super.c | 7 +++++--\n 2 files changed, 15 insertions(+), 2 deletions(-)", "diff": "diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h\nindex 4d85992d75b2..08358f38dee6 100644\n--- a/fs/xfs/kmem.h\n+++ b/fs/xfs/kmem.h\n@@ -110,6 +110,16 @@ kmem_zone_init_flags(int size, char *zone_name, unsigned long flags,\n \treturn kmem_cache_create(zone_name, size, 0, flags, construct);\n }\n \n+static inline kmem_zone_t *\n+kmem_zone_init_flags_usercopy(int size, char *zone_name, unsigned long flags,\n+\t\t\t\tsize_t useroffset, size_t usersize,\n+\t\t\t\tvoid (*construct)(void *))\n+{\n+\treturn kmem_cache_create_usercopy(zone_name, size, 0, flags,\n+\t\t\t\tuseroffset, usersize, construct);\n+}\n+\n+\n static inline void\n kmem_zone_free(kmem_zone_t *zone, void *ptr)\n {\ndiff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c\nindex c996f4ae4a5f..1b4b67194538 100644\n--- a/fs/xfs/xfs_super.c\n+++ b/fs/xfs/xfs_super.c\n@@ -1846,9 +1846,12 @@ xfs_init_zones(void)\n \t\tgoto out_destroy_efd_zone;\n \n \txfs_inode_zone =\n-\t\tkmem_zone_init_flags(sizeof(xfs_inode_t), \"xfs_inode\",\n+\t\tkmem_zone_init_flags_usercopy(sizeof(xfs_inode_t), \"xfs_inode\",\n \t\t\tKM_ZONE_HWALIGN | KM_ZONE_RECLAIM | KM_ZONE_SPREAD |\n-\t\t\tKM_ZONE_ACCOUNT, xfs_fs_inode_init_once);\n+\t\t\t\tKM_ZONE_ACCOUNT,\n+\t\t\toffsetof(xfs_inode_t, i_df.if_u2.if_inline_data),\n+\t\t\tsizeof_field(xfs_inode_t, i_df.if_u2.if_inline_data),\n+\t\t\txfs_fs_inode_init_once);\n \tif (!xfs_inode_zone)\n \t\tgoto out_destroy_efi_zone;\n \n", "prefixes": [ "v3", "15/31" ] }