From patchwork Sun Apr 1 06:34:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 10319077 X-Patchwork-Delegate: leon@leon.nu 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 56C1060247 for ; Sun, 1 Apr 2018 06:35:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3017828DB8 for ; Sun, 1 Apr 2018 06:35:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FF2E2916F; Sun, 1 Apr 2018 06:35: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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 6EC0528DB8 for ; Sun, 1 Apr 2018 06:35:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750841AbeDAGfR (ORCPT ); Sun, 1 Apr 2018 02:35:17 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:40580 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750827AbeDAGfQ (ORCPT ); Sun, 1 Apr 2018 02:35:16 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w316T9PD033361; Sun, 1 Apr 2018 06:35:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2017-10-26; bh=RGqvnOviHo6xJ14CLZOl5t6GWEurp7NcaMGmP1ioU28=; b=SQRvq2eo1VHPq6SG9ZfGudhLlUKvnxmzwwbCa7HOnMSQ1x3tjGCdMDTY+Q3PWi6vR57B I/O8/LvNKR4rVbRsjS4DpxCz48bOEHv1PM1T9W5Tcon+vVO3bXS0dp5zbEUp7FLa3WZf sxHADtSYu6p+Owj7GAHIk4cAi0ky2aDOSm9asReJfglq76R4XHUsY/qLPMRfe4GkTCog j+MOvoVGqhr6Sqb7TRpzdJGU3DlV9OCxpQ/W56u7OpCORd6o+Dfq4p0AssHTelIIOmbF jRHRdjvYXEZ10KTeA8D9LvkRMBfkQ129D5fJP7qABxNkNDwvUqoV9GBcutfkz29JQ6Hg 7g== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2h2t6ur0cw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 01 Apr 2018 06:35:11 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w316Z9ja022046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 1 Apr 2018 06:35:10 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w316Z9Ea018633; Sun, 1 Apr 2018 06:35:09 GMT Received: from yuvallap.nl.oracle.com (/10.175.29.98) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 31 Mar 2018 23:35:08 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com, linux-rdma@vger.kernel.org Cc: Yuval Shaia Subject: [PATCH] libibverb/examples: Protect against memory corruption Date: Sun, 1 Apr 2018 09:34:57 +0300 Message-Id: <20180401063457.5250-1-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.14.3 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8849 signatures=668697 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=748 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804010065 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure num_qp is less than MAX_QP so we will not overrun my_dest array. Signed-off-by: Yuval Shaia --- libibverbs/examples/srq_pingpong.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libibverbs/examples/srq_pingpong.c b/libibverbs/examples/srq_pingpong.c index c289b463..f0a3c221 100644 --- a/libibverbs/examples/srq_pingpong.c +++ b/libibverbs/examples/srq_pingpong.c @@ -759,6 +759,12 @@ int main(int argc, char *argv[]) return 1; } + if (num_qp > MAX_QP) { + fprintf(stderr, "num_qp %d must be less than %d\n", num_qp, + MAX_QP); + return 1; + } + num_wc = num_qp + rx_depth; wc = alloca(num_wc * sizeof *wc);