From patchwork Thu Jan 11 02:02:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10156569 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 AB968605BA for ; Thu, 11 Jan 2018 02:11:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9995528749 for ; Thu, 11 Jan 2018 02:11:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E0212874B; Thu, 11 Jan 2018 02:11:23 +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 9A3F728749 for ; Thu, 11 Jan 2018 02:11:22 +0000 (UTC) Received: (qmail 28656 invoked by uid 550); 11 Jan 2018 02:09:56 -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 28536 invoked from network); 11 Jan 2018 02:09:51 -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=Cl4EzZIQI+I/4hmhOifD4BG5/ryirhxAWdzufaYdQlI=; b=jQ/xIYNGJPUpRslvCVun0UHM+sxTFa5Bo+igqO6Fk677n1FnuHVAwvsVrPDz88SSZr MXEAs29JCPxFfMOAHvHhz3TVbDZrJ/A8JSPr36FC4NIB6NC7L5IOF+cO+WLr7f9Zz1fS 01LFrf0btHfPHPugDzz79iVr18g86mO3T0b1s= 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=Cl4EzZIQI+I/4hmhOifD4BG5/ryirhxAWdzufaYdQlI=; b=uVRAXC6hRRL/qns1YMYpTpaDtTLTjwf5PLvQmqhY9LFoW31F0S/iTfPGQ6v2hY5Msk eRjkzj2xwYOMBybLs7OYF2RaeGcShXHEZH8NU8fQ9Vznb1WM62KzvETNvWaNEKRUTduL mDynOUn9um9HsgReRc3Zlz6quce+i2rHgG43yqS8qekFr3DVFrkKqudjABGdfyC8nELB czOiamOsXfb8O+lHS3tpFlS87tm1eyZj+8JlILgSHeV5HSF7tisaU7gPZR9ioW14rH7p p+KCSO1oodRwjXlZmTBA0cEQUqV197tSyJRenk0XypynvbKs4k+V03zvSJ1576u3XH6f F+ZQ== X-Gm-Message-State: AKwxytfbLp4U8LkQjpU/Ci6vmAFqYQpIISsj+O8Krk8gfL80ROFsYhx3 GDBnF5shJjQShMLpIX9vOan0uQ== X-Google-Smtp-Source: ACJfBosT9jWXMTCX0sXBLdudgzZkS77/GHF/c8x30TJjTIclpiSrcUHl85zrpleJz/PUFEI1XdaPFg== X-Received: by 10.99.188.17 with SMTP id q17mr2382596pge.43.1515636580079; Wed, 10 Jan 2018 18:09:40 -0800 (PST) From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , David Windsor , "David S. Miller" , netdev@vger.kernel.org, Linus Torvalds , Alexander Viro , Andrew Morton , Andy Lutomirski , Christoph Hellwig , Christoph Lameter , Laura Abbott , Mark Rutland , "Martin K. Petersen" , Paolo Bonzini , Christian Borntraeger , Christoffer Dall , Dave Kleikamp , Jan Kara , Luis de Bethencourt , Marc Zyngier , Rik van Riel , Matthew Garrett , linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, kernel-hardening@lists.openwall.com Date: Wed, 10 Jan 2018 18:02:57 -0800 Message-Id: <1515636190-24061-26-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515636190-24061-1-git-send-email-keescook@chromium.org> References: <1515636190-24061-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH 25/38] caif: Define usercopy region in caif proto slab cache X-Virus-Scanned: ClamAV using ClamSMTP From: David Windsor The CAIF channel connection request parameters need to be copied to/from userspace. In support of usercopy hardening, this patch defines a region in the struct proto slab cache in which userspace copy operations are allowed. example usage trace: net/caif/caif_socket.c: setsockopt(...): ... copy_from_user(&cf_sk->conn_req.param.data, ..., ol) This region is known as the slab cache's usercopy region. Slab caches can now check that each dynamically sized 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: split from network patch, provide usage trace] Cc: "David S. Miller" Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook --- net/caif/caif_socket.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c index 632d5a416d97..c76d513b9a7a 100644 --- a/net/caif/caif_socket.c +++ b/net/caif/caif_socket.c @@ -1032,6 +1032,8 @@ static int caif_create(struct net *net, struct socket *sock, int protocol, static struct proto prot = {.name = "PF_CAIF", .owner = THIS_MODULE, .obj_size = sizeof(struct caifsock), + .useroffset = offsetof(struct caifsock, conn_req.param), + .usersize = sizeof_field(struct caifsock, conn_req.param) }; if (!capable(CAP_SYS_ADMIN) && !capable(CAP_NET_ADMIN))