From patchwork Thu Jun 7 14:57:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10452525 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 0FDC660234 for ; Thu, 7 Jun 2018 14:57:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00E962960B for ; Thu, 7 Jun 2018 14:57:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7DCD29625; Thu, 7 Jun 2018 14:57:40 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DEF52960B for ; Thu, 7 Jun 2018 14:57:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 16CCC6B02A2; Thu, 7 Jun 2018 10:57:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CB9346B02A3; Thu, 7 Jun 2018 10:57:28 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 767936B02A5; Thu, 7 Jun 2018 10:57:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f72.google.com (mail-pl0-f72.google.com [209.85.160.72]) by kanga.kvack.org (Postfix) with ESMTP id 2419B6B02A4 for ; Thu, 7 Jun 2018 10:57:28 -0400 (EDT) Received: by mail-pl0-f72.google.com with SMTP id c6-v6so5535543pll.4 for ; Thu, 07 Jun 2018 07:57:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=p+lQr6bAugSImnC9444JxiiPjhXApjVlWYwVp+W2KAI=; b=Vs0Yxng/Amkmyp3bb/od7CCuuEmZYvNtbZZTrzMDjUdce4gRY8tfMkBye/EwQLB+nB QgUMFj1lhf3rh+uCsAWDoHam1zJQpwCO7WKedPy5Q1+RPCuGv3dd0wMoUIWVhKmQevV1 nt17X2BRJ2IL++/T/cOXdY14jzJIqz0l8dwIUz4U2seBc0vSXYvPf6hfWt0sKzgfvkgq hyTPw6NluSz6nuqumcaw54iqrRhc/aJTAT6xJLC3aTo879xphVBcMxjjzv2mZuqGopng 3AO0YM+6yrL6jjHLvCaJQIg5wyYxzlVerBUIOMCChiPZKwvYBwgngtYoNCC6fxH3yeIS 3Yhw== X-Gm-Message-State: APt69E2TwwvOhJei0HL9D0XDKzIi6zt0zXlIGipvSM93vZtCpvhoohP1 Lzv3rcRiW51bsNFzEuaRH+s6yPJGQjwvnN+glb9V9deFvSVblIyEKf3cZNUzbVFvWR/lPjrNVAM QsyHkg57DzUdvZz69Nk0C+I4tyubE8S4qoQdxcTreO40mZhfRnb6N3YQINf4K9X0wXg== X-Received: by 2002:a63:3348:: with SMTP id z69-v6mr1819907pgz.171.1528383447830; Thu, 07 Jun 2018 07:57:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLkqeEFJW7o3uQOO1+9S1N5OcLK0QpCqLLegz7p0eX55Eh5G/0gFEgbkDr/UZC0yUGYA3+4 X-Received: by 2002:a63:3348:: with SMTP id z69-v6mr1819855pgz.171.1528383446665; Thu, 07 Jun 2018 07:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528383446; cv=none; d=google.com; s=arc-20160816; b=zY6bgr8fUSYod8zUB5MSFVXGHUtrxiZLkEVdCL/IuuJnlOMkBUxi+FljrVcfhjWJOw cjMrXJeccGkWkSmIsBJQqQYvOdyitq7OMvacWe3QHdk3QqzZ6r37hAH/mi4e5028KCgT cd5URGmWyzz7Fwi8+LSZmIkh2J/KthDJi120OgxXcU799YwOEpZnxEbvWfNSqt9+iajf Pv4yJlHGeZMSsqCKo3g7E6y7x3SDYtUkN9T3axEQoNYWWvYu64HKZpSMtCYUDV2GRs99 mVNOJQJ4Udjay04fGqbU7R7NVlqiLPgOrfjQJBhCq3aejoDRBwHUKl+irQWbQt99Xurq cpzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=p+lQr6bAugSImnC9444JxiiPjhXApjVlWYwVp+W2KAI=; b=qZ2mO1begpL6PSj1UVKVLmMNXXNQ7Qi+OYIs/MiUEkfk91oQQ9Qz7tCqgBUH3cK0Y+ Yxqi0Lf9B0D6W3YU1lpEPlC59IPMYpzwi6dnHO6DgT5mXs308F+v+GXXzi5Ne+6Leyj9 NHKLNHZZ5P/MhFkWUsa37+YDflNGwUmDbvI7/vE+ItJcPIcUsjLzkJkfpT9J8GKisbUu JCAWQJCzToruX5CVbfGwKlEEOEoO2K8t31qIxbprsn6VeqPpvOu9C551GUOFRPTd6gF9 XNIUf90481nn8qZlUpdHzoeVJWNlQG1B+Z+XD+PyX+Rkf8yNqZlJeI/ssJozdI0Rw6VZ lWdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=gbA5tF1K; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id t13-v6si30479831pgs.242.2018.06.07.07.57.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Jun 2018 07:57:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=gbA5tF1K; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=p+lQr6bAugSImnC9444JxiiPjhXApjVlWYwVp+W2KAI=; b=gbA5tF1KgJmlJfbYcAgk0bwux Svd3q/JqkBzlvA9QdOWP9G4JL/32nXM8Sw27EIvRN4TviGguTLfQB0pPbup33NzFeB+davpWZOMrP kE0eEPsYbQptIJ1g7x+yTeUabDG4s/ayTfpxe3TJCKyjG3gL5g2gQWjIpJZuyqHy/pCHCJt8GsFQF v981eKjb76d/HsvXnr8jkZab19KMCLOn3bLgYI2hYgu5W5lvfEREU595P9SrFWZkTgJP4EY1un4bk 1rOBBksdq6/JoMCuK0X7NKPZfjPmg830ZwI3RHyZDskD2ZGSrB5qdiVFKBRdyEIrA6BiidOduIlkJ y6lz6w2VA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQwLs-0005tn-OG; Thu, 07 Jun 2018 14:57:24 +0000 From: Matthew Wilcox To: Kees Cook Cc: Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH 2/6] Convert infiniband uverbs to struct_size Date: Thu, 7 Jun 2018 07:57:16 -0700 Message-Id: <20180607145720.22590-3-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180607145720.22590-1-willy@infradead.org> References: <20180607145720.22590-1-willy@infradead.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox The flows were hidden from the C compiler; expose them as a zero-length array to allow struct_size to work. Signed-off-by: Matthew Wilcox --- drivers/infiniband/core/uverbs_cmd.c | 4 ++-- include/rdma/ib_verbs.h | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index e3662a8ee465..67cab6102f7a 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -3478,8 +3478,8 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, goto err_uobj; } - flow_attr = kzalloc(sizeof(*flow_attr) + cmd.flow_attr.num_of_specs * - sizeof(union ib_flow_spec), GFP_KERNEL); + flow_attr = kzalloc(struct_size(flow_attr, flows, + cmd.flow_attr.num_of_specs), GFP_KERNEL); if (!flow_attr) { err = -ENOMEM; goto err_put; diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 9fc8a825aa28..bb6125ceb187 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2035,10 +2035,7 @@ struct ib_flow_attr { u32 flags; u8 num_of_specs; u8 port; - /* Following are the optional layers according to user request - * struct ib_flow_spec_xxx - * struct ib_flow_spec_yyy - */ + union ib_flow_spec flows[]; }; struct ib_flow {