From patchwork Mon Jun 19 23:36:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9798091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5D24760381 for ; Mon, 19 Jun 2017 23:41:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A3A61FFB9 for ; Mon, 19 Jun 2017 23:41:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F00D27DCD; Mon, 19 Jun 2017 23:41:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, URIBL_BLACK autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id D6FA126C9B for ; Mon, 19 Jun 2017 23:40:15 +0000 (UTC) Received: (qmail 15905 invoked by uid 550); 19 Jun 2017 23:37:31 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 12009 invoked from network); 19 Jun 2017 23:37:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2QzpNDdo3hhyUIchMEp3ogSNacfhBXAP5brana3zyBo=; b=k3rb4Q2NG0UeMYkYPtLEFbXRNJzh9p+NXnLrcQYvY+Odvf7P3kAro4inXZIKkG07iw drIXsyjNO7FmYKIZfmBzWkbKISdRhTU6IHXvhQATBqEJkDgrooYlU0Q+hRximU3SurCs oEl7aWrtyc4zl9IkYipRSvaD9vCZc2uN18Dng= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2QzpNDdo3hhyUIchMEp3ogSNacfhBXAP5brana3zyBo=; b=VO6QXAXV50Dp7dE67XLSJ/ElDt543iS+MaSFJi/wKtyQ2U3ZHAp+gYZA6fZpwSk2/m LK3mDsktDLxrSQPp2p1ruRdd35iSKu3u+eVaeqfbI5rVj9EeeIJm6FnCLqiSQWfFr2zM VcNWUirvo1SJOz5Tq5EKh/qqyqWjJyXnCJLgbc81WolTXj/fw54Ov4ZYjY2CqkO8WJZo tGYzbIsF/Fjqt3S1z5KeT9Uy3TylHspqSWn2hm4d26cPOshHizI4VO6ojhsPEMpvoMqw c1kl06RiMoSid7deALjJIYva6m9S2BxQVAC1WChaSFIPTcjJzffHpigcZDSUueVN+6Ic N+GQ== X-Gm-Message-State: AKS2vOxWySDsrQGnlDWT9dytVU35+H0vmAEei6+O2GSUsdW0OfgdsNRC 6qIOZrK1oQOUatjT X-Received: by 10.99.63.140 with SMTP id m134mr28828948pga.170.1497915416496; Mon, 19 Jun 2017 16:36:56 -0700 (PDT) From: Kees Cook To: kernel-hardening@lists.openwall.com Cc: Kees Cook , David Windsor , linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Mon, 19 Jun 2017 16:36:27 -0700 Message-Id: <1497915397-93805-14-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497915397-93805-1-git-send-email-keescook@chromium.org> References: <1497915397-93805-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH 13/23] ufs: define usercopy region in ufs_inode_cache slab cache X-Virus-Scanned: ClamAV using ClamSMTP From: David Windsor The ufs symlink pathnames, stored in struct ufs_inode_info.i_u1.i_symlink and therefore contained in the ufs_inode_cache slab cache, need to be copied to/from userspace. In support of usercopy hardening, this patch defines a region in the ufs_inode_cache slab cache in which userspace copy operations are allowed. This region is known as the slab cache's usercopy region. Slab caches can now check that each copy operation involving cache-managed memory falls entirely within the slab's usercopy region. This patch is modified from Brad Spengler/PaX Team's PAX_USERCOPY whitelisting code in the last public patch of grsecurity/PaX based on my understanding of the code. Changes or omissions from the original code are mine and don't reflect the original grsecurity/PaX code. Signed-off-by: David Windsor [kees: adjust commit log] Signed-off-by: Kees Cook --- fs/ufs/super.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 878cc6264f1a..fa001feed14a 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -1441,11 +1441,14 @@ static void init_once(void *foo) static int __init init_inodecache(void) { - ufs_inode_cachep = kmem_cache_create("ufs_inode_cache", - sizeof(struct ufs_inode_info), - 0, (SLAB_RECLAIM_ACCOUNT| - SLAB_MEM_SPREAD|SLAB_ACCOUNT), - init_once); + ufs_inode_cachep = kmem_cache_create_usercopy("ufs_inode_cache", + sizeof(struct ufs_inode_info), 0, + (SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD| + SLAB_ACCOUNT), + offsetof(struct ufs_inode_info, i_u1.i_symlink), + sizeof_field(struct ufs_inode_info, + i_u1.i_symlink), + init_once); if (ufs_inode_cachep == NULL) return -ENOMEM; return 0;