Received: by 10.213.65.16 with SMTP id m16csp43026imf; Sun, 11 Mar 2018 14:11:15 -0700 (PDT) X-Google-Smtp-Source: AG47ELvuDIn6GqS7UpDzOscbjRGhpiZnyER+NRh6b/oT5cxG0qvNbcFigQZiTodBVcONmzLCxCbV X-Received: by 10.98.246.16 with SMTP id x16mr5688618pfh.81.1520802674989; Sun, 11 Mar 2018 14:11:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520802674; cv=none; d=google.com; s=arc-20160816; b=ZvVyvU+NXw1sPlbkRMV2hPNYWDOwCmbYt2PRmrvzNSQ97J5weGAjKNNzMFsgQf0nql ERFZQHBGmanvzG/7dYwpUxb9uPMDmHmUa43pYtdyBy1HVhsOmj417kbiaPTgXXxdJMSu ATAB1ti5irYX43nzsNQhUdfUBQDZ3qxF8nmLAvx7D3B8YAI8cCDO2D9Us2lgAXkJ0AiY +vKKiQ+nZmnKt0y8fAoJ1oVGxhQirhwR7aEoS5LgBMFDS0UvWY04V6u/L0k24CsVpTfg aCfrJkp68DZsnGXMwN+0H8XObEygHNr/F/gMbahGlae+d+iJc0gTHj8HM6sgaeJuGn6r ikTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ASBoo/iq4FnQZM67OtjBA1CkBLKa93AR6pHEA4zVrsA=; b=BKs8uZOPDvE83gsLd3rIUE8GKPwh1BEwuC91w26PkedWDtm8nL9A/06LHPvG4s5CXN gtw4t6RfOtN5fWm7WUWGVziCVRIr/iyVrD8VJdwfSlbftT7qfZqDoG4N12/kNOCBZXh/ TGXVg1XJ8tnvtWa0CfTU8r2Dq0kTA518+HXGzc45YSXzDlRWGqZVPoq2cC4rGztITnWx N0XIYKWr/bOdviN2fpMAQgzbgB0K0m5cpHb43XnoojvB3QdnFzPlAiUEEbDpV6ayAF5E PDB5+2TjVF80He2NydnuxULZfzRkGG5t7//nvOnxBBCRzjbHlalCNVmM/KQ3R5AYUP3v edMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IRCQpDnS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97-v6si4839593ple.349.2018.03.11.14.11.00; Sun, 11 Mar 2018 14:11:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IRCQpDnS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932384AbeCKVJy (ORCPT + 99 others); Sun, 11 Mar 2018 17:09:54 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:44308 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932235AbeCKVJw (ORCPT ); Sun, 11 Mar 2018 17:09:52 -0400 Received: by mail-wr0-f195.google.com with SMTP id v65so13723127wrc.11; Sun, 11 Mar 2018 14:09:51 -0700 (PDT) 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=CoYktW4cplmYeDDTAr0MMjwViUMHtfSGVAXBUK1D/2XO+zuxqXw+pFKCX6eATzLl8U 5/Yh7p7xL9QPrVX3Y2AFomgkCTgwZyjkNayufn4kLiXsUrjjw9sHI8DI+h+V7DAFFx6F U7BdWLRY1dMchV2CW84DIHIXakTTCNW48gqr2kb+ajh//u/g3qDU9vehe9yWyGV0dFrY xAjP2BvyihawozIkLzhP9ivwYRzWwRWMj4516sd8J9EX1XjvatwdOAHPScLBEx/YcMcr wKyFmxV7FXbxbj+DiNRMZdah8UicEKlXH/5PdhlGSLUH7SDUsC6auaRdKu/k4oWCVN4J r5EQ== X-Gm-Message-State: AElRT7FPZZzigsvl9Vx9Nz4JgBrZ3ml8KcWTBNirshKr4GeU071MKPO+ 08nd1V+/DBWTaqgB0Z8XdRPaq6erKV3NEw== X-Received: by 10.223.161.194 with SMTP id v2mr4272476wrv.48.1520802590614; Sun, 11 Mar 2018 14:09:50 -0700 (PDT) Received: from localhost ([37.177.59.159]) by smtp.gmail.com with ESMTPSA id 10sm10053988wrv.95.2018.03.11.14.09.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 1.9.1