From patchwork Tue Jan 9 20:55:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10153483 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 3120C60223 for ; Tue, 9 Jan 2018 21:12:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27BC2269B2 for ; Tue, 9 Jan 2018 21:12:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2612926B41; Tue, 9 Jan 2018 21:12:04 +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=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, URIBL_BLACK autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DEA328546 for ; Tue, 9 Jan 2018 21:11:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757094AbeAIVKz (ORCPT ); Tue, 9 Jan 2018 16:10:55 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:38391 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758481AbeAIU5H (ORCPT ); Tue, 9 Jan 2018 15:57:07 -0500 Received: by mail-pg0-f66.google.com with SMTP id t67so8808870pgc.5 for ; Tue, 09 Jan 2018 12:57:06 -0800 (PST) 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=S/YPhIRF2wWX7ylNFgNb5lfJzyyGnEMzQMNlRcIgRqYhnmWO4ewLCkcQxChEmZc4aD YFAgAO64HSHcLua0/vyCgC0YL7AoznilrMb3FTYoGo56YAwlC+peVAEDN+MkwQvhA/YU rceK1XxFoJb0z9ObYClrW8kNGWjRLaToSronw= 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=TpHXQcEL5wi7dJjymRjURovecWh73VGpBp8H18f1+0YmbE7Mh1L6ffoK717uzYafMN 3oyWKigtHQnjkasRAZ0oLIOnswXboBp9ByQ3qlTIMjTAZm9FxQRxkZdOKRbnipgufAwb TxJYH5b0HvJyk7JwIgEDmAPET+ntMSgR9lOTeV0AOtamLvdxN1AgrV/UWotHZ1IB0ZYe FOSzc5VMaC8CBOJCvGBV574YaeiswaLIP8ayHdSy8DyJlpCG4OqkrSf5FfZTUKpRoso6 VOf/yLTg23PRxVig/R85o47BCXPm79emxokL7bMjgT9dHdQR0JvY3c+2KEGeiZ4D3K37 +UTA== X-Gm-Message-State: AKGB3mLvG4OyXyAuLNHcghUapt1gEwHDhR/HF1cTcD5jtdwR9gnxl4i0 ez6tUdgf+mzQkOo+oV/TaMPmwQ== X-Google-Smtp-Source: ACJfBosr/lnZeXarw4XsYi+mKzkFqlsmkZgnh3acF6nDzU9RajxEqYDwhnSqirtpayg8QBojJtdGkA== X-Received: by 10.98.65.216 with SMTP id g85mr14920655pfd.76.1515531426491; Tue, 09 Jan 2018 12:57:06 -0800 (PST) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id g7sm30109213pfm.76.2018.01.09.12.57.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jan 2018 12:57:05 -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 Subject: [PATCH 22/36] caif: Define usercopy region in caif proto slab cache Date: Tue, 9 Jan 2018 12:55:51 -0800 Message-Id: <1515531365-37423-23-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515531365-37423-1-git-send-email-keescook@chromium.org> References: <1515531365-37423-1-git-send-email-keescook@chromium.org> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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))