From patchwork Sun Mar 11 21:07:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salvatore Mesoraca X-Patchwork-Id: 10274943 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 5EB60602C2 for ; Sun, 11 Mar 2018 21:10:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DBB2289E4 for ; Sun, 11 Mar 2018 21:10:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EE6028AE6; Sun, 11 Mar 2018 21:10:05 +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=-4.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_MED 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 652BE289E4 for ; Sun, 11 Mar 2018 21:10:04 +0000 (UTC) Received: (qmail 7769 invoked by uid 550); 11 Mar 2018 21:10:02 -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 7729 invoked from network); 11 Mar 2018 21:10:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ASBoo/iq4FnQZM67OtjBA1CkBLKa93AR6pHEA4zVrsA=; b=IRCQpDnSqUJuICnxd/uRoORFBYJzqMvrOrXYj3RxVuqClvH/tHGLpdUwCvlueorG+e 1JfyBaIeM0LEHgoUH2kndBf0OPS3JqACBhmMzcNDzf4t0fE/twmgPU0o2lArLXT93haU oMLiYiPe/Mw8+eaPecoyg0guONJbNAQLlezVMODF8ikyfsKlfGrpYKDTvtUFO7GsacuJ efY8FGIV1adYeguO7+Zby3rpZo1REGnQWNkU4F7/m4zLocVYD/fY4gXCQLylaXt0zm18 z9wuXrP+ohxoX1hqgGHDzOlRCa6Nz7QEjIkmlFKwtJ7d7fpJvaohdLTc5OAKoApKNviY gsDw== 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; bh=ASBoo/iq4FnQZM67OtjBA1CkBLKa93AR6pHEA4zVrsA=; b=bAoQviRAY+B5tWwMLQBH6TcS1U/1kEOlVczhsm/6YQ+d7enWia12O2XPMvArWGeALK sxmsTRHkxXfIxtCh7Ikf/bKYi+H0WelBQ+rQP/NpB7pDa/Wj8o4fSHsqhlj0VkLn8IKW tqYELUR4bLc0yWIUg/5HGM8leSlJbfH9ZJNr5t28CQ015CVhVg0NnpQokLClqkkWMYjb MusCfZQbML9gvBLN8f764pRw0g+qc7YmiI7qnc3GeobiJZ+pon6un+36zdhdWDBG6a65 zrdNARgxLYdHEXg3Tt6x5VOoncVwPzHKtGBRjZ9JSsLNsCWRXfjVEMGTSvLthH5sF1j0 t0IA== X-Gm-Message-State: AElRT7ESkj0T82VYskp0+B3d7/g9CeHMH0T++0e0IlgwVTLvZ8LaSyZm om8hRHr/nTDf0nJU8Yde/uw= X-Google-Smtp-Source: AG47ELsBy8fCuELjM13bfh6Jrw0yDmSi6q0o3/tQU17B1l6DdDYO0gTpil9uckWOYxAU2snJCemaSA== X-Received: by 10.223.161.194 with SMTP id v2mr4272476wrv.48.1520802590614; Sun, 11 Mar 2018 14:09:50 -0700 (PDT) From: Salvatore Mesoraca To: linux-kernel@vger.kernel.org Cc: kernel-hardening@lists.openwall.com, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, "David S. Miller" , Kees Cook , Salvatore Mesoraca , Santosh Shilimkar Subject: [PATCH 1/2] net: rds: drop VLA in rds_for_each_conn_info() Date: Sun, 11 Mar 2018 22:07:49 +0100 Message-Id: <1520802470-17374-1-git-send-email-s.mesoraca16@gmail.com> X-Mailer: git-send-email 1.9.1 X-Virus-Scanned: ClamAV using ClamSMTP Avoid VLA[1] by using an already allocated buffer passed by the caller. [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Salvatore Mesoraca --- net/rds/connection.c | 2 +- net/rds/ib.c | 3 +++ net/rds/rds.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/net/rds/connection.c b/net/rds/connection.c index 2da3176..f80792c 100644 --- a/net/rds/connection.c +++ b/net/rds/connection.c @@ -540,9 +540,9 @@ void rds_for_each_conn_info(struct socket *sock, unsigned int len, struct rds_info_iterator *iter, struct rds_info_lengths *lens, int (*visitor)(struct rds_connection *, void *), + u64 *buffer, size_t item_len) { - uint64_t buffer[(item_len + 7) / 8]; struct hlist_head *head; struct rds_connection *conn; size_t i; diff --git a/net/rds/ib.c b/net/rds/ib.c index 50a88f3..02deee2 100644 --- a/net/rds/ib.c +++ b/net/rds/ib.c @@ -321,8 +321,11 @@ static void rds_ib_ic_info(struct socket *sock, unsigned int len, struct rds_info_iterator *iter, struct rds_info_lengths *lens) { + u64 buffer[(sizeof(struct rds_info_rdma_connection) + 7) / 8]; + rds_for_each_conn_info(sock, len, iter, lens, rds_ib_conn_info_visitor, + buffer, sizeof(struct rds_info_rdma_connection)); } diff --git a/net/rds/rds.h b/net/rds/rds.h index 7301b9b..91ea08f 100644 --- a/net/rds/rds.h +++ b/net/rds/rds.h @@ -709,6 +709,7 @@ void rds_for_each_conn_info(struct socket *sock, unsigned int len, struct rds_info_iterator *iter, struct rds_info_lengths *lens, int (*visitor)(struct rds_connection *, void *), + u64 *buffer, size_t item_len); __printf(2, 3)